mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-07 02:58:11 +00:00
fix: ai-sdk config optional (#380)
This commit is contained in:
parent
da033f19ec
commit
0348291049
3 changed files with 14 additions and 14 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@supermemory/ai-sdk",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"scripts": {
|
||||
"build": "tsdown",
|
||||
"dev": "tsdown --watch",
|
||||
|
|
|
|||
|
|
@ -35,15 +35,15 @@ const providerMap = {
|
|||
|
||||
export const createSupermemoryInfiniteChat = (
|
||||
apiKey: SupermemoryApiKey,
|
||||
config: SupermemoryInfiniteChatConfig,
|
||||
config?: SupermemoryInfiniteChatConfig,
|
||||
) =>
|
||||
createOpenAI({
|
||||
apiKey: config.providerApiKey,
|
||||
baseURL: config.providerName
|
||||
apiKey: config?.providerApiKey,
|
||||
baseURL: config?.providerName
|
||||
? providerMap[config.providerName]
|
||||
: config.providerUrl,
|
||||
: config?.providerUrl,
|
||||
headers: {
|
||||
"x-supermemory-api-key": apiKey,
|
||||
...config.headers,
|
||||
...config?.headers,
|
||||
},
|
||||
}).chat
|
||||
|
|
|
|||
|
|
@ -17,16 +17,16 @@ export interface SupermemoryToolsConfig {
|
|||
*/
|
||||
export function supermemoryTools(
|
||||
apiKey: string,
|
||||
config: SupermemoryToolsConfig,
|
||||
config?: SupermemoryToolsConfig,
|
||||
) {
|
||||
const client = new Supermemory({
|
||||
apiKey,
|
||||
...(config.baseUrl && { baseURL: config.baseUrl }),
|
||||
...(config?.baseUrl && { baseURL: config.baseUrl }),
|
||||
})
|
||||
|
||||
const containerTags = config.projectId
|
||||
? [`sm_project_${config.projectId}`]
|
||||
: (config.containerTags ?? ["sm_project_default"])
|
||||
const containerTags = config?.projectId
|
||||
? [`sm_project_${config?.projectId}`]
|
||||
: (config?.containerTags ?? ["sm_project_default"])
|
||||
|
||||
const searchMemories = tool({
|
||||
description:
|
||||
|
|
@ -124,7 +124,7 @@ export function supermemoryTools(
|
|||
// Export individual tool creators for more flexibility
|
||||
export const searchMemoriesTool = (
|
||||
apiKey: string,
|
||||
config: SupermemoryToolsConfig,
|
||||
config?: SupermemoryToolsConfig,
|
||||
) => {
|
||||
const { searchMemories } = supermemoryTools(apiKey, config)
|
||||
return searchMemories
|
||||
|
|
@ -132,7 +132,7 @@ export const searchMemoriesTool = (
|
|||
|
||||
export const addMemoryTool = (
|
||||
apiKey: string,
|
||||
config: SupermemoryToolsConfig,
|
||||
config?: SupermemoryToolsConfig,
|
||||
) => {
|
||||
const { addMemory } = supermemoryTools(apiKey, config)
|
||||
return addMemory
|
||||
|
|
@ -140,7 +140,7 @@ export const addMemoryTool = (
|
|||
|
||||
export const fetchMemoryTool = (
|
||||
apiKey: string,
|
||||
config: SupermemoryToolsConfig,
|
||||
config?: SupermemoryToolsConfig,
|
||||
) => {
|
||||
const { fetchMemory } = supermemoryTools(apiKey, config)
|
||||
return fetchMemory
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue