|
@@ -4,11 +4,9 @@ import { attributionHeaders, LlmError } from '@deepseek-ai/dsh-llm'
|
|
|
import type { ImageMediaType } from '@deepseek-ai/dsh-attachment'
|
|
import type { ImageMediaType } from '@deepseek-ai/dsh-attachment'
|
|
|
import { DeepSeekFileId } from './file-id.ts'
|
|
import { DeepSeekFileId } from './file-id.ts'
|
|
|
import type { DeepSeekFileId as DeepSeekFileIdType } from './file-id.ts'
|
|
import type { DeepSeekFileId as DeepSeekFileIdType } from './file-id.ts'
|
|
|
|
|
+import { messagesApiRoot, MESSAGES_FILES_BETA } from './messages-api.ts'
|
|
|
import type { DeepSeekProtocol } from './types.ts'
|
|
import type { DeepSeekProtocol } from './types.ts'
|
|
|
|
|
|
|
|
-/** Required opt-in for Messages file operations and file-referenced image requests. */
|
|
|
|
|
-export const MESSAGES_FILES_BETA = 'files-api-2025-04-14'
|
|
|
|
|
-
|
|
|
|
|
/** Minimum provider-supported file lifetime. */
|
|
/** Minimum provider-supported file lifetime. */
|
|
|
export const MIN_FILE_EXPIRY_SECONDS = 3_600
|
|
export const MIN_FILE_EXPIRY_SECONDS = 3_600
|
|
|
/** Maximum provider-supported file lifetime. */
|
|
/** Maximum provider-supported file lifetime. */
|
|
@@ -155,11 +153,13 @@ export class DeepSeekFilesClient {
|
|
|
* @param options - endpoint, API-key snapshot, and optional test transport.
|
|
* @param options - endpoint, API-key snapshot, and optional test transport.
|
|
|
*/
|
|
*/
|
|
|
constructor(options: FilesApiOptions) {
|
|
constructor(options: FilesApiOptions) {
|
|
|
- this.baseURL = options.baseURL.replace(/\/+$/u, '')
|
|
|
|
|
this.apiKey = options.apiKey
|
|
this.apiKey = options.apiKey
|
|
|
this.fetchImpl = options.fetch ?? globalThis.fetch
|
|
this.fetchImpl = options.fetch ?? globalThis.fetch
|
|
|
this.protocol = options.protocol
|
|
this.protocol = options.protocol
|
|
|
- this.path = this.protocol === 'messages' ? '/v1/files' : '/files'
|
|
|
|
|
|
|
+ this.baseURL = this.protocol === 'messages'
|
|
|
|
|
+ ? messagesApiRoot(options.baseURL)
|
|
|
|
|
+ : options.baseURL.replace(/\/+$/u, '')
|
|
|
|
|
+ this.path = '/files'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private parseFile(value: unknown, operation: string): DeepSeekFileObject {
|
|
private parseFile(value: unknown, operation: string): DeepSeekFileObject {
|