kenken999 commited on
Commit
5ad0419
·
1 Parent(s): 90a420e
controllers/gpt_enginner20240706063303 ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 84519cd758b3fb209789549c47433233cb0dbaff
controllers/gpt_enginner20240706064239 ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit b2ab1d65cc1b9610e5319c7cc374820bf08b79d3
controllers/gpt_enginner20240706064439 ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit 3ef7a2dfd43bd1bc9a24bf3b8d4d1c3e84be83ef
controllers/gpt_enginner20240706064718 ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit b831caf9d51113e4f802f67f4402439201405356
controllers/gpt_enginner20240706064852 ADDED
@@ -0,0 +1 @@
 
 
1
+ Subproject commit cf85ad3836b5171d43c05f5fc77a70cebd5503f9
mysite/interpreter/google_chat.py CHANGED
@@ -32,21 +32,21 @@ def send_google_chat_card(webhook_url, title, subtitle, link_text, link_url,imag
32
  "buttons": [
33
  {
34
  "textButton": {
35
- "text": "チャットボット設定シートを開く ",
36
  "onClick": {
37
  "openLink": {
38
- "url": link_url
39
  }
40
  }
41
  }
42
  }
43
  ]
44
- },
45
- {
46
  "buttons": [
47
  {
48
  "textButton": {
49
- "text": "ラインチャットを開く",
50
  "onClick": {
51
  "openLink": {
52
  "url": "https://chat.line.biz/U2df77fd63804c72346b4e50c0096572e/chat/Ua13ef47afc077917275658a44019e072"
@@ -55,21 +55,21 @@ def send_google_chat_card(webhook_url, title, subtitle, link_text, link_url,imag
55
  }
56
  }
57
  ]
58
- },
59
  {
60
  "buttons": [
61
  {
62
  "textButton": {
63
- "text": "データがヒットしない場合登録",
64
  "onClick": {
65
  "openLink": {
66
- "url": "https://kenken999-php.hf.space/zendesk__dataszz_list.php?qs=500%E5%86%86"
67
  }
68
  }
69
  }
70
  }
71
  ]
72
- },
73
  ]
74
  }
75
  ]
 
32
  "buttons": [
33
  {
34
  "textButton": {
35
+ "text": "ラインチャットを開く",
36
  "onClick": {
37
  "openLink": {
38
+ "url": "https://chat.line.biz/U2df77fd63804c72346b4e50c0096572e/chat/Ua13ef47afc077917275658a44019e072"
39
  }
40
  }
41
  }
42
  }
43
  ]
44
+ },
45
+ {
46
  "buttons": [
47
  {
48
  "textButton": {
49
+ "text": "LINEからチャットで[question]質問項目[answer]こたえ と登録すると答えるようになります(運用用)",
50
  "onClick": {
51
  "openLink": {
52
  "url": "https://chat.line.biz/U2df77fd63804c72346b4e50c0096572e/chat/Ua13ef47afc077917275658a44019e072"
 
55
  }
56
  }
57
  ]
58
+ },
59
  {
60
  "buttons": [
61
  {
62
  "textButton": {
63
+ "text": "Q&Aを登録する",
64
  "onClick": {
65
  "openLink": {
66
+ "url": "https://kenken999-php.hf.space/main_list.php?page=mainpage"
67
  }
68
  }
69
  }
70
  }
71
  ]
72
+ },
73
  ]
74
  }
75
  ]
routers/webhook.py CHANGED
@@ -24,7 +24,7 @@ from command.n8n import post_data,post_data_line
24
  import time
25
  import traceback
26
  logger = logging.getLogger(__name__)
27
-
28
  #router = APIRouter()
29
  router = APIRouter()
30
  #@router.get("/route/webhooks")
@@ -47,7 +47,7 @@ async def webhook(request: Request):
47
  n8nurl = os.getenv("n8nhook")
48
 
49
  thread_name=""
