Spaces:
Runtime error
Runtime error
File size: 1,027 Bytes
db3f703 0e519fe db3f703 0e519fe db3f703 0e519fe db3f703 0e519fe db3f703 c9a66e4 0e519fe c9a66e4 0e519fe db3f703 0e519fe db3f703 0e519fe |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
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"このデモはOpenAPI Assistant APIのデモです。テキストボックスにテキストを入力すると、{model}モデルが応答します。"
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()
|