Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
# connecting to the model so my chatbot can generate real responses
|
| 5 |
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
|
| 6 |
|
| 7 |
def respond(message, history):
|
|
@@ -15,21 +15,15 @@ def respond(message, history):
|
|
| 15 |
"Keep responses under 100 words. "
|
| 16 |
"Be specific, clear, and briefly explain why each recommendation fits."
|
| 17 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
}
|
| 19 |
]
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
#
|
| 23 |
-
if history:
|
| 24 |
-
for user_msg, bot_msg in history:
|
| 25 |
-
messages.append({"role": "user", "content": user_msg})
|
| 26 |
-
messages.append({"role": "assistant", "content": bot_msg})
|
| 27 |
-
|
| 28 |
-
# adding the newest message from the user
|
| 29 |
-
messages.append({"role": "user", "content": message})
|
| 30 |
-
|
| 31 |
-
# i chose 0.7 because it gives a balance between creative and focused answers
|
| 32 |
-
# i used 150 max tokens so the response is long enough but still not too wordy
|
| 33 |
response = client.chat_completion(
|
| 34 |
messages=messages,
|
| 35 |
max_tokens=150,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
+
# connecting to the model so my chatbot can generate real AI responses
|
| 5 |
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
|
| 6 |
|
| 7 |
def respond(message, history):
|
|
|
|
| 15 |
"Keep responses under 100 words. "
|
| 16 |
"Be specific, clear, and briefly explain why each recommendation fits."
|
| 17 |
)
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"role": "user",
|
| 21 |
+
"content": message
|
| 22 |
}
|
| 23 |
]
|
| 24 |
|
| 25 |
+
# i chose 0.7 because it balances creative and focused answers
|
| 26 |
+
# i used 150 max tokens so responses do not get cut off but also stay concise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
response = client.chat_completion(
|
| 28 |
messages=messages,
|
| 29 |
max_tokens=150,
|