camparchimedes commited on
Commit
0c02838
·
verified ·
1 Parent(s): 2956d3e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -21,7 +21,7 @@ import chainlit as cl
21
  from dotenv import load_dotenv
22
 
23
  from langchain_community.tools.requests.tool import RequestsPostTool
24
- #from langchain_community.utilities.requests import TextRequestsWrapper
25
  from langchain_community.utilities.requests import JsonRequestsWrapper
26
 
27
 
@@ -122,7 +122,7 @@ def setup_multiple_chains():
122
 
123
  cl.user_session.set("api_chain", api_chain)
124
 
125
- requests_wrapper = JsonRequestsWrapper( # TextRequestsWrapper
126
  headers={
127
  "Authorization": f"Bearer <auth_token>",
128
  "Content-Type": "application/json"
@@ -164,9 +164,13 @@ async def handle_message(message: cl.Message):
164
  config={"callbacks": [cl.AsyncLangchainCallbackHandler()]}
165
  )
166
 
 
 
 
 
167
  if response:
168
  try:
169
- booking_info = json.loads(response)
170
  table = "| Field | Information |\n|---|---|\n"
171
 
172
  fields_mapping = [
 
21
  from dotenv import load_dotenv
22
 
23
  from langchain_community.tools.requests.tool import RequestsPostTool
24
+ from langchain_community.utilities.requests import TextRequestsWrapper
25
  from langchain_community.utilities.requests import JsonRequestsWrapper
26
 
27
 
 
122
 
123
  cl.user_session.set("api_chain", api_chain)
124
 
125
+ requests_wrapper = TextRequestsWrapper(
126
  headers={
127
  "Authorization": f"Bearer <auth_token>",
128
  "Content-Type": "application/json"
 
164
  config={"callbacks": [cl.AsyncLangchainCallbackHandler()]}
165
  )
166
 
167
+ ## PS:
168
+ #json.dumps(post_data) converts a Python dictionary (post_data) into a JSON string.
169
+ #json.loads(post_data_str) takes a JSON string and converts it back into a Python dictionary.
170
+
171
  if response:
172
  try:
173
+ booking_info = response
174
  table = "| Field | Information |\n|---|---|\n"
175
 
176
  fields_mapping = [