Bofandra commited on
Commit
31d5e67
·
verified ·
1 Parent(s): 0017bdf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
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
- # 🔄 Get text response
52
- response = client.text_generation(prompt=prompt)
53
- return response if response else "❌ Error: No response received."
 
 
 
 
 
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()