File size: 583 Bytes
bb9ca0c
6844f3e
bb9ca0c
6844f3e
b59e2e5
cec24d0
ba6ab46
bb9ca0c
 
 
 
c622cee
bb9ca0c
 
c622cee
bb9ca0c
 
 
b59e2e5
 
c0b7af0
b59e2e5
2417efc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from huggingface_hub import InferenceClient

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

def random_response(message,history):
    messages= [{"role": "system", "content": "You are a friendly chatbot."}]

    if history:
        messages.extend(history)

    message.append({"role":"user", "content": messages})
    
    response = client.chat_completion(
        message,
        max_tokens=100
    )
    return response.choices[0].message.content.strip()


chatbot = gr.ChatInterface(random_response, title = "Magic 8 Ball Chatbot")

chatbot.launch()