File size: 897 Bytes
21a5794
 
a03d3c7
 
 
 
 
 
21a5794
 
 
a03d3c7
 
 
21a5794
 
 
 
 
 
 
 
 
a03d3c7
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
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()