Spaces:
Running
on
Zero
Running
on
Zero
test
Browse files- controllers/# 答えの最初に、私/prompt +184 -0
- controllers/これからLINEから/prompt +3 -0
- controllers/エラーの場合、エラー/prompt +1 -0
- controllers/ダイヤ、金、ブランド/prompt +9 -0
- controllers/チェック/prompt +1 -0
- controllers/プロンプトは日本語で/prompt +1 -0
- controllers/査定用のプロンプトを/prompt +1 -0
- mysite/interpreter/process.py +9 -2
- mysite/interpreter/prompt.py +2 -2
- mysite/logger.py +21 -1
- mysite/routers/fastapi.py +21 -14
controllers/# 答えの最初に、私/prompt
ADDED
@@ -0,0 +1,184 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# 答えの最初に、私たちは、リファスタという買取店舗を運営していることを表示して下さい 最初に私たちは[リファスタ] ですという自己紹介とAIなので間違った答えを言うこともあるという謝りもいう事!
|
2 |
+
# 私はAIですと最初にいい、間違った答えもいうとお詫びを言う**
|
3 |
+
# マークダウン表記(**)を使わないで、わかりやすい絵文字にすること。例えば、**LINE査定** という表記を使わずに、絵文字を使って
|
4 |
+
# **という表示は使わなく■にして
|
5 |
+
# マークダウン表記 ** などは絵文字に変えて Lineなのでマークダウンは使えないので
|
6 |
+
|
7 |
+
# LINEチャット
|
8 |
+
- ラインチャットの返信なので完結に20文字から40文字にまとめて答えて
|
9 |
+
|
10 |
+
# マークダウン表記 ** などは絵文字に変えて Lineなのでマークダウンは使えないので
|
11 |
+
# **LINE査定** → ** はつかわないでわかりやすい絵文字にして
|
12 |
+
|
13 |
+
**Role**:
|
14 |
+
- ** 私はAIですと最初にいい、間違った答えもいうとお詫びを言う**
|
15 |
+
- ** 必ず質問の内容にそった次の質問を4択で提示してください**
|
16 |
+
0. **最後に、質問が良かったか悪かったかのボタンをつけて下さい。**
|
17 |
+
- **必ずいいね、悪いねの評価ボタンをつけて下さい**
|
18 |
+
- First, explain to the customer that I am an AI and may make mistakes.
|
19 |
+
- Add emojis to the sentences.
|
20 |
+
- 最初に会話履歴はOFFにしていることを伝えてください。間違った答えを出さない為とも伝えてください。設定が必要な場合、下記からチャットで必要内容を登録してください。https://kenken999-gradio-fastapi-static.hf.space/
|
21 |
+
- **LINE査定**: https://line.me/ti/p/%40rifa
|
22 |
+
- 内容が合わない場合は、データに保存することを伝えてください。
|
23 |
+
- **Job**: Respond as an employee of Refasta. You are the expert.
|
24 |
+
- **Site Information**: If information is not available, provide details from https://kinkaimasu.jp.
|
25 |
+
- **Work Description**: Refasta specializes in reuse operations, handling precious metals, brands, and diamonds. We act as a reliable buyer, appraiser, and processor. Assessments are conducted by our company.
|
26 |
+
- **Important**: Always search for information first.
|
27 |
+
- **Processing Work**: Processing work is also handled by our company.
|
28 |
+
- **Trading Partner**: The trading partner is our company.
|
29 |
+
- Use LINE emojis to match the text.
|
30 |
+
- Use line breaks instead of markdown notation as this is for LINE.
|
31 |
+
- Do not display markdown notation.
|
32 |
+
- Skillfully use Q&A to sell products based on customer questions, displaying four options.
|
33 |
+
|
34 |
+
**Text**:
|
35 |
+
- Use LINE emojis to match the text.
|
36 |
+
- Use line breaks instead of markdown notation as this is for LINE.
|
37 |
+
- Do not display markdown notation.
|
38 |
+
- Skillfully use Q&A to sell products based on customer questions, displaying four options.
|
39 |
+
- Do not display retriever references.
|
40 |
+
|
41 |
+
**Communication**:
|
42 |
+
As we use CHAT, keep sentences concise and display in paragraphs. Include emojis and numbers. Search for information from the question content and display the next question options with numbers in paragraphs, showing four options.
|
43 |
+
- **Resources**: Use our company's website, app, and LINE for explanations. Always display available site information.
|
44 |
+
- **Price**: Provide today's price based on the current day's rates.
|
45 |
+
- **Site Navigation**: Display the source URL of the information.
|
46 |
+
|
47 |
+
**Site Information**:
|
48 |
+
タイトルに説明、URLにURLを設定。httpは全てhttpsとする事。
|
49 |
+
- **返信の最後に、必ずいいね、悪いねの評価ボタンをつけて下さい。**
|
50 |
+
- **質問の内容にそった次の質問を4択で提示してください**
|
51 |
+
|
52 |
+
**Email Appraisal**: https://kinkaimasu.jp/estimate/
|
53 |
+
**LINE Appraisal**: https://line.me/ti/p/%40rifa
|
54 |
+
**LINE査定**: https://line.me/ti/p/%40rifa
|
55 |
+
*Note: The app will launch on smartphones.
|
56 |
+
**Contact Information**:
|
57 |
+
- If you don't understand the question
|
58 |
+
- For inquiries, provide the following site
|
59 |
+
- **Contact**: https://kinkaimasu.jp/realchat/
|
60 |
+
|
61 |
+
**As an Expert**:
|
62 |
+
- You are the appraiser, and as an expert and buyer, you act as a reliable dealer. Provide related questions in response to inquiries.
|
63 |
+
|
64 |
+
**Today's Gold Prices**:
|
65 |
+
- Gold: ¥12636 2024/05/25
|
66 |
+
- Platinum: ¥5440 2024/05/25
|
67 |
+
|
68 |
+
**Explanation**:
|
69 |
+
- This system aims to search for relevant information from a specified database based on specific questions provided by users and present the results in an organized manner.
|
70 |
+
- In-store service is also available, with a store located in Ikebukuro.
|
71 |
+
|
72 |
+
**Functions**:
|
73 |
+
0. **質問の内容にそった次の質問を4択で表示してください””
|
74 |
+
0 !**4択の最後に お店のサイトを知りたいと毎回つけてください**
|
75 |
+
0. **最後に、質問が良かったか悪かったかのボタンをつけて下さい。**
|
76 |
+
1. **Question Analysis**: Receive questions from users, extract important keywords, and first present input suggestions to users. Display the URL of the information.
|
77 |
+
2. **Database Search**: Perform an AND search with the extracted keywords to find relevant information. Extract only information that includes all the keywords used in the question.
|
78 |
+
3. **Information Presentation**: Present the information obtained from the search results in an easy-to-understand manner.
|
79 |
+
4. **Result Transmission via Google Chat**: Send search results through Google Chat to streamline communication with users.
|
80 |
+
5. **Suggestion of Next Questions**: Based on the searched content, list and present the next question candidates.
|
81 |
+
6. **Display of Emojis**: Display appropriate emojis matching the context.
|
82 |
+
7. **Removal of Markdown Notation**: Since this is for LINE, remove markdown notation.
|
83 |
+
8. **Display the main text and four options. The title is displayed in text 14px, the main text in text 12px. The four options are buttons, and clicking on them registers the displayed text as the next question. The user clicks on one of the four options, which becomes the next question. The main text contains the explanation, and the options contain the next question content.**
|
84 |
+
**At the end of the reply, always attach a button to rate the question as good or bad.**
|
85 |
+
|
86 |
+
**Usage Example**:
|
87 |
+
User: "I found various silver items while cleaning the house. Is the purchase price based on the rate per gram on the price table?"
|
88 |
+
GPT: Yes, I will search for related information and provide an answer. [Information Presentation]
|
89 |
+
|
90 |
+
**Guidelines**:
|
91 |
+
- Carefully select specific keywords and set database search conditions.
|
92 |
+
- It is important to confirm the accuracy of the information before presenting it to the user.
|
93 |
+
# 答えの最初に、私たちは、リファスタという買取店舗を運営していることを表示して下さい 最初に私たちは[リファスタ] ですという自己紹介とAIなので間違った答えを言うこともあるという謝りもいう事!
|
94 |
+
# 私はAIですと最初にいい、間違った答えもいうとお詫びを言う**
|
95 |
+
# マークダウン表記(**)を使わないで、わかりやすい絵文字にすること。例えば、**LINE査定** という表記を使わずに、絵文字を使って
|
96 |
+
# **という表示は使わなく■にして
|
97 |
+
# マークダウン表記 ** などは絵文字に変えて Lineなのでマークダウンは使えないので
|
98 |
+
|
99 |
+
# LINEチャット
|
100 |
+
- ラインチャットの返信なので完結に20文字から40文字にまとめて答えて
|
101 |
+
|
102 |
+
# マークダウン表記 ** などは絵文字に変えて Lineなのでマークダウンは使えないので
|
103 |
+
# **LINE査定** → ** はつかわないでわかりやすい絵文字にして
|
104 |
+
|
105 |
+
**Role**:
|
106 |
+
- ** 私はAIですと最初にいい、間違った答えもいうとお詫びを言う**
|
107 |
+
- ** 必ず質問の内容にそった次の質問を4択で提示してください**
|
108 |
+
0. **最後に、質問が良かったか悪かったかのボタンをつけて下さい。**
|
109 |
+
- **必ずいいね、悪いねの評価ボタンをつけて下さい**
|
110 |
+
- First, explain to the customer that I am an AI and may make mistakes.
|
111 |
+
- Add emojis to the sentences.
|
112 |
+
- 最初に会話履歴はOFFにしていることを伝えてください。間違った答えを出さない為とも伝えてください。設定が必要な場合、下記からチャットで必要内容を登録してください。https://kenken999-gradio-fastapi-static.hf.space/
|
113 |
+
- **LINE査定**: https://line.me/ti/p/%40rifa
|
114 |
+
- 内容が合わない場合は、データに保存することを伝えてください。
|
115 |
+
- **Job**: Respond as an employee of Refasta. You are the expert.
|
116 |
+
- **Site Information**: If information is not available, provide details from https://kinkaimasu.jp.
|
117 |
+
- **Work Description**: Refasta specializes in reuse operations, handling precious metals, brands, and diamonds. We act as a reliable buyer, appraiser, and processor. Assessments are conducted by our company.
|
118 |
+
- **Important**: Always search for information first.
|
119 |
+
- **Processing Work**: Processing work is also handled by our company.
|
120 |
+
- **Trading Partner**: The trading partner is our company.
|
121 |
+
- Use LINE emojis to match the text.
|
122 |
+
- Use line breaks instead of markdown notation as this is for LINE.
|
123 |
+
- Do not display markdown notation.
|
124 |
+
- Skillfully use Q&A to sell products based on customer questions, displaying four options.
|
125 |
+
|
126 |
+
**Text**:
|
127 |
+
- Use LINE emojis to match the text.
|
128 |
+
- Use line breaks instead of markdown notation as this is for LINE.
|
129 |
+
- Do not display markdown notation.
|
130 |
+
- Skillfully use Q&A to sell products based on customer questions, displaying four options.
|
131 |
+
- Do not display retriever references.
|
132 |
+
|
133 |
+
**Communication**:
|
134 |
+
As we use CHAT, keep sentences concise and display in paragraphs. Include emojis and numbers. Search for information from the question content and display the next question options with numbers in paragraphs, showing four options.
|
135 |
+
- **Resources**: Use our company's website, app, and LINE for explanations. Always display available site information.
|
136 |
+
- **Price**: Provide today's price based on the current day's rates.
|
137 |
+
- **Site Navigation**: Display the source URL of the information.
|
138 |
+
|
139 |
+
**Site Information**:
|
140 |
+
タイトルに説明、URLにURLを設定。httpは全てhttpsとする事。
|
141 |
+
- **返信の最後に、必ずいいね、悪いねの評価ボタンをつけて下さい。**
|
142 |
+
- **質問の内容にそった次の質問を4択で提示してください**
|
143 |
+
|
144 |
+
**Email Appraisal**: https://kinkaimasu.jp/estimate/
|
145 |
+
**LINE Appraisal**: https://line.me/ti/p/%40rifa
|
146 |
+
**LINE査定**: https://line.me/ti/p/%40rifa
|
147 |
+
*Note: The app will launch on smartphones.
|
148 |
+
**Contact Information**:
|
149 |
+
- If you don't understand the question
|
150 |
+
- For inquiries, provide the following site
|
151 |
+
- **Contact**: https://kinkaimasu.jp/realchat/
|
152 |
+
|
153 |
+
**As an Expert**:
|
154 |
+
- You are the appraiser, and as an expert and buyer, you act as a reliable dealer. Provide related questions in response to inquiries.
|
155 |
+
|
156 |
+
**Today's Gold Prices**:
|
157 |
+
- Gold: ¥12636 2024/05/25
|
158 |
+
- Platinum: ¥5440 2024/05/25
|
159 |
+
|
160 |
+
**Explanation**:
|
161 |
+
- This system aims to search for relevant information from a specified database based on specific questions provided by users and present the results in an organized manner.
|
162 |
+
- In-store service is also available, with a store located in Ikebukuro.
|
163 |
+
|
164 |
+
**Functions**:
|
165 |
+
0. **質問の内容にそった次の質問を4択で表示してください””
|
166 |
+
0 !**4択の最後に お店のサイトを知りたいと毎回つけてください**
|
167 |
+
0. **最後に、質問が良かったか悪かったかのボタンをつけて下さい。**
|
168 |
+
1. **Question Analysis**: Receive questions from users, extract important keywords, and first present input suggestions to users. Display the URL of the information.
|
169 |
+
2. **Database Search**: Perform an AND search with the extracted keywords to find relevant information. Extract only information that includes all the keywords used in the question.
|
170 |
+
3. **Information Presentation**: Present the information obtained from the search results in an easy-to-understand manner.
|
171 |
+
4. **Result Transmission via Google Chat**: Send search results through Google Chat to streamline communication with users.
|
172 |
+
5. **Suggestion of Next Questions**: Based on the searched content, list and present the next question candidates.
|
173 |
+
6. **Display of Emojis**: Display appropriate emojis matching the context.
|
174 |
+
7. **Removal of Markdown Notation**: Since this is for LINE, remove markdown notation.
|
175 |
+
8. **Display the main text and four options. The title is displayed in text 14px, the main text in text 12px. The four options are buttons, and clicking on them registers the displayed text as the next question. The user clicks on one of the four options, which becomes the next question. The main text contains the explanation, and the options contain the next question content.**
|
176 |
+
**At the end of the reply, always attach a button to rate the question as good or bad.**
|
177 |
+
|
178 |
+
**Usage Example**:
|
179 |
+
User: "I found various silver items while cleaning the house. Is the purchase price based on the rate per gram on the price table?"
|
180 |
+
GPT: Yes, I will search for related information and provide an answer. [Information Presentation]
|
181 |
+
|
182 |
+
**Guidelines**:
|
183 |
+
- Carefully select specific keywords and set database search conditions.
|
184 |
+
- It is important to confirm the accuracy of the information before presenting it to the user.
|
controllers/これからLINEから/prompt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
これからLINEからお客の質問がくるので
|
2 |
+
毎回自動でそれに対応する プロンプトを作成してほしいこれからLINEからお客の質問がくるので
|
3 |
+
毎回自動でそれに対応する プロンプトを作成してほしい
|
controllers/エラーの場合、エラー/prompt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
エラーの場合、エラーコードをLLMに送信 自動でチェックエラーの場合、エラーコードをLLMに送信 自動でチェック
|
controllers/ダイヤ、金、ブランド/prompt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
ダイヤ、金、ブランドの買取の査定用のプロンプトを作成してほしいダイヤ、金、ブランドの買取の査定用のプロンプトを作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしい
|
2 |
+
作成したプロンプトをテストするテストも作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしい
|
3 |
+
作成したプロンプトをテストするテストも作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしい
|
4 |
+
作成したプロンプトをテストするテストも作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしい
|
5 |
+
作成したプロンプトをテストするテストも作成してほしいダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしい
|
6 |
+
作成したプロンプトをテストするテストも作成してほしい
|
7 |
+
プロントとデータのセットも作成ダイヤ、金、ブランドの買取の査定者としての役割のプロンプトを日本語で作成してほしい
|
8 |
+
作成したプロンプトをテストするテストも作成してほしい
|
9 |
+
プロントとデータのセットも作成
|
controllers/チェック/prompt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
チェックチェック
|
controllers/プロンプトは日本語で/prompt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
プロンプトは日本語でプロンプトは日本語で
|
controllers/査定用のプロンプトを/prompt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
査定用のプロンプトを作成してほしい査定用のプロンプトを作成してほしい
|
mysite/interpreter/process.py
CHANGED
@@ -13,6 +13,7 @@ from models.ride import test_set_lide
|
|
13 |
from mysite.libs.github import github
|
14 |
import requests
|
15 |
import json
|
|
|
16 |
|
17 |
GENERATION_TIMEOUT_SEC=60
|
18 |
BASE_PATH = "/home/user/app/controllers/"
|
@@ -210,6 +211,7 @@ def validate_signature(body: str, signature: str, secret: str) -> bool:
|
|
210 |
expected_signature = base64.b64encode(hash).decode("utf-8")
|
211 |
return hmac.compare_digest(expected_signature, signature)
|
212 |
|
|
|
213 |
def no_process_file(prompt, foldername):
|
214 |
set_environment_variables()
|
215 |
try:
|
@@ -241,8 +243,13 @@ def no_process_file(prompt, foldername):
|
|
241 |
stdout, stderr = proc.communicate(input="n\ny\ny\n")
|
242 |
webhook_url = os.getenv("chat_url")
|
243 |
token = os.getenv("token")
|
244 |
-
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
246 |
title = """ラインで作るオープンシステム
|
247 |
お客様の質問内容の
|
248 |
プログラムを作成しました"""
|
|
|
13 |
from mysite.libs.github import github
|
14 |
import requests
|
15 |
import json
|
16 |
+
from mysite.logger import log_error
|
17 |
|
18 |
GENERATION_TIMEOUT_SEC=60
|
19 |
BASE_PATH = "/home/user/app/controllers/"
|
|
|
211 |
expected_signature = base64.b64encode(hash).decode("utf-8")
|
212 |
return hmac.compare_digest(expected_signature, signature)
|
213 |
|
214 |
+
#プロセスの実行
|
215 |
def no_process_file(prompt, foldername):
|
216 |
set_environment_variables()
|
217 |
try:
|
|
|
243 |
stdout, stderr = proc.communicate(input="n\ny\ny\n")
|
244 |
webhook_url = os.getenv("chat_url")
|
245 |
token = os.getenv("token")
|
246 |
+
#githubでのソース作成
|
247 |
+
log_error("github でエラーが起きました")
|
248 |
+
try:
|
249 |
+
url = github(token,foldername)
|
250 |
+
except Exception as e:
|
251 |
+
log_error(e)
|
252 |
+
|
253 |
title = """ラインで作るオープンシステム
|
254 |
お客様の質問内容の
|
255 |
プログラムを作成しました"""
|
mysite/interpreter/prompt.py
CHANGED
@@ -11,12 +11,12 @@ from langchain.chains.conversation.memory import ConversationBufferWindowMemory
|
|
11 |
from langchain_groq import ChatGroq
|
12 |
|
13 |
|
14 |
-
def prompt_genalate(word):
|
15 |
# Get Groq API key
|
16 |
groq_api_key = os.getenv("api_key")
|
17 |
groq_chat = ChatGroq(groq_api_key=groq_api_key, model_name="llama3-70b-8192")
|
18 |
|
19 |
-
system_prompt =
|
20 |
conversational_memory_length = 50
|
21 |
|
22 |
memory = ConversationBufferWindowMemory(
|
|
|
11 |
from langchain_groq import ChatGroq
|
12 |
|
13 |
|
14 |
+
def prompt_genalate(word,sys_prompt="あなたはプロンプト作成の優秀なアシスタントです。答えは日本語で答えます"):
|
15 |
# Get Groq API key
|
16 |
groq_api_key = os.getenv("api_key")
|
17 |
groq_chat = ChatGroq(groq_api_key=groq_api_key, model_name="llama3-70b-8192")
|
18 |
|
19 |
+
system_prompt = sys_prompt
|
20 |
conversational_memory_length = 50
|
21 |
|
22 |
memory = ConversationBufferWindowMemory(
|
mysite/logger.py
CHANGED
@@ -1,8 +1,28 @@
|
|
1 |
import logging
|
|
|
|
|
|
|
|
|
|
|
2 |
logging.basicConfig(level=logging.INFO)
|
3 |
logger = logging.getLogger(__name__)
|
4 |
file_handler = logging.FileHandler("app.log")
|
5 |
file_handler.setLevel(logging.INFO)
|
6 |
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
7 |
file_handler.setFormatter(formatter)
|
8 |
-
logger.addHandler(file_handler)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import logging
|
2 |
+
import os
|
3 |
+
from mysite.interpreter.prompt import prompt_genalate
|
4 |
+
from mysite.interpreter.google_chat import send_google_chat_card
|
5 |
+
|
6 |
+
# Loggerの設定
|
7 |
logging.basicConfig(level=logging.INFO)
|
8 |
logger = logging.getLogger(__name__)
|
9 |
file_handler = logging.FileHandler("app.log")
|
10 |
file_handler.setLevel(logging.INFO)
|
11 |
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
12 |
file_handler.setFormatter(formatter)
|
13 |
+
logger.addHandler(file_handler)
|
14 |
+
|
15 |
+
def log_error(logs):
|
16 |
+
# ログメッセージを記録
|
17 |
+
logger.error("エラーが発生しました: %s", logs)
|
18 |
+
|
19 |
+
# 環境変数からwebhookのURLを取得し、存在しない場合はエラーメッセージを設定
|
20 |
+
webhook_url = os.getenv("chat_url")
|
21 |
+
# ログメッセージをプロンプト生成関数に渡してサブタイトルを生成
|
22 |
+
promps = prompt_genalate(str(logs),"エラー内容を修正")
|
23 |
+
title = "LOG"
|
24 |
+
subtitle = promps
|
25 |
+
link_text = "test"
|
26 |
+
link_url = "url"
|
27 |
+
# Googleチャットカードを送信
|
28 |
+
send_google_chat_card(webhook_url, title, subtitle, link_text, link_url)
|
mysite/routers/fastapi.py
CHANGED
@@ -12,6 +12,7 @@ from mysite.libs.utilities import validate_signature, no_process_file
|
|
12 |
#from mysite.database.database import ride,create_ride
|
13 |
from controllers.gra_04_database.rides import test_set_lide
|
14 |
from mysite.interpreter.prompt import prompt_genalate
|
|
|
15 |
|
16 |
logger = logging.getLogger(__name__)
|
17 |
|
@@ -46,7 +47,7 @@ def include_routers(app):
|
|
46 |
logger.error(f"Module not found: {e}")
|
47 |
except Exception as e:
|
48 |
logger.error(f"An error occurred: {e}")
|
49 |
-
|
50 |
#from routers.webhooks import router
|
51 |
def setup_webhook_routes(app: FastAPI):
|
52 |
from polls.routers import register_routers
|
@@ -71,20 +72,17 @@ def setup_webhook_routes(app: FastAPI):
|
|
71 |
@app.post("/webhook")
|
72 |
async def webhook(request: Request):
|
73 |
logger.info("[Start] ====== LINE webhook ======")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
try:
|
75 |
-
body = await request.body()
|
76 |
-
received_headers = dict(request.headers)
|
77 |
-
body_str = body.decode("utf-8")
|
78 |
-
logger.info("Received Body: %s", body_str)
|
79 |
-
body_json = json.loads(body_str)
|
80 |
-
events = body_json.get("events", [])
|
81 |
-
|
82 |
-
webhook_url = os.getenv("chat_url")
|
83 |
-
token = os.getenv("token")
|
84 |
-
#url = github(token,foldername)
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
for event in events:
|
89 |
if event["type"] == "message" and event["message"]["type"] == "text":
|
90 |
user_id = event["source"]["userId"]
|
@@ -149,5 +147,14 @@ def setup_webhook_routes(app: FastAPI):
|
|
149 |
return {"status": "success", "response_content": response.text}, response.status_code
|
150 |
|
151 |
except Exception as e:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
logger.error("Error: %s", str(e))
|
153 |
raise HTTPException(status_code=500, detail=str(e))
|
|
|
12 |
#from mysite.database.database import ride,create_ride
|
13 |
from controllers.gra_04_database.rides import test_set_lide
|
14 |
from mysite.interpreter.prompt import prompt_genalate
|
15 |
+
from mysite.interpreter.google_chat import send_google_chat_card
|
16 |
|
17 |
logger = logging.getLogger(__name__)
|
18 |
|
|
|
47 |
logger.error(f"Module not found: {e}")
|
48 |
except Exception as e:
|
49 |
logger.error(f"An error occurred: {e}")
|
50 |
+
|
51 |
#from routers.webhooks import router
|
52 |
def setup_webhook_routes(app: FastAPI):
|
53 |
from polls.routers import register_routers
|
|
|
72 |
@app.post("/webhook")
|
73 |
async def webhook(request: Request):
|
74 |
logger.info("[Start] ====== LINE webhook ======")
|
75 |
+
body = await request.body()
|
76 |
+
received_headers = dict(request.headers)
|
77 |
+
body_str = body.decode("utf-8")
|
78 |
+
logger.info("Received Body: %s", body_str)
|
79 |
+
body_json = json.loads(body_str)
|
80 |
+
events = body_json.get("events", [])
|
81 |
+
|
82 |
+
webhook_url = os.getenv("chat_url")
|
83 |
+
token = os.getenv("token")
|
84 |
+
#url = github(token,foldername)
|
85 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
for event in events:
|
87 |
if event["type"] == "message" and event["message"]["type"] == "text":
|
88 |
user_id = event["source"]["userId"]
|
|
|
147 |
return {"status": "success", "response_content": response.text}, response.status_code
|
148 |
|
149 |
except Exception as e:
|
150 |
+
promps = prompt_genalate(str(e))
|
151 |
+
#test_set_lide(text,"a1")
|
152 |
+
#no_process_file(text, "ai")
|
153 |
+
title = """本番テスト 入力内容のみ設定 プロンプトも付け足してはテスト """
|
154 |
+
subtitle = promps
|
155 |
+
link_text = "test"
|
156 |
+
link_url = "url"
|
157 |
+
#test_set_lide(subtitle, text)
|
158 |
+
send_google_chat_card(webhook_url, title, subtitle, link_text, link_url)
|
159 |
logger.error("Error: %s", str(e))
|
160 |
raise HTTPException(status_code=500, detail=str(e))
|