wangzhang's picture
Update app.py
949d71e
raw
history blame
979 Bytes
import gradio as gr
from huggingface_hub import InferenceClient
from googletrans import Translator
client = InferenceClient(model="https://pl0u0mrj2ag4o0-80.proxy.runpod.net")
translator = Translator()
def inference(message, history):
# Translate to English
message = translator.translate(message, dest="en").text
partial_message = ""
for token in client.text_generation(message, max_new_tokens=1024, stream=True):
partial_message += token
yield partial_message
gr.ChatInterface(
inference,
chatbot=gr.Chatbot(height=300),
textbox=gr.Textbox(placeholder="Please ask your question here...", container=False, scale=7),
description="This is a chatbot trained on the Llama2-7b model.",
title="SequoiaDB AI",
examples=["What is SequioaDB?", "What is SequioaDB's license?", "What is SequioaDB's official website?"],
retry_btn="Retry",
undo_btn="Undo",
clear_btn="Clear",
submit_btn="Submit",
).queue().launch()