Commit ·
f317fef
1
Parent(s): 4ac290a
Update for Browser Storage
Browse files
app.py
CHANGED
|
@@ -89,7 +89,7 @@ def submit_signup(_email: str, _name: str, _contact: str):
|
|
| 89 |
def call_travel_ai(
|
| 90 |
message: str,
|
| 91 |
history: Sequence[Tuple[str, str]],
|
| 92 |
-
|
| 93 |
endpoint: str = ENDPOINT,
|
| 94 |
output_type: str = "chat",
|
| 95 |
input_type: str = "chat",
|
|
@@ -108,7 +108,7 @@ def call_travel_ai(
|
|
| 108 |
api_url = f"{BASE_API_URL}/lf/{LANGFLOW_ID}/api/v1/run/{endpoint}"
|
| 109 |
|
| 110 |
payload = {
|
| 111 |
-
'session_id':
|
| 112 |
"input_value": message,
|
| 113 |
"output_type": output_type,
|
| 114 |
"input_type": input_type,
|
|
@@ -129,10 +129,14 @@ def call_travel_ai(
|
|
| 129 |
)
|
| 130 |
response = response.json()
|
| 131 |
resp_message = ''
|
| 132 |
-
|
| 133 |
-
for
|
| 134 |
-
for
|
| 135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
return resp_message
|
| 138 |
|
|
@@ -195,7 +199,6 @@ with gr.Blocks() as demo:
|
|
| 195 |
local_storage: str
|
| 196 |
):
|
| 197 |
"""Update the visibility of the sign up and chat interfaces."""
|
| 198 |
-
print(local_storage)
|
| 199 |
# session_id, signed_up = local_storage
|
| 200 |
local_storage[0] = local_storage[0] or generate_session_id()
|
| 201 |
_status = submit_signup(_email, _name, _phone)
|
|
|
|
| 89 |
def call_travel_ai(
|
| 90 |
message: str,
|
| 91 |
history: Sequence[Tuple[str, str]],
|
| 92 |
+
local_storage: str,
|
| 93 |
endpoint: str = ENDPOINT,
|
| 94 |
output_type: str = "chat",
|
| 95 |
input_type: str = "chat",
|
|
|
|
| 108 |
api_url = f"{BASE_API_URL}/lf/{LANGFLOW_ID}/api/v1/run/{endpoint}"
|
| 109 |
|
| 110 |
payload = {
|
| 111 |
+
'session_id': local_storage[0],
|
| 112 |
"input_value": message,
|
| 113 |
"output_type": output_type,
|
| 114 |
"input_type": input_type,
|
|
|
|
| 129 |
)
|
| 130 |
response = response.json()
|
| 131 |
resp_message = ''
|
| 132 |
+
try:
|
| 133 |
+
for resp in response['outputs']:
|
| 134 |
+
for _resp in resp['outputs']:
|
| 135 |
+
for message in _resp['messages']:
|
| 136 |
+
resp_message = message['message']
|
| 137 |
+
except KeyError as e:
|
| 138 |
+
print(e)
|
| 139 |
+
print(response)
|
| 140 |
|
| 141 |
return resp_message
|
| 142 |
|
|
|
|
| 199 |
local_storage: str
|
| 200 |
):
|
| 201 |
"""Update the visibility of the sign up and chat interfaces."""
|
|
|
|
| 202 |
# session_id, signed_up = local_storage
|
| 203 |
local_storage[0] = local_storage[0] or generate_session_id()
|
| 204 |
_status = submit_signup(_email, _name, _phone)
|