Bloom_Bot / app.py
clarissah's picture
Update app.py
25fb233 verified
raw
history blame
816 Bytes
import gradio as gr
from huggingface_hub import InferenceClient
with open("knowledge.txt" , "r", encoding="utf-8") as f:
knowledge_base.txt = f.read()
client = InterferenceClient("google/gemma-3-27b-it")
def respond(message,history):
messages = [{"role": "system" , "content" : "You're a supportive and helpful feminist"}]
if history:
messages.extend(history)
messages.append({"role" : "user", "content" : message})
response = ""
for message in client.chat_completion(
messages,
max_tokens = 150,
stream=True,
):
token = message.choices[0].delta.content
response += token
yield response
print(response)
chatbot = gr.ChatInterface(respond, type = "messages")
chatbot.launch(debug=True)