50
- #return
51
  #url = github(token,foldername)
52
  try:
53
 
@@ -97,13 +97,16 @@ async def webhook(request: Request):
97
 
98
  subtitle = f"""<b>ユーザーID</b> {user_id}\r\n <b>質問内容</b>\r\n{message_id} {text}"""
99
 
100
-
101
  subtitle = f"""
102
- <b>ユーザーID:</b>{user_id}
103
- <b>質問内容:</b> {text}
 
 
104
 
105
- <b>送信タイプ:</b> {event_type}
106
- <b>ラインへ返信token /line_replay でチャットから返信<b>{reply_token}
 
107
  """
108
  #<b>Webhook Event ID:</b> {webhook_event_id}<br>
109
  #<b>Delivery Context:</b> {json.dumps(delivery_context)}<br>
@@ -124,13 +127,15 @@ async def webhook(request: Request):
124
  ### n8n WorkFlowStart
125
  #########################################################################
126
  line_signature = received_headers.get("x-line-signature")
127
- #for debug
128
  headers = {
129
  "Content-Type": "application/json",
130
  "X-Line-Signature": line_signature,
131
  "Authorization": f"Bearer {os.getenv('ChannelAccessToken')}",
 
132
  }
133
  #/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f
 
134
  post_data("https://kenken999-nodex-n8n.hf.space/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f",text,thread_name,headers)
135
  #http://localhost:7860/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f
136
  post_data_line("https://kenken999-nodex-n8n.hf.space/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3d",body,headers)
@@ -170,25 +175,29 @@ async def webhook(request: Request):
170
 
171
  #########################################################################
172
  ## excute create program
173
- res_no_process = no_process_file(prompt_for_create_system+res, "gpt_enginner"+ yyyymmddhis,thread_name)
 
174
  # execute open interpreter
175
  #########################################################################
176
- full_response,history = chat_with_interpreter_no_stream(prompt_for_create_system+"\r\n"+res)
 
177
  if DEBUG==1:
178
  thread_name = send_google_chat_card_thread(webhook_url, f"自動設定開始 {res}", str(full_response), link_text, link_url,thread_name)
179
- #########################################################################
180
  #ダイヤ金額計算
181
  from babyagi.classesa.diamond import calculate
182
- title = f""" ダイヤ予測計算の実行 類似5件表示 {text}
183
- id,price,carat, cut, color, clarity, depth, diamondprice.table, x, y, z 類似度"""
184
- res_calculate = calculate(text)
185
- subtitle = res_calculate
186
- link_text = "データを確認する"
187
- link_url = "https://kenken999-php.hf.space/diamondprice_list.php"
188
- #########################################################################
189
- test_set_lide(subtitle, text)
190
-
191
  if DEBUG==1:
 
 
 
 
 
 
 
 
 
 
 
192
  thread_name = send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
193
  #########################################################################
194
  from babyagi.babyagi import completion
@@ -196,9 +205,9 @@ async def webhook(request: Request):
196
  text = text.replace("\r\n","")
197
  # コマンドを構築
198
  command = f"""make runbabyagi "{text}に対して、より良いチャットボットでのQAプランデータ設定の提案を日本語で作成してください" {thread_name}"""
199
-
200
- with open('/home/user/app/babyagi/prompt.txt', 'w') as file:
201
- file.write(f"""{text}の質問 についてチャットボットでよりよく対応するプランを日本語で作成して""")
202
 
203
  ######################################################################
204
  if DEBUG==1:
@@ -230,6 +239,7 @@ async def webhook(request: Request):
230
  # "Authorization": f"Bearer {os.getenv('ChannelAccessToken')}",
231
  # }
232
  #r#esponse = requests.post(os.getenv("WEBHOOK_URL"), headers=headers, data=body)
 
233
  if not line_signature:
234
  raise HTTPException(status_code=400, detail="X-Line-Signature header is missing.")
235
 
