File size: 461 Bytes
30af771
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def run(query):
    from langchain.callbacks import get_openai_callback
    
    with get_openai_callback() as cb:
        response = (agent.run(query))
        costs = (f"Total Cost (USD): ${cb.total_cost}")
        output = f'{response} \n {costs}'
        return output
    
def respond(message, chat_history):
    import time
    
    bot_message = run(message)
    chat_history.append((message, bot_message))
    time.sleep(0.5)
    return "", chat_history