mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
feat(agent): add trigger-schedule api
This commit is contained in:
+7
-1
@@ -12,7 +12,13 @@ export const createAgent = ({
|
||||
brave,
|
||||
language = 'Same as the user input',
|
||||
allowedActions = allActions,
|
||||
identity,
|
||||
identity = {
|
||||
botId: '',
|
||||
sessionId: '',
|
||||
containerId: '',
|
||||
contactId: '',
|
||||
contactName: '',
|
||||
},
|
||||
platforms = [],
|
||||
currentPlatform = 'Unknown Platform',
|
||||
}: AgentParams, fetch: AuthFetcher) => {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { createAgent } from '../agent'
|
||||
import { createAuthFetcher } from '../index'
|
||||
import { ModelConfig } from '../types'
|
||||
import { bearerMiddleware } from '../middlewares/bearer'
|
||||
import { AllowedActionModel, IdentityContextModel, ModelConfigModel } from '../models'
|
||||
import { AllowedActionModel, IdentityContextModel, ModelConfigModel, ScheduleModel } from '../models'
|
||||
import { allActions } from '../types'
|
||||
|
||||
const AgentModel = z.object({
|
||||
@@ -61,4 +61,21 @@ export const chatModule = new Elysia({ prefix: '/chat' })
|
||||
}, {
|
||||
body: AgentModel,
|
||||
})
|
||||
|
||||
.post('/trigger-schedule', async ({ body, bearer }) => {
|
||||
const authFetcher = createAuthFetcher(bearer)
|
||||
const { triggerSchedule } = createAgent({
|
||||
model: body.model as ModelConfig,
|
||||
activeContextTime: body.activeContextTime,
|
||||
platforms: body.platforms,
|
||||
currentPlatform: body.currentPlatform,
|
||||
allowedActions: body.allowedActions,
|
||||
}, authFetcher)
|
||||
return triggerSchedule({
|
||||
schedule: body.schedule,
|
||||
messages: body.messages,
|
||||
})
|
||||
}, {
|
||||
body: AgentModel.extend({
|
||||
schedule: ScheduleModel,
|
||||
}),
|
||||
})
|
||||
@@ -40,7 +40,7 @@ export interface AgentParams {
|
||||
activeContextTime?: number
|
||||
allowedActions?: AgentAction[]
|
||||
brave?: BraveConfig
|
||||
identity: IdentityContext
|
||||
identity?: IdentityContext
|
||||
platforms?: string[]
|
||||
currentPlatform?: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user