@@ -279,7 +289,9 @@ async def webhook(request: Request):
279
  #test_set_lide(subtitle, text)
280
  logger.error(res)
281
  #send error to google chat
282
- send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
 
 
283
  logger.error("Error: %s", str(e))
284
  #raise するとシステムとまるのでアンコメント
285
  #raise HTTPException(status_code=500, detail=str(e))
 
24
  import time
25
  import traceback
26
  logger = logging.getLogger(__name__)
27
+ ##
28
  #router = APIRouter()
29
  router = APIRouter()
30
  #@router.get("/route/webhooks")
 
47
  n8nurl = os.getenv("n8nhook")
48
 
49
  thread_name=""
50
+ ###return
51
  #url = github(token,foldername)
52
  try:
53
 
 
97
 
98
  subtitle = f"""<b>ユーザーID</b> {user_id}\r\n <b>質問内容</b>\r\n{message_id} {text}"""
99
 
100
+ ##
101
  subtitle = f"""
102
+ <b>ユーザーID:</b>
103
+ {user_id}
104
+ <b>質問内容:</b>
105
+ {text}
106
 
107
+ <b>ラインへ返信token</b>
108
+ {reply_token}
109
+ GoogleChatから返信 /line_replay でチャットから返信
110
  """
111
  #<b>Webhook Event ID:</b> {webhook_event_id}<br>
112
  #<b>Delivery Context:</b> {json.dumps(delivery_context)}<br>
 
127
  ### n8n WorkFlowStart
128
  #########################################################################
129
  line_signature = received_headers.get("x-line-signature")
130
+ ####$for debug
131
  headers = {
132
  "Content-Type": "application/json",
133
  "X-Line-Signature": line_signature,
134
  "Authorization": f"Bearer {os.getenv('ChannelAccessToken')}",
135
+ "user_id":user_id,
136
  }
137
  #/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f
138
+ #d2d0af6e-5c42-45b6-a923-3bd2d8520e3d
139
  post_data("https://kenken999-nodex-n8n.hf.space/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f",text,thread_name,headers)
140
  #http://localhost:7860/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3f
141
  post_data_line("https://kenken999-nodex-n8n.hf.space/webhook-test/d2d0af6e-5c42-45b6-a923-3bd2d8520e3d",body,headers)
 
175
 
176
  #########################################################################
177
  ## excute create program
178
+ if DEBUG==1:
179
+ res_no_process = no_process_file(prompt_for_create_system+res, "gpt_enginner"+ yyyymmddhis,thread_name)
180
  # execute open interpreter
181
  #########################################################################
182
+ if DEBUG==1:
183
+ full_response,history = chat_with_interpreter_no_stream(prompt_for_create_system+"\r\n"+res)
184
  if DEBUG==1:
185
  thread_name = send_google_chat_card_thread(webhook_url, f"自動設定開始 {res}", str(full_response), link_text, link_url,thread_name)
186
+ ####################################################################
187
  #ダイヤ金額計算
188
  from babyagi.classesa.diamond import calculate
 
 
 
 
 
 
 
 
 
189
  if DEBUG==1:
190
+ title = f""" ダイヤ予測計算の実行 類似5件表示 {text}
191
+ id,price,carat, cut, color, clarity, depth, diamondprice.table, x, y, z 類似度"""
192
+ #ベクトルインデックス
193
+ res_calculate = calculate(text)
194
+ subtitle = res_calculate
195
+ link_text = "データを確認する"
196
+ link_url = "https://kenken999-php.hf.space/diamondprice_list.php"
197
+ #########################################################################
198
+ #test_set_lide(subtitle, text)
199
+
200
+ #if DEBUG==0:
201
  thread_name = send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
202
  #########################################################################
203
  from babyagi.babyagi import completion
 
205
  text = text.replace("\r\n","")
206
  # コマンドを構築
207
  command = f"""make runbabyagi "{text}に対して、より良いチャットボットでのQAプランデータ設定の提案を日本語で作成してください" {thread_name}"""
