import os import gradio as gr from model import AssistantModel def get_answer(api_key: str, deployment: str, endpoint: str, tavily_key: str, question: str) -> str: os.environ['TAVILY_API_KEY'] = tavily_key model = AssistantModel(api_key, deployment, endpoint) answer = model.ask_question(question, '') return answer inputs = [ gr.Textbox(label='Azure API key', show_label=True, type='password', key=1), gr.Textbox(label='Azure Deployment', info='(i.e. my-gpt-4o)', show_label=True, key=2), gr.Textbox(label='Azure Endpoint', info='(i.e. https://my.openai.azure.com)', show_label=True, key=3), gr.Textbox(label='Tavily API key', info='search engine: https://www.tavily.com/', show_label=True, type='password', key=4), gr.Textbox(label='Question', lines=5, show_label=True) ] demo = gr.Interface(fn=get_answer, inputs=inputs, outputs="text") demo.launch()