Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the AI model
|
5 |
+
model = pipeline("text-generation", model="STEM-AI-mtl/phi-2-electrical-engineering")
|
6 |
+
|
7 |
+
# Function to process user questions
|
8 |
+
def get_ai_answer(question):
|
9 |
+
response = model(question, max_length=200, do_sample=True)
|
10 |
+
return response[0]["generated_text"]
|
11 |
+
|
12 |
+
# Gradio UI
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=get_ai_answer,
|
15 |
+
inputs="text",
|
16 |
+
outputs="text",
|
17 |
+
title="Circuit Debugging AI",
|
18 |
+
description="Ask electrical engineering or circuit debugging questions!"
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch
|
22 |
+
iface.launch()
|