Bofandra commited on
Commit
0f32032
·
verified ·
1 Parent(s): 6f8e6ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
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(model="deepseek-ai/DeepSeek-R1-0528", token=os.getenv("HF_TOKEN"))
 
 
 
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.text_generation(
55
- prompt,
56
- max_new_tokens=2048,
57
- temperature=0.7,
58
- top_p=0.9,
59
- repetition_penalty=1.1,
60
- do_sample=True,
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