Files
tello-commander/brain/service_gradio_nicetry_1.py

37 lines
1.1 KiB
Python

import gradio as gr
import requests
conversation = []
def generate_response(prompt, params):
#response = requests.get(f"http://localhost:8000/command/{prompt}").json()
response = f"I got {prompt}"
conversation.append({"prompt": prompt, "response": response})
print(params)
#params["conversation_history"].description = f"Conversation History:\n\n{populate_chat_history(conversation)}"
return f"I got: {prompt}"
def populate_chat_history(conversation):
history = ""
for i, chat in enumerate(conversation):
history += f"User: {chat['prompt']}\nBot: {chat['response']}\n\n"
return history
iface = gr.Interface(
fn=generate_response,
inputs=["text"],
outputs=["text"],
parameters=[
{
"type": "textbox",
"key": "conversation_history",
"label": "Conversation:",
"default": ""
}
],
title="fly my drone by talking",
description="what should I do now?\n(enter q for emergency)"
)
iface.launch(server_name="0.0.0.0", server_port=8890, debug=True)