hhhhhhhhhhhhhhh / app.py
karrrr123456's picture
Update app.py
d2357b4 verified
import gradio as gr
from huggingface_hub import InferenceClient
# Inference Client for Llama 3.2
client = InferenceClient("karrrr123456/aaaaaaaa")
def respond(
message,
history: list[tuple[str, str]],
system_message="You are a friendly AI assistant called ACE assisant made by ace.",
max_tokens=512,
temperature=0.7,
top_p=0.95,
):
messages = [{"role": "system", "content": system_message}]
for val in history:
if val[0]:
messages.append({"role": "user", "content": val[0]})
if val[1]:
messages.append({"role": "assistant", "content": val[1]})
messages.append({"role": "user", "content": message})
response = ""
for message in client.chat_completion(
messages,
max_tokens=max_tokens,
stream=True,
temperature=temperature,
top_p=top_p,
):
token = message.choices[0].delta.content
response += token
yield response
# Minimalistic, Sleek Chatbot UI
with gr.Blocks(theme="soft") as demo:
gr.Markdown("""
#
""")
chatbot = gr.ChatInterface(respond)
if __name__ == "__main__":
demo.launch()