feat(integrations): declare which surface each client is, and its version (#7326)
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
declare const __MEM0_PROVIDER_VERSION__: string | undefined;
|
||||
|
||||
// Replaced at build time by tsup `define`. The fallback only applies when the
|
||||
// source is run unbundled, such as in tests.
|
||||
const PROVIDER_VERSION =
|
||||
typeof __MEM0_PROVIDER_VERSION__ !== "undefined" ? __MEM0_PROVIDER_VERSION__ : "dev";
|
||||
|
||||
import { LanguageModelV3Prompt } from '@ai-sdk/provider';
|
||||
import { Mem0ConfigSettings } from './mem0-types';
|
||||
import { loadApiKey } from '@ai-sdk/provider-utils';
|
||||
@@ -277,7 +284,11 @@ const searchInternalMemories = async (query: string, config?: Mem0ConfigSettings
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Token ${apiKey}`,
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
// Surface attribution. Set-once by contract: this wrapper is the
|
||||
// outermost layer on these raw fetch calls.
|
||||
'X-Mem0-Source': 'VERCEL_AI_SDK',
|
||||
'X-Mem0-Client': `mem0-vercel-ai-provider/${PROVIDER_VERSION}`
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
@@ -331,7 +342,11 @@ const updateMemories = async (messages: Array<Message>, config?: Mem0ConfigSetti
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Authorization: `Token ${apiKey}`,
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
// Surface attribution. Set-once by contract: this wrapper is the
|
||||
// outermost layer on these raw fetch calls.
|
||||
'X-Mem0-Source': 'VERCEL_AI_SDK',
|
||||
'X-Mem0-Client': `mem0-vercel-ai-provider/${PROVIDER_VERSION}`
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
};
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"preserveWatchOutput": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"types": ["@types/node", "jest"],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { defineConfig } from 'tsup'
|
||||
import pkg from './package.json'
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
@@ -6,5 +7,11 @@ export default defineConfig([
|
||||
entry: ['src/index.ts'],
|
||||
format: ['cjs', 'esm'],
|
||||
sourcemap: true,
|
||||
// Injected rather than written in the source. A hardcoded literal matches
|
||||
// package.json on the day it is written and misreports the client version
|
||||
// from the next release bump onwards. Same mechanism as mem0-ts.
|
||||
define: {
|
||||
__MEM0_PROVIDER_VERSION__: JSON.stringify(pkg.version),
|
||||
},
|
||||
},
|
||||
])
|
||||
Reference in New Issue
Block a user