Spaces:
Sleeping
Sleeping
changed the LLM
Browse files
app.py
CHANGED
|
@@ -2,18 +2,23 @@ import gradio as gr
|
|
| 2 |
import random
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
-
client = InferenceClient("
|
|
|
|
| 6 |
|
| 7 |
def respond(message, history):
|
| 8 |
|
| 9 |
-
messages = [{"role": "system", "content": "You are a friendly chatbot."}
|
|
|
|
| 10 |
if history:
|
| 11 |
messages.extend(history)
|
| 12 |
|
| 13 |
messages.append({"role": "user", "content" : message})
|
| 14 |
|
| 15 |
-
response = client.chat_completion(messages, max_tokens = 100
|
|
|
|
|
|
|
| 16 |
|
|
|
|
| 17 |
print(response ["choices"][0]["message"]["content"].strip())
|
| 18 |
|
| 19 |
return response ['choices'][0]['message']['content'].strip()
|
|
@@ -26,4 +31,4 @@ def echo(message, history):
|
|
| 26 |
|
| 27 |
chatbot = gr.ChatInterface(respond, type = "messages", theme = "shivi/calm_seafoam")
|
| 28 |
|
| 29 |
-
chatbot.launch()
|
|
|
|
| 2 |
import random
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
client = InferenceClient("deepseek-ai/DeepSeek-R1-Distill-Qwen-32B")
|
| 6 |
+
# To change the LLM ^
|
| 7 |
|
| 8 |
def respond(message, history):
|
| 9 |
|
| 10 |
+
messages = [{"role": "system", "content": "You are a friendly chatbot."} # <to change the personality
|
| 11 |
+
]
|
| 12 |
if history:
|
| 13 |
messages.extend(history)
|
| 14 |
|
| 15 |
messages.append({"role": "user", "content" : message})
|
| 16 |
|
| 17 |
+
response = client.chat_completion(messages, max_tokens = 100
|
| 18 |
+
# to change the length
|
| 19 |
+
)
|
| 20 |
|
| 21 |
+
|
| 22 |
print(response ["choices"][0]["message"]["content"].strip())
|
| 23 |
|
| 24 |
return response ['choices'][0]['message']['content'].strip()
|
|
|
|
| 31 |
|
| 32 |
chatbot = gr.ChatInterface(respond, type = "messages", theme = "shivi/calm_seafoam")
|
| 33 |
|
| 34 |
+
chatbot.launch(debug=True)
|