Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-plugin-chatgpt-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
koishi-plugin-chatgpt-api
Commits
27d324b5
Commit
27d324b5
authored
Feb 10, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change command a bit
parent
74283f43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
src/index.tsx
src/index.tsx
+12
-2
No files found.
src/index.tsx
View file @
27d324b5
...
...
@@ -4,6 +4,7 @@ import {
Inject
,
InjectLogger
,
LifecycleEvents
,
PutArg
,
PutSession
,
StarterPlugin
,
UseCommand
,
...
...
@@ -64,7 +65,12 @@ export default class ChatGPTApiPlugin
return
`session:
${
session
.
platform
}
:
${
session
.
selfId
}
:
${
session
.
channelId
}
:
${
session
.
userId
}
`
;
}
@
UseCommand
(
'
chatgpt-reset
'
,
'
重置 ChatGPT 对话
'
)
@
UseCommand
(
'
chatgpt <content:text>
'
,
'
与 ChatGPT 对话,也可以直接发送消息。
'
)
async
chat
(@
PutSession
()
session
:
Session
,
@
PutArg
(
0
)
content
:
string
)
{
return
this
.
handle
(
session
,
content
);
}
@
UseCommand
(
'
chatgpt.reset
'
,
'
重置 ChatGPT 对话
'
)
async
reset
(@
PutSession
()
session
:
Session
)
{
await
this
.
__cache__
.
cache
(
'
chatgptMessages
'
)
...
...
@@ -77,7 +83,10 @@ export default class ChatGPTApiPlugin
@
UseMiddleware
()
middleware
(
session
:
Session
,
next
:
Next
)
{
if
(
!
this
.
config
.
prefix
.
length
||
session
.
parsed
?.
appel
)
if
(
(
!
this
.
config
.
prefix
.
length
&&
session
.
content
)
||
session
.
parsed
?.
appel
)
return
this
.
handle
(
session
,
session
.
content
);
const
matchingPrefix
=
this
.
config
.
prefix
.
find
((
prefix
)
=>
session
.
content
.
startsWith
(
prefix
),
...
...
@@ -87,6 +96,7 @@ export default class ChatGPTApiPlugin
}
async
handle
(
session
:
Session
,
text
:
string
)
{
if
(
!
text
)
return
;
const
api
=
this
.
getApiInstance
(
session
);
const
key
=
this
.
sessionKey
(
session
);
const
lastMessage
=
await
this
.
__cache__
.
cache
(
'
chatgptMessages
'
).
get
(
key
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment