mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 10:29:02 +08:00
refactor(api): improve session messages path handling by returning object with base and withId
Simplify deleteSessionMessage implementation by using the new paths object structure
This commit is contained in:
parent
b82b16b5f6
commit
122e4a10d0
@ -75,8 +75,10 @@ export class AgentApiClient {
|
||||
withId: (id: string) => `/${this.apiVersion}/agents/${agentId}/sessions/${id}`
|
||||
})
|
||||
|
||||
public getSessionMessagesPath = (agentId: string, sessionId: string) =>
|
||||
`/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages`
|
||||
public getSessionMessagesPaths = (agentId: string, sessionId: string) => ({
|
||||
base: `/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages`,
|
||||
withId: (id: number) => `/${this.apiVersion}/agents/${agentId}/sessions/${sessionId}/messages/${id}`
|
||||
})
|
||||
|
||||
public getModelsPath = (props?: ApiModelsFilter) => {
|
||||
const base = `/${this.apiVersion}/models`
|
||||
@ -207,8 +209,7 @@ export class AgentApiClient {
|
||||
}
|
||||
|
||||
public async deleteSessionMessage(agentId: string, sessionId: string, messageId: number): Promise<void> {
|
||||
const base = this.getSessionMessagesPath(agentId, sessionId)
|
||||
const url = `${base}/${messageId}`
|
||||
const url = this.getSessionMessagesPaths(agentId, sessionId).withId(messageId)
|
||||
try {
|
||||
await this.axios.delete(url)
|
||||
} catch (error) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user