kenken999 commited on
Commit
8bdac48
1 Parent(s): 69c58ee
Files changed (1) hide show
  1. mysite/routers/fastapi.py +23 -10
mysite/routers/fastapi.py CHANGED
@@ -319,18 +319,31 @@ def setup_webhook_routes(app: FastAPI):
319
  from babyagi.babyagi import completion
320
  #import tempfile
321
  text = text.replace("\r\n","")
 
322
  command = f"""make runbabyagi "{text}に対して、より良いチャットボットでのQAプランデータ設定の提案を日本語で作成してください"""
323
-
324
- proc = subprocess.Popen(
325
- command,
326
- stdin=subprocess.PIPE,
327
- stdout=subprocess.PIPE,
328
- stderr=subprocess.PIPE,
329
- text=True,
330
- shel=True
 
331
  )
332
- stdout, stderr = proc.communicate()
333
- thread_name = send_google_chat_card_thread(webhook_url, title, stdout, link_text, link_url,thread_name)
 
 
 
 
 
 
 
 
 
 
 
334
 
335
  #prompt_res_agi = completion("日本語で下記のプランを考えて "+res)
336
  #thread_name = send_google_chat_card_thread(webhook_url, title, prompt_res_agi, link_text, link_url,thread_name)
 
319
  from babyagi.babyagi import completion
320
  #import tempfile
321
  text = text.replace("\r\n","")
322
+ # コマンドを構築
323
  command = f"""make runbabyagi "{text}に対して、より良いチャットボットでのQAプランデータ設定の提案を日本語で作成してください"""
324
+
325
+ try:
326
+ proc = subprocess.Popen(
327
+ command,
328
+ stdin=subprocess.PIPE,
329
+ stdout=subprocess.PIPE,
330
+ stderr=subprocess.PIPE,
331
+ text=True,
332
+ shell=True
333
  )
334
+ stdout, stderr = proc.communicate()
335
+
336
+ if proc.returncode != 0:
337
+ print(f"Command failed with return code {proc.returncode}")
338
+ print(f"Error output: {stderr}")
339
+ return None
340
+
341
+ thread_name = send_google_chat_card_thread(webhook_url, title, stdout, link_text, link_url, thread_name)
342
+ return thread_name
343
+
344
+ except Exception as e:
345
+ print(f"An error occurred: {e}")
346
+ return None
347
 
348
  #prompt_res_agi = completion("日本語で下記のプランを考えて "+res)
349
  #thread_name = send_google_chat_card_thread(webhook_url, title, prompt_res_agi, link_text, link_url,thread_name)