Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
-
# ✅ Set up Hugging Face client
|
| 6 |
client = InferenceClient(
|
| 7 |
model="microsoft/Phi-3-mini-4k-instruct",
|
| 8 |
token=os.environ["HF_TOKEN"]
|
|
@@ -48,9 +48,14 @@ Return the result in this format:
|
|
| 48 |
<code_here>
|
| 49 |
```
|
| 50 |
"""
|
| 51 |
-
|
| 52 |
-
response = client.
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
# 🎨 Gradio UI
|
| 56 |
with gr.Blocks() as demo:
|
|
@@ -104,4 +109,4 @@ with gr.Blocks() as demo:
|
|
| 104 |
show_progress=True
|
| 105 |
)
|
| 106 |
|
| 107 |
-
demo.launch()
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
# ✅ Set up Hugging Face client with Phi-3
|
| 6 |
client = InferenceClient(
|
| 7 |
model="microsoft/Phi-3-mini-4k-instruct",
|
| 8 |
token=os.environ["HF_TOKEN"]
|
|
|
|
| 48 |
<code_here>
|
| 49 |
```
|
| 50 |
"""
|
| 51 |
+
|
| 52 |
+
response = client.chat_completion(
|
| 53 |
+
messages=[
|
| 54 |
+
{"role": "system", "content": "You are a helpful software architecture assistant."},
|
| 55 |
+
{"role": "user", "content": prompt}
|
| 56 |
+
]
|
| 57 |
+
)
|
| 58 |
+
return response.choices[0].message.content if response and response.choices else "❌ Error: No response received."
|
| 59 |
|
| 60 |
# 🎨 Gradio UI
|
| 61 |
with gr.Blocks() as demo:
|
|
|
|
| 109 |
show_progress=True
|
| 110 |
)
|
| 111 |
|
| 112 |
+
demo.launch()
|