Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,10 @@ import gradio as gr
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
# ✅ Set up Hugging Face client with token from environment
|
| 6 |
-
client = InferenceClient(
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# 🧠 Function to generate software architecture
|
| 9 |
def generate_software_spec(name, description, architecture, components, deployment, platform, extra):
|
|
@@ -51,14 +54,15 @@ def generate_software_spec(name, description, architecture, components, deployme
|
|
| 51 |
|
| 52 |
print(prompt)
|
| 53 |
# Generate response from Hugging Face Inference Client
|
| 54 |
-
response = client.
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
)
|
|
|
|
| 62 |
return response.choices[0].message["content"] if response and response.choices else "Error: No response received."
|
| 63 |
|
| 64 |
# 🎨 Gradio UI
|
|
|
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
# ✅ Set up Hugging Face client with token from environment
|
| 6 |
+
client = InferenceClient(
|
| 7 |
+
provider="auto",
|
| 8 |
+
api_key=os.environ["HF_TOKEN"],
|
| 9 |
+
)
|
| 10 |
|
| 11 |
# 🧠 Function to generate software architecture
|
| 12 |
def generate_software_spec(name, description, architecture, components, deployment, platform, extra):
|
|
|
|
| 54 |
|
| 55 |
print(prompt)
|
| 56 |
# Generate response from Hugging Face Inference Client
|
| 57 |
+
response = client.chat_completion(
|
| 58 |
+
messages=[
|
| 59 |
+
{"role": "system", "content": "You are a helpful software architecture assistant."},
|
| 60 |
+
{"role": "user", "content": prompt}
|
| 61 |
+
],
|
| 62 |
+
model="deepseek-ai/DeepSeek-R1-0528",
|
| 63 |
+
max_tokens=2048,
|
| 64 |
)
|
| 65 |
+
print(response)
|
| 66 |
return response.choices[0].message["content"] if response and response.choices else "Error: No response received."
|
| 67 |
|
| 68 |
# 🎨 Gradio UI
|