File size: 1,921 Bytes
64aee40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
from agents.gather_agent import Gather_Agent
from agents.check_agent import Check_Agent
from agents.response_agent import Response_Agent
from agents.planner_agent import Planner_Agent

gather_agent = Gather_Agent()
check_agent = Check_Agent()
response_agent = Response_Agent()
planner_agent = Planner_Agent()

isComplete = False
chat_history = ""

helper_anwser = "Hello, can you tell me your trip details and constraints so I can give you great recomendations?"
user_input = input("Helper: " + helper_anwser + "\nUser: ")

def send_message(user_input, chat_history):
    isComplete = False
    helper_anwser = ""

    _input_gather = gather_agent.format_prompt(input=user_input, history=chat_history)
    parsed_result_gather = gather_agent.get_parsed_result(_input_gather)

    _input_check = check_agent.format_prompt(input=parsed_result_gather)
    isComplete = check_agent.get_parsed_result(_input_check)

    if isComplete == False:
        _input_response = response_agent.format_prompt(input=parsed_result_gather)
        helper_anwser = response_agent.get_parsed_result(_input_response)

    return isComplete, helper_anwser, parsed_result_gather

def get_itenerary(parsed_result_gather):
    _input_planner = planner_agent.format_prompt(parsed_result_gather)
    return planner_agent.get_itenerary(_input_planner)

    

while isComplete == False:
    isComplete, helper_anwser, parsed_result_gather = send_message(user_input, chat_history)

    if isComplete == False:
        chat_history += "User: " + user_input + "\nHelper: " + helper_anwser + "\n"
        user_input = input("Helper: " + helper_anwser + "\nUser: ")
        

print(parsed_result_gather)
print(get_itenerary(parsed_result_gather))

_input_places = planner_agent.format_instructions_places(parsed_result_gather)
parsed_result_places = planner_agent.get_places_from_itenerary(_input_places)
print(planner_agent.get_itenerary(_input_planner))