spike is better
This commit is contained in:
parent
d21db3f186
commit
9976bde4de
|
|
@ -11,7 +11,7 @@ interface UserContext {
|
|||
msg: OmitPartialGroupDMChannel<Message<boolean>>
|
||||
}
|
||||
|
||||
let history: AgentInputItem[] = []
|
||||
const historyForChannel: Record<string, AgentInputItem[]> = {}
|
||||
let abortController = new AbortController()
|
||||
|
||||
export const respondToUserMessage = async (msg: OmitPartialGroupDMChannel<Message<boolean>>) => {
|
||||
|
|
@ -24,14 +24,21 @@ export const respondToUserMessage = async (msg: OmitPartialGroupDMChannel<Messag
|
|||
msg.channel.sendTyping()
|
||||
})
|
||||
|
||||
return await respond(msg.content, agent, context)
|
||||
return await respond(msg.content, agent, msg.channel.id, context)
|
||||
}
|
||||
|
||||
export const respondToSystemMessage = async (msg: string) => {
|
||||
return await respond(msg, systemAgent)
|
||||
export const respondToSystemMessage = async (msg: string, channelId: string) => {
|
||||
return await respond(msg, systemAgent, channelId)
|
||||
}
|
||||
|
||||
const respond = async (content: string, agent: Agent<UserContext>, context?: UserContext) => {
|
||||
const respond = async (
|
||||
content: string,
|
||||
agent: Agent<UserContext>,
|
||||
channelId: string,
|
||||
context?: UserContext
|
||||
) => {
|
||||
const history = (historyForChannel[channelId] ||= [])
|
||||
|
||||
try {
|
||||
// Stop the previous response
|
||||
abortController.abort()
|
||||
|
|
@ -39,7 +46,7 @@ const respond = async (content: string, agent: Agent<UserContext>, context?: Use
|
|||
|
||||
history.push(context ? user(content) : system(content))
|
||||
const result = await run(agent, history, { context, signal: abortController.signal })
|
||||
history = result.history
|
||||
historyForChannel[channelId] = result.history
|
||||
|
||||
return result.finalOutput
|
||||
} catch (error) {
|
||||
|
|
@ -88,6 +95,7 @@ const reactionGuardrail: InputGuardrail = {
|
|||
const emoji = result.finalOutput?.trim()
|
||||
if (emoji && emoji !== "0") {
|
||||
const msg = (context.context as UserContext).msg
|
||||
const history = (historyForChannel[msg.channel.id] ||= [])
|
||||
history.push(system(`Spike reacted with ${emoji}`))
|
||||
msg.react(emoji)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ export const runCronJobs = async (client: Client) => {
|
|||
const content = `These reminders are due soon, let them know!: ${JSON.stringify(upcomingReminders)}`
|
||||
|
||||
console.log(`🌭`, { content })
|
||||
const output = await respondToSystemMessage(content)
|
||||
const output = await respondToSystemMessage(content, channelId)
|
||||
ensure(output, "The response to reminders should not be undefined")
|
||||
|
||||
for (let reminder of upcomingReminders) {
|
||||
|
|
|
|||
|
|
@ -25,14 +25,13 @@ export const listenForEvents = (client: Client) => {
|
|||
|
||||
client.on("ready", () => {
|
||||
// set the bots description
|
||||
client.user?.client.user?.setActivity(
|
||||
`${process.env.RENDER_GIT_BRANCH}@${process.env.RENDER_GIT_COMMIT}`,
|
||||
{
|
||||
type: ActivityType.Playing,
|
||||
state: `Error Count: ${0}`,
|
||||
url: `https://github.com/${process.env.RENDER_GIT_REPO_SLUG}/commit/${process.env.RENDER_GIT_COMMIT}`,
|
||||
}
|
||||
)
|
||||
const branch = process.env.RENDER_GIT_BRANCH || "unknown"
|
||||
const commit = process.env.RENDER_GIT_COMMIT?.slice(0, 7) || "deadbeef"
|
||||
client.user?.client.user?.setActivity(`${branch}@${commit}`, {
|
||||
type: ActivityType.Playing,
|
||||
state: `Error Count: ${0}`,
|
||||
url: `https://github.com/${process.env.RENDER_GIT_REPO_SLUG}/commit/${commit}`,
|
||||
})
|
||||
})
|
||||
|
||||
client.on("error", (error) => {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,15 @@ Usually if Spike is mentioned or asked a question he should reply. If the user i
|
|||
If Spike should reply return 1.
|
||||
If Spike should not reply return 0.
|
||||
|
||||
## Examples
|
||||
## Nicknames
|
||||
|
||||
Spike is often referred to by the following nicknames, consider these when deciding if Spike should reply:
|
||||
- Spike
|
||||
- spike
|
||||
- The cactus
|
||||
- Spiky
|
||||
|
||||
## Example interactions
|
||||
|
||||
user: Spike, can you set a reminder for me tomorrow at 08:00am for a meeting with the team?
|
||||
<respond> 1
|
||||
|
|
@ -181,4 +189,5 @@ user: I thought spike would be more helpful with that.
|
|||
|
||||
user: hey spike, what up
|
||||
<respond> 1
|
||||
|
||||
`
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user