kenken999 commited on
Commit
202535f
1 Parent(s): c62714c
chat_history.db CHANGED
Binary files a/chat_history.db and b/chat_history.db differ
 
controllers/gpt_enginner20240619110826 ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 3f7da4e51cdf331ec62ffba464e52760f2197b35
controllers/gra_02_openInterpreter/OpenInterpreter.py CHANGED
@@ -130,6 +130,33 @@ def chat_with_interpreter(message, history=None, a=None, b=None, c=None, d=None)
130
  yield full_response
131
  return full_response, history
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
  # 初期化
134
  initialize_db()
135
 
 
130
  yield full_response
131
  return full_response, history
132
 
133
+
134
+ def chat_with_interpreter_no_stream(message, history=None, a=None, b=None, c=None, d=None):
135
+ if message == "reset":
136
+ interpreter.reset()
137
+ return "Interpreter reset", history
138
+
139
+ full_response = ""
140
+ recent_messages = get_recent_messages()
141
+
142
+ for role, message_type, content in recent_messages:
143
+ entry = {"role": role, "type": message_type, "content": content}
144
+ interpreter.messages.append(entry)
145
+
146
+ user_entry = {"role": "user", "type": "message", "content": message}
147
+ interpreter.messages.append(user_entry)
148
+ add_message_to_db("user", "message", message)
149
+
150
+ full_response = interpreter.chat(message, display=False, stream=False):
151
+
152
+ assistant_entry = {"role": "assistant", "type": "message", "content": full_response}
153
+ interpreter.messages.append(assistant_entry)
154
+ add_message_to_db("assistant", "message", full_response)
155
+
156
+ #yield full_response
157
+ return full_response, history
158
+
159
+
160
  # 初期化
161
  initialize_db()
162
 
mysite/routers/fastapi.py CHANGED
@@ -14,7 +14,7 @@ from controllers.gra_04_database.rides import test_set_lide
14
  from mysite.interpreter.prompt import prompt_genalate,test_prompt
15
  from mysite.interpreter.google_chat import send_google_chat_card
16
  #from mysite.interpreter.interpreter import chat_with_interpreter
17
- from controllers.gra_02_openInterpreter.OpenInterpreter import chat_with_interpreter
18
  from mysite.appsheet.appsheet import get_senario
19
 
20
  logger = logging.getLogger(__name__)
@@ -205,7 +205,7 @@ def setup_webhook_routes(app: FastAPI):
205
  """
206
  res_no_process = no_process_file(prompt_for_create_system+res, "gpt_enginner"+ yyyymmddhis)
207
 
208
- full_response,history = chat_with_interpreter(res)
209
  send_google_chat_card(webhook_url, f"自動設定開始 {res}", str(full_response), link_text, link_url)
210
 
211
 
 
14
  from mysite.interpreter.prompt import prompt_genalate,test_prompt
15
  from mysite.interpreter.google_chat import send_google_chat_card
16
  #from mysite.interpreter.interpreter import chat_with_interpreter
17
+ from controllers.gra_02_openInterpreter.OpenInterpreter import chat_with_interpreter_no_stream
18
  from mysite.appsheet.appsheet import get_senario
19
 
20
  logger = logging.getLogger(__name__)
 
205
  """
206
  res_no_process = no_process_file(prompt_for_create_system+res, "gpt_enginner"+ yyyymmddhis)
207
 
208
+ full_response,history = chat_with_interpreter_no_stream(res)
209
  send_google_chat_card(webhook_url, f"自動設定開始 {res}", str(full_response), link_text, link_url)
210
 
211