geqintan commited on
Commit
d859f7d
·
1 Parent(s): ba018db
Files changed (1) hide show
  1. redis_service.py +20 -15
redis_service.py CHANGED
@@ -98,14 +98,16 @@ async def redis_subscriber(redis_client, channel_name):
98
  "streaming": False
99
  }
100
  response1 = requests.post("https://tanbushi-adk-teams.hf.space/run", json=data)
101
- parts=response1.json()[0]['content']['parts']
102
- ret_text=''
103
- for part in parts:
104
- # if part['type']=='text':
105
- ret_text=ret_text+part['text']
106
- # break
107
- # ret_text = response1.json()[0]['content']['parts'][0]['text']
108
- print(ret_text)
 
 
109
  else:
110
  print("Successfully get session")
111
  data = {
@@ -123,13 +125,16 @@ async def redis_subscriber(redis_client, channel_name):
123
  "streaming": False
124
  }
125
  response1 = requests.post("https://tanbushi-adk-teams.hf.space/run", json=data)
126
- ret_text = response1.json()[0]['content']['parts'][0]['text']
127
- print(ret_text)
128
-
129
-
130
-
131
-
132
- content = {"text": ret_text}
 
 
 
133
  # Correctly extract msg_type from the original_msg_type field
134
  msg_type = data_dict.get('original_msg_type')
135
 
 
98
  "streaming": False
99
  }
100
  response1 = requests.post("https://tanbushi-adk-teams.hf.space/run", json=data)
101
+ response1_json=response1.json()
102
+ print('\n\n\n\n\n\n\n\nresponse1_json: ',response1_json)
103
+ # 引用自检索结果[6]
104
+ if response1_json[0]["content"]["parts"][0].get("function_call"):
105
+ function_call = response1_json[0]["content"]["parts"][0]["function_call"]
106
+ print(f"函数调用: {function_call['name']}")
107
+ else:
108
+ text_content = "".join([part["text"] for part in response1_json[0]["content"]["parts"]])
109
+ print(text_content)
110
+
111
  else:
112
  print("Successfully get session")
113
  data = {
 
125
  "streaming": False
126
  }
127
  response1 = requests.post("https://tanbushi-adk-teams.hf.space/run", json=data)
128
+ response1_json=response1.json()
129
+ print('\n\n\n\n\n\n\n\nresponse1_json: ', response1_json)
130
+ if response1_json[0]["content"]["parts"][0].get("function_call"):
131
+ function_call = response1_json[0]["content"]["parts"][0]["function_call"]
132
+ print(f"函数调用: {function_call['name']}")
133
+ else:
134
+ text_content = "".join([part["text"] for part in response1_json[0]["content"]["parts"]])
135
+ print(text_content)
136
+
137
+ content = {"text": text_content}
138
  # Correctly extract msg_type from the original_msg_type field
139
  msg_type = data_dict.get('original_msg_type')
140