mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-25 03:10:08 +08:00
feat(agent): return updated agent data from updateAgent method
Add response parsing and return type to updateAgent to provide updated agent data to callers
This commit is contained in:
parent
524098d6d3
commit
8d92b515ab
@ -9,7 +9,9 @@ import {
|
||||
GetAgentResponseSchema,
|
||||
type ListAgentsResponse,
|
||||
ListAgentsResponseSchema,
|
||||
UpdateAgentRequest
|
||||
UpdateAgentRequest,
|
||||
UpdateAgentResponse,
|
||||
UpdateAgentResponseSchema
|
||||
} from '@types'
|
||||
import { Axios, AxiosRequestConfig, isAxiosError } from 'axios'
|
||||
|
||||
@ -87,13 +89,15 @@ export class AgentApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
public async updateAgent(id: string, agent: Partial<AgentForm>): Promise<void> {
|
||||
public async updateAgent(id: string, agent: Partial<AgentForm>): Promise<UpdateAgentResponse> {
|
||||
const url = `/${this.apiVersion}/agents/${id}`
|
||||
try {
|
||||
const payload = {
|
||||
...agent
|
||||
} satisfies UpdateAgentRequest
|
||||
await this.axios.patch(url, payload)
|
||||
const response = await this.axios.patch(url, payload)
|
||||
const data = UpdateAgentResponseSchema.parse(response.data)
|
||||
return data
|
||||
} catch (error) {
|
||||
throw processError(error, 'Failed to updateAgent.')
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user