mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-29 05:51:26 +08:00
refactor(agent): replace interface with zod schema for message request
Add createMessage method to AgentApiClient to handle posting messages to sessions
This commit is contained in:
parent
1c19e529ac
commit
445528aff7
@ -7,6 +7,7 @@ import {
|
||||
CreateAgentResponse,
|
||||
CreateAgentResponseSchema,
|
||||
CreateSessionForm,
|
||||
CreateSessionMessageRequest,
|
||||
CreateSessionRequest,
|
||||
CreateSessionResponse,
|
||||
CreateSessionResponseSchema,
|
||||
@ -208,4 +209,14 @@ export class AgentApiClient {
|
||||
throw processError(error, 'Failed to update session.')
|
||||
}
|
||||
}
|
||||
|
||||
public async createMessage(agentId: string, sessionId: string, content: string): Promise<void> {
|
||||
const url = this.getSessionMessagesPath(agentId, sessionId)
|
||||
try {
|
||||
const payload = { content } satisfies CreateSessionMessageRequest
|
||||
await this.axios.post(url, payload)
|
||||
} catch (error) {
|
||||
throw processError(error, 'Failed to post message.')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -204,9 +204,7 @@ export const ListAgentSessionsResponseSchema = z.object({
|
||||
|
||||
export type ListAgentSessionsResponse = z.infer<typeof ListAgentSessionsResponseSchema>
|
||||
|
||||
export interface CreateSessionMessageRequest {
|
||||
content: string
|
||||
}
|
||||
export type CreateSessionMessageRequest = z.infer<typeof CreateSessionMessageRequestSchema>
|
||||
|
||||
export const CreateSessionResponseSchema = AgentSessionEntitySchema
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user