-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add 本周星座運勢(限繁中指令), add group chat
- Loading branch information
1 parent
83fa86e
commit a22dafa
Showing
14 changed files
with
215 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from chatgpt_linebot.modules.gpt import chat_completion | ||
from chatgpt_linebot.modules.horoscope import Horoscope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import g4f | ||
from chatgpt_linebot.memory import Memory | ||
|
||
|
||
def chat_completion(id: int, memory: Memory) -> str: | ||
"""Use OpenAI API via gpt4free providers""" | ||
try: | ||
response = g4f.ChatCompletion.create( | ||
model=g4f.models.default, | ||
messages=memory.get(id), | ||
) | ||
memory.append(id, 'system', response) | ||
print(response) | ||
|
||
except Exception as e: | ||
response = ( | ||
"There're something wrong in openai api, please try again.😱\n" | ||
"Or connect to developer: https://github.com/Lin-jun-xiang/chatgpt-line-bot/issues" | ||
) | ||
print(e) | ||
|
||
return response |
Oops, something went wrong.