assistants-api / app.py
umer70112254's picture
Update app.py
e329f2e
raw
history blame contribute delete
976 Bytes
import gradio as gr
import random
from llm.openai import Llm
# # mock for testing
# from llm.mock import Llm
llm = Llm()
def assistant_response(prompt):
answer = llm.chatcompletion(prompt)
return answer
def respond(message, chat_history):
answer = llm.chatcompletion(message)
print(answer)
chat_history.append((message, answer))
return "", chat_history
title = "OpenAPI Assistant API: " + llm.assistant.name
if llm.assistant.description is None:
model = llm.assistant.model
description = f"This demo is OpenAPI Assistant API . When you enter text in the text box,{model} The model responds."
else:
description = llm.assistant.description
with gr.Blocks() as demo:
gr.Markdown(
f"""
# {title}
{description}
""")
chatbot = gr.Chatbot()
msg = gr.Textbox()
clear = gr.ClearButton([msg, chatbot])
msg.submit(respond, [msg, chatbot], [msg, chatbot])
if __name__ == "__main__":
demo.launch()