Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
from huggingface_hub import InferenceClient
|
| 3 |
-
|
| 4 |
-
client = InferenceClient("HuggingFaceH4/zephyr-7b-beta") #change LLM
|
| 5 |
-
|
| 6 |
-
def respond(message, history):
|
| 7 |
-
messages = [{"role": "system", "content": "You are a chatbot that is assisting teenagers in preparing for job interviews."}]
|
| 8 |
-
if history:
|
| 9 |
-
messages.extend(history)
|
| 10 |
-
messages.append({"role": "user", "content": message})
|
| 11 |
-
|
| 12 |
-
response = ""
|
| 13 |
-
for message in client.chat_completion(
|
| 14 |
-
messages,
|
| 15 |
-
max_tokens=100,
|
| 16 |
-
stream=True,
|
| 17 |
-
):
|
| 18 |
-
token = message.choices[0].delta.content
|
| 19 |
-
response += token
|
| 20 |
-
yield response
|
| 21 |
-
|
| 22 |
-
chatbot = gr.ChatInterface(respond, type="messages")
|
| 23 |
-
chatbot.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|