File size: 1,403 Bytes
3060e5b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
af6d9c2
 
3060e5b
 
 
 
 
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
45
import gradio as gr


from llm.qa_agent import QnAAgent
from llm.calculator_agent import CalculatorAgent
from llm.orchestrator import Orchestrator



if __name__ == "__main__":
    orchestrator = Orchestrator()
    qna_agent = QnAAgent()
    calculator_agent = CalculatorAgent()

    # question = input("Question - ")
    def get_answer(question:str) -> [str, str]:
        
        api_name, parameters = orchestrator.get_API_call(question)

        print(f"Using the {api_name} Agent")
        print(api_name, parameters)
        if api_name == "QnA":
            answer, wiki_page = qna_agent.get_answer(parameters)

    # elif api_name == "calculator":
    #     operand, op1, op2 = parameters.split(",")
    #     answer = calculator_agent.calculate(operand, op1, op2)

        print(answer)   
        return [answer, wiki_page]
    
    demo = gr.Interface(
        fn=get_answer,
        inputs=gr.Textbox(placeholder="Enter your question...[Who won the Cricket World Cup in 2023?]")
,
        # outputs=[gr.Textbox(label=f'Document {i+1}') for i in range(TOP_K)],
        outputs=[gr.Textbox(label="Answer"), gr.Textbox(label="Wikipedia Page")],
        title="Current Event Question Answering using near-real-time data",
        description="Ask questions about current events beyond the LLM's knowledge cutoff. Ex: Who is the current Prime Minister of France?"
    )

    demo.launch()