(Feature) Vercel AI SDK (#2024)

This commit is contained in:
Saket Aryan
2024-11-19 23:53:58 +05:30
committed by GitHub
parent a02597ed59
commit 13374a12e9
70 changed files with 4074 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
import { withoutTrailingSlash } from '@ai-sdk/provider-utils'
import { Mem0ChatLanguageModel } from './mem0-chat-language-model'
import { Mem0ChatModelId, Mem0ChatSettings } from './mem0-chat-settings'
import { Mem0ProviderSettings } from './mem0-provider'
export class Mem0 {
readonly baseURL: string
readonly headers?: Record<string, string>
constructor(options: Mem0ProviderSettings = {
provider: 'openai',
}) {
this.baseURL =
withoutTrailingSlash(options.baseURL) ?? 'http://127.0.0.1:11434/api'
this.headers = options.headers
}
private get baseConfig() {
return {
baseURL: this.baseURL,
headers: () => ({
...this.headers,
}),
}
}
chat(modelId: Mem0ChatModelId, settings: Mem0ChatSettings = {}) {
return new Mem0ChatLanguageModel(modelId, settings, {
provider: 'openai',
...this.baseConfig,
})
}
}