chatBotGenAi / app.py
Usernotfound39347's picture
Update app.py
b961122 verified
Raw
History Blame Contribute Delete
598 Bytes
import os
from huggingface_hub import
InferenceClient
client = InferenceClient(
model="Qwen/Qwen2.5-7B-Instruct",
token=os.getenv("HF_TOKEN")
)
def respond(message, history):
messages = [{"role": "system", "content": "you are a friendly chatbot"}]
if history:
messages.extend(history)
message.append({"role":"user", "content": message})
response = client.chat_completion (
messages,
max_tokens=100
)
return random.choices[0].messages.content.strip()
chatbot = gr.ChatInerfae(respond)
chatbot.launh()