mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-07 13:59:28 +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,
|
GetAgentResponseSchema,
|
||||||
type ListAgentsResponse,
|
type ListAgentsResponse,
|
||||||
ListAgentsResponseSchema,
|
ListAgentsResponseSchema,
|
||||||
UpdateAgentRequest
|
UpdateAgentRequest,
|
||||||
|
UpdateAgentResponse,
|
||||||
|
UpdateAgentResponseSchema
|
||||||
} from '@types'
|
} from '@types'
|
||||||
import { Axios, AxiosRequestConfig, isAxiosError } from 'axios'
|
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}`
|
const url = `/${this.apiVersion}/agents/${id}`
|
||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
...agent
|
...agent
|
||||||
} satisfies UpdateAgentRequest
|
} 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) {
|
} catch (error) {
|
||||||
throw processError(error, 'Failed to updateAgent.')
|
throw processError(error, 'Failed to updateAgent.')
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user