Spaces:
Sleeping
Sleeping
Change in Code... (hopefully it works)
Browse files
app.py
CHANGED
|
@@ -1,22 +1,24 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
from huggingface_hub import InferenceClient
|
| 3 |
|
| 4 |
-
client = InferenceClient
|
| 5 |
-
|
| 6 |
-
def respond(message, history):
|
| 7 |
-
messages = [{"role": "system", "content": "You are a friendly chatbot."}]
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 9 |
if history:
|
| 10 |
messages.extend(history)
|
| 11 |
-
|
| 12 |
-
messages.append({"role":"user","content":message})
|
| 13 |
|
| 14 |
response = client.chat_completion(
|
| 15 |
-
messages,
|
| 16 |
-
max_tokens=
|
| 17 |
)
|
| 18 |
return response.choices[0].message.content.strip()
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
chatbot = gr.ChatInterface(
|
| 21 |
-
chatbot.launch()
|
| 22 |
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import random
|
| 3 |
from huggingface_hub import InferenceClient
|
| 4 |
|
| 5 |
+
client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
def random_response(message, history):
|
| 8 |
+
messages = [{"role":"system", "content" : "You are an exceptionally unique and kind chatbot."}]
|
| 9 |
+
|
| 10 |
if history:
|
| 11 |
messages.extend(history)
|
| 12 |
+
messages.append({"role":"user", "content":message})
|
|
|
|
| 13 |
|
| 14 |
response = client.chat_completion(
|
| 15 |
+
messages,
|
| 16 |
+
max_tokens = 1000
|
| 17 |
)
|
| 18 |
return response.choices[0].message.content.strip()
|
| 19 |
+
#response_options = ["nope", "yeah", "no", "yes", "absolutely not", "absolutely"]
|
| 20 |
+
return random.choice(response_options)
|
| 21 |
|
| 22 |
+
chatbot = gr.ChatInterface(random_response, title = "Vanshika's First Chatbot")
|
|
|
|
| 23 |
|
| 24 |
+
chatbot.launch()
|