208
+ if DEBUG==1:
209
+ with open('/home/user/app/babyagi/prompt.txt', 'w') as file:
210
+ file.write(f"""{text}の質問 についてチャットボットでよりよく対応するプランを日本語で作成して""")
211
 
212
  ######################################################################
213
  if DEBUG==1:
 
239
  # "Authorization": f"Bearer {os.getenv('ChannelAccessToken')}",
240
  # }
241
  #r#esponse = requests.post(os.getenv("WEBHOOK_URL"), headers=headers, data=body)
242
+
243
  if not line_signature:
244
  raise HTTPException(status_code=400, detail="X-Line-Signature header is missing.")
245
 
 
289
  #test_set_lide(subtitle, text)
290
  logger.error(res)
291
  #send error to google chat
292
+ ###
293
+ #send_google_chat_card_thread(webhook_url, title, subtitle, link_text, link_url,thread_name)
294
+
295
  logger.error("Error: %s", str(e))
296
  #raise するとシステムとまるのでアンコメント
297
  #raise HTTPException(status_code=500, detail=str(e))
workspace/buysystem/buysystem/__init__.py ADDED
File without changes
workspace/buysystem/buysystem/asgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ ASGI config for buysystem project.
3
+
4
+ It exposes the ASGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.asgi import get_asgi_application
13
+
14
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'buysystem.settings')
15
+
16
+ application = get_asgi_application()
workspace/buysystem/buysystem/settings.py ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Django settings for buysystem project.
3
+
4
+ Generated by 'django-admin startproject' using Django 5.0.4.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.0/topics/settings/
8
+
9
+ For the full list of settings and their values, see
10
+ https://docs.djangoproject.com/en/5.0/ref/settings/
11
+ """
12
+
13
+ from pathlib import Path
14
+
15
+ # Build paths inside the project like this: BASE_DIR / 'subdir'.
16
+ BASE_DIR = Path(__file__).resolve().parent.parent
17
+
18
+
19
+ # Quick-start development settings - unsuitable for production
20
+ # See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
21
+
22
+ # SECURITY WARNING: keep the secret key used in production secret!
23
+ SECRET_KEY = 'django-insecure-w&_ve_ax*9b7^f3vms=$lg)n=yu_pgil8u%c&@#$ixs!^fi3+y'
24
+
25
+ # SECURITY WARNING: don't run with debug turned on in production!
26
+ DEBUG = True
27
+
28
+ ALLOWED_HOSTS = []
29
+
30
+
31
+ # Application definition
32
+
33
+ INSTALLED_APPS = [
34
+ 'django.contrib.admin',
35
+ 'django.contrib.auth',
36
+ 'django.contrib.contenttypes',
37
+ 'django.contrib.sessions',
38
+ 'django.contrib.messages',
39
+ 'django.contrib.staticfiles',
40
+ ]
41
+
42
+ MIDDLEWARE = [
43
+ 'django.middleware.security.SecurityMiddleware',
44
+ 'django.contrib.sessions.middleware.SessionMiddleware',
45
+ 'django.middleware.common.CommonMiddleware',
46
+ 'django.middleware.csrf.CsrfViewMiddleware',
47
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
48
+ 'django.contrib.messages.middleware.MessageMiddleware',
49
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
50
+ ]
51
+
52
+ ROOT_URLCONF = 'buysystem.urls'
53
+
54
+ TEMPLATES = [
55
+ {
56
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
57
+ 'DIRS': [],
58
+ 'APP_DIRS': True,
59
+ 'OPTIONS': {
60
+ 'context_processors': [
61
+ 'django.template.context_processors.debug',
62
+ 'django.template.context_processors.request',
63
+ 'django.contrib.auth.context_processors.auth',
64
+ 'django.contrib.messages.context_processors.messages',
65
+ ],
66
+ },
67
+ },
68
+ ]
69
+
70
+ WSGI_APPLICATION = 'buysystem.wsgi.application'
71
+
72
+
73
+ # Database
74
+ # https://docs.djangoproject.com/en/5.0/ref/settings/#databases
75
+
76
+ DATABASES = {
77
+ 'default': {
78
+ 'ENGINE': 'django.db.backends.sqlite3',
79
+ 'NAME': BASE_DIR / 'db.sqlite3',
80
+ }
81
+ }
82
+
83
+
84
+ # Password validation
85
+ # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
86
+
87
+ AUTH_PASSWORD_VALIDATORS = [
88
+ {
89
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
90
+ },
91
+ {
92
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
93
+ },
94
+ {
95
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
96
+ },
97
+ {
98
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
99
+ },
100
+ ]
101
+
102
+
103
+ # Internationalization
104
+ # https://docs.djangoproject.com/en/5.0/topics/i18n/
105
+
106
+ LANGUAGE_CODE = 'en-us'
107
+
108
+ TIME_ZONE = 'UTC'
109
+
110
+ USE_I18N = True
111
+
112
+ USE_TZ = True
113
+
114
+
115
+ # Static files (CSS, JavaScript, Images)
116
+ # https://docs.djangoproject.com/en/5.0/howto/static-files/
117
+
118
+ STATIC_URL = 'static/'
119
+
120
+ # Default primary key field type
121
+ # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
122
+
123
+ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
workspace/buysystem/buysystem/urls.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ URL configuration for buysystem project.
3
+
4
+ The `urlpatterns` list routes URLs to views. For more information please see:
5
+ https://docs.djangoproject.com/en/5.0/topics/http/urls/
6
+ Examples:
7
+ Function views
8
+ 1. Add an import: from my_app import views
9
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
10
+ Class-based views
11
+ 1. Add an import: from other_app.views import Home
12
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
13
+ Including another URLconf
14
+ 1. Import the include() function: from django.urls import include, path
15
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
16
+ """
17
+ from django.contrib import admin
18
+ from django.urls import path
19
+
20
+ urlpatterns = [
21
+ path('admin/', admin.site.urls),
22
+ ]
workspace/buysystem/buysystem/wsgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ WSGI config for buysystem project.
3
+
4
+ It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.wsgi import get_wsgi_application
13
+
14
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'buysystem.settings')
15
+
16
+ application = get_wsgi_application()
workspace/buysystem/buysystem_app/__init__.py ADDED
File without changes
workspace/buysystem/buysystem_app/admin.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.contrib import admin
2
+
3
+ # Register your models here.
workspace/buysystem/buysystem_app/apps.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class BuysystemAppConfig(AppConfig):
5
+ default_auto_field = 'django.db.models.BigAutoField'
6
+ name = 'buysystem_app'
workspace/buysystem/buysystem_app/migrations/__init__.py ADDED
File without changes
workspace/buysystem/buysystem_app/models.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.db import models
2
+
3
+ # Create your models here.
workspace/buysystem/buysystem_app/tests.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.test import TestCase
2
+
3
+ # Create your tests here.
workspace/buysystem/buysystem_app/views.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.shortcuts import render
2
+
3
+ # Create your views here.
workspace/buysystem/manage.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Django's command-line utility for administrative tasks."""
3
+ import os
4
+ import sys
5
+
6
+
7
+ def main():
8
+ """Run administrative tasks."""
9
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'buysystem.settings')
10
+ try:
11
+ from django.core.management import execute_from_command_line
12
+ except ImportError as exc:
13
+ raise ImportError(
14
+ "Couldn't import Django. Are you sure it's installed and "
15
+ "available on your PYTHONPATH environment variable? Did you "
16
+ "forget to activate a virtual environment?"
17
+ ) from exc
18
+ execute_from_command_line(sys.argv)
19
+
20
+
21
+ if __name__ == '__main__':
22
+ main()