Spaces:
Running
Running
Update chatgpt.py
Browse files- chatgpt.py +5 -6
chatgpt.py
CHANGED
|
@@ -6,13 +6,13 @@ import requests
|
|
| 6 |
# ===== Channel.io 設定 =====
|
| 7 |
CHANNEL_ID = "200605"
|
| 8 |
GROUP_ID = "534868"
|
| 9 |
-
ASSISTANT_PERSON_ID = "
|
| 10 |
|
| 11 |
MESSAGES_URL = f"https://desk-api.channel.io/desk/channels/{CHANNEL_ID}/groups/{GROUP_ID}/messages"
|
| 12 |
|
| 13 |
-
X_ACCOUNT = os.getenv("
|
| 14 |
if not X_ACCOUNT:
|
| 15 |
-
raise RuntimeError("環境変数
|
| 16 |
|
| 17 |
HEADERS = {
|
| 18 |
"accept": "application/json",
|
|
@@ -61,7 +61,7 @@ def build_chat_messages(messages):
|
|
| 61 |
|
| 62 |
role = (
|
| 63 |
"assistant"
|
| 64 |
-
if str(msg.get("
|
| 65 |
else "user"
|
| 66 |
)
|
| 67 |
|
|
@@ -127,7 +127,7 @@ def main():
|
|
| 127 |
)
|
| 128 |
|
| 129 |
latest_id = latest.get("id")
|
| 130 |
-
latest_person = str(latest.get("
|
| 131 |
latest_text = latest.get("plainText")
|
| 132 |
|
| 133 |
# 空メッセージは無視
|
|
@@ -140,7 +140,6 @@ def main():
|
|
| 140 |
time.sleep(10)
|
| 141 |
continue
|
| 142 |
|
| 143 |
-
# 最後が GPT(595702)なら何もしない
|
| 144 |
if latest_person == ASSISTANT_PERSON_ID:
|
| 145 |
time.sleep(10)
|
| 146 |
continue
|
|
|
|
| 6 |
# ===== Channel.io 設定 =====
|
| 7 |
CHANNEL_ID = "200605"
|
| 8 |
GROUP_ID = "534868"
|
| 9 |
+
ASSISTANT_PERSON_ID = "479401"
|
| 10 |
|
| 11 |
MESSAGES_URL = f"https://desk-api.channel.io/desk/channels/{CHANNEL_ID}/groups/{GROUP_ID}/messages"
|
| 12 |
|
| 13 |
+
X_ACCOUNT = os.getenv("dmsendertoken")
|
| 14 |
if not X_ACCOUNT:
|
| 15 |
+
raise RuntimeError("環境変数 dmsendertoken が設定されていません")
|
| 16 |
|
| 17 |
HEADERS = {
|
| 18 |
"accept": "application/json",
|
|
|
|
| 61 |
|
| 62 |
role = (
|
| 63 |
"assistant"
|
| 64 |
+
if str(msg.get("chatId")) == ASSISTANT_PERSON_ID
|
| 65 |
else "user"
|
| 66 |
)
|
| 67 |
|
|
|
|
| 127 |
)
|
| 128 |
|
| 129 |
latest_id = latest.get("id")
|
| 130 |
+
latest_person = str(latest.get("chatId"))
|
| 131 |
latest_text = latest.get("plainText")
|
| 132 |
|
| 133 |
# 空メッセージは無視
|
|
|
|
| 140 |
time.sleep(10)
|
| 141 |
continue
|
| 142 |
|
|
|
|
| 143 |
if latest_person == ASSISTANT_PERSON_ID:
|
| 144 |
time.sleep(10)
|
| 145 |
continue
|