Update app.py
Browse files
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from text_generation import InferenceAPIClient
|
| 3 |
import os
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
# ✅
|
| 6 |
-
|
| 7 |
-
client = InferenceAPIClient("bigscience/bloomz")
|
| 8 |
|
| 9 |
# 🧠 Function to generate software architecture
|
| 10 |
def generate_software_spec(name, description, architecture, components, deployment, platform, extra):
|
|
@@ -49,17 +48,16 @@ Return the result in this format:
|
|
| 49 |
```
|
| 50 |
"""
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
#return result
|
| 63 |
|
| 64 |
# 🎨 Gradio UI
|
| 65 |
with gr.Blocks() as demo:
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
# ✅ Set up Hugging Face client with token from environment
|
| 6 |
+
llm = InferenceClient(token=os.getenv("HF_TOKEN"))
|
|
|
|
| 7 |
|
| 8 |
# 🧠 Function to generate software architecture
|
| 9 |
def generate_software_spec(name, description, architecture, components, deployment, platform, extra):
|
|
|
|
| 48 |
```
|
| 49 |
"""
|
| 50 |
|
| 51 |
+
# Generate response from Hugging Face Inference Client
|
| 52 |
+
response = llm.chat_completion(
|
| 53 |
+
messages=[
|
| 54 |
+
{"role": "system", "content": "You are a helpful software architecture assistant."},
|
| 55 |
+
{"role": "user", "content": prompt}
|
| 56 |
+
],
|
| 57 |
+
model="deepseek-ai/DeepSeek-R1-0528",
|
| 58 |
+
max_tokens=2048,
|
| 59 |
+
)
|
| 60 |
+
return response.choices[0].message["content"] if response and response.choices else "Error: No response received."
|
|
|
|
| 61 |
|
| 62 |
# 🎨 Gradio UI
|
| 63 |
with gr.Blocks() as demo:
|