kenken999 commited on
Commit
cf24326
·
1 Parent(s): 5c375a8
Files changed (1) hide show
  1. routers/webhook.py +0 -95
routers/webhook.py CHANGED
@@ -138,26 +138,8 @@ async def webhook(request: Request):
138
  }
139
  #/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f
140
  #d2d0af6e-5c42-45b6-a923-3bd2d8520e3d
141
- post_data("https://kenken999-nodex-n8n.hf.space/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f",text,thread_name,headers)
142
- #http://localhost:7860/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f
143
- post_data_line("https://kenken999-nodex-n8n.hf.space/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3d",body,headers)
144
- #http://localhost:7860/webhook/d2d0af6e-5c42-45b6-a923-3bd2d8520e3d
145
- post_data_line("https://kenken999-nodex-n8n.hf.space/webhook/d2d0af6e-5c42-45b6-a923-3bd2d8520e3d",body,headers)
146
- #post_data_line("https://kenken999-nodex-n8n.hf.space/webhook/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f",body,headers)
147
 
148
- #return
149
-
150
 
151
- post_data(n8nurl,text,thread_name,headers)
152
- time.sleep(10)
153
- #########################################################################
154
- title = f""" プロンプト作成 {promps}"""
155
- subtitle = f"""userid {user_id}\r\n chatid {thread_name}\r\n{prompt_res}"""
156
- link_text = "データを確認する"
157
- link_url = "https://kenken999-php.hf.space/diamondprice_list.php"
158
- #test_set_lide(subtitle, text)
159
- if DEBUG==1:
160
- thread_name = send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
161
 
162
  #thread_name = send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
163
  #return
@@ -165,83 +147,6 @@ async def webhook(request: Request):
165
  #########################################################################
166
  first_line = text.split('\n')[0]
167
  #test_prompt
168
- res = test_prompt("返信は必ず日本語でして下さい \r\n"+prompt_res,text)
169
-
170
- if DEBUG==1:
171
- thread_name = send_google_chat_card_thread(webhook_url, "プロンプトテスト "+first_line, str(res), link_text, link_url,thread_name)
172
-
173
- #thread_name = send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
174
- now = datetime.now()
175
- yyyymmddhis = now.strftime('%Y%m%d%H%M%S')
176
-
177
-
178
- #########################################################################
179
- ## excute create program
180
- if DEBUG==1:
181
- res_no_process = no_process_file(prompt_for_create_system+res, "gpt_enginner"+ yyyymmddhis,thread_name)
182
- # execute open interpreter
183
- #########################################################################
184
- if DEBUG==1:
185
- full_response,history = chat_with_interpreter_no_stream(prompt_for_create_system+"\r\n"+res)
186
- if DEBUG==1:
187
- thread_name = send_google_chat_card_thread(webhook_url, f"自動設定開始 {res}", str(full_response), link_text, link_url,thread_name)
188
- ####################################################################
189
- #ダイヤ金額計算
190
- from babyagi.classesa.diamond import calculate
191
- if DEBUG==1:
192
- title = f""" ダイヤ予測計算の実行 類似5件表示 {text}
193
- id,price,carat, cut, color, clarity, depth, diamondprice.table, x, y, z 類似度"""
194
- #ベクトルインデックス
195
- res_calculate = calculate(text)
196
- subtitle = res_calculate
197
- link_text = "データを確認する"
198
- link_url = "https://kenken999-php.hf.space/diamondprice_list.php"
199
- #########################################################################
200
- #test_set_lide(subtitle, text)
201
-
202
- #if DEBUG==0:
203
- thread_name = send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
204
- #########################################################################
205
- from babyagi.babyagi import completion
206
- #import tempfile
207
- text = text.replace("\r\n","")
208
- # コマンドを構築
209
- command = f"""make runbabyagi "{text}に対して、より良いチャットボットでのQAプランデータ設定の提案を日本語で作成してください" {thread_name}"""
210
- if DEBUG==1:
211
- with open('/home/user/app/babyagi/prompt.txt', 'w') as file:
212
- file.write(f"""{text}の質問 についてチャットボットでよりよく対応するプ��ンを日本語で作成して""")
213
-
214
- ######################################################################
215
- if DEBUG==1:
216
- proc = subprocess.Popen(
217
- ["make", "runbabyagi", thread_name],
218
- stdin=subprocess.PIPE,
219
- stdout=subprocess.PIPE,
220
- stderr=subprocess.PIPE,
221
- text=True,
222
- )
223
-
224
- logger.info("Received Headers: %s", received_headers)
225
- logger.info("Received Body: %s", body.decode("utf-8"))
226
- ###############################################################################
227
- #send to appsheet
228
- get_senario("user_id",str(body))
229
- #apps script send
230
- headers = {
231
- "Content-Type": "application/json",
232
- }
233
- logger.info("Received Body: %s", "send data to appsheet ")
234
- #response = requests.post(os.getenv("WEBHOOK_URL"), headers=headers, data=body)
235
- # check signature
236
- line_signature = received_headers.get("x-line-signature")
237
- logger.info("Received Body: %s", "start send messages ")
238
- #headers = {
239
- # "Content-Type": "application/json",
240
- # "X-Line-Signature": line_signature,
241
- # "Authorization": f"Bearer {os.getenv('ChannelAccessToken')}",
242
- # }
243
- #r#esponse = requests.post(os.getenv("WEBHOOK_URL"), headers=headers, data=body)
244
-
245
  if not line_signature:
246
  raise HTTPException(status_code=400, detail="X-Line-Signature header is missing.")
247
 
 
138
  }
139
  #/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f
140
  #d2d0af6e-5c42-45b6-a923-3bd2d8520e3d
 
 
 
 
 
 
141
 
 
 
142
 
 
 
 
 
 
 
 
 
 
 
143
 
144
  #thread_name = send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
145
  #return
 
147
  #########################################################################
148
  first_line = text.split('\n')[0]
149
  #test_prompt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  if not line_signature:
151
  raise HTTPException(status_code=400, detail="X-Line-Signature header is missing.")
152