File size: 929 Bytes
4eefee7
3150159
6d4a95f
4eefee7
6d4a95f
4eefee7
3150159
1f198de
6d4a95f
 
 
 
f495c42
 
 
 
 
 
c089e2c
 
1f198de
 
 
 
6d4a95f
cb0713f
4eefee7
 
1f43b12
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import gradio as gr
import random
from huggingface_hub import InferenceClient 

client = InferenceClient("Qwen/Qwen2.5-7B-Instruct")

def respond(message, history):
    messages = [{"role": "system", "content": "You are a travel advisor helping plan a trip to Morocco. Give a week long itinerary. Focus on activities, not food."}]
    if history:
        messages.extend(history)
    messages.append({"role": "user", "content": message})

    # response = client.chat_completion(
    #     messages,
    #     max_tokens=100,
    #     temperature = 1.5,
    #     top_p = 0.34
    # )
    response = ""
    for msg in client.chat_completion(messages, stream=True):
        token = msg.choices[0].delta.content
        if token is not None:
            response += token
            yield response #response.choices[0].message.content.strip()
    
chatbot = gr.ChatInterface(respond, title="my bot")


chatbot.launch(debug=True)