@librechat/agents 2.4.67 → 2.4.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/utils/title.cjs
CHANGED
|
@@ -47,7 +47,7 @@ const createTitleRunnable = async (model, _titlePrompt) => {
|
|
|
47
47
|
},
|
|
48
48
|
});
|
|
49
49
|
};
|
|
50
|
-
const defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using
|
|
50
|
+
const defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using title case conventions. Only return the title itself.
|
|
51
51
|
|
|
52
52
|
Conversation:
|
|
53
53
|
{convo}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.cjs","sources":["../../../src/utils/title.ts"],"sourcesContent":["import { z } from 'zod';\nimport { RunnableLambda } from '@langchain/core/runnables';\nimport { ChatPromptTemplate } from '@langchain/core/prompts';\nimport type { Runnable, RunnableConfig } from '@langchain/core/runnables';\nimport type * as t from '@/types';\nimport { ContentTypes } from '@/common';\n\nconst defaultTitlePrompt = `Analyze this conversation and provide:\n1. The detected language of the conversation\n2. A concise title in the detected language (5 words or less, no punctuation or quotation)\n\n{convo}`;\n\nconst titleSchema = z.object({\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nconst combinedSchema = z.object({\n language: z.string().describe('The detected language of the conversation'),\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nexport const createTitleRunnable = async (\n model: t.ChatModelInstance,\n _titlePrompt?: string\n): Promise<Runnable> => {\n // Disabled since this works fine\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const titleLLM = model.withStructuredOutput(titleSchema);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const combinedLLM = model.withStructuredOutput(combinedSchema);\n\n const titlePrompt = ChatPromptTemplate.fromTemplate(\n _titlePrompt ?? defaultTitlePrompt\n );\n\n return new RunnableLambda({\n func: async (\n input: {\n convo: string;\n inputText: string;\n skipLanguage: boolean;\n },\n config?: Partial<RunnableConfig>\n ): Promise<{ language: string; title: string } | { title: string }> => {\n if (input.skipLanguage) {\n return (await titlePrompt.pipe(titleLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { title: string };\n }\n\n const result = (await titlePrompt.pipe(combinedLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { language: string; title: string } | undefined;\n\n return {\n language: result?.language ?? 'English',\n title: result?.title ?? '',\n };\n },\n });\n};\n\nconst defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using
|
|
1
|
+
{"version":3,"file":"title.cjs","sources":["../../../src/utils/title.ts"],"sourcesContent":["import { z } from 'zod';\nimport { RunnableLambda } from '@langchain/core/runnables';\nimport { ChatPromptTemplate } from '@langchain/core/prompts';\nimport type { Runnable, RunnableConfig } from '@langchain/core/runnables';\nimport type * as t from '@/types';\nimport { ContentTypes } from '@/common';\n\nconst defaultTitlePrompt = `Analyze this conversation and provide:\n1. The detected language of the conversation\n2. A concise title in the detected language (5 words or less, no punctuation or quotation)\n\n{convo}`;\n\nconst titleSchema = z.object({\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nconst combinedSchema = z.object({\n language: z.string().describe('The detected language of the conversation'),\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nexport const createTitleRunnable = async (\n model: t.ChatModelInstance,\n _titlePrompt?: string\n): Promise<Runnable> => {\n // Disabled since this works fine\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const titleLLM = model.withStructuredOutput(titleSchema);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const combinedLLM = model.withStructuredOutput(combinedSchema);\n\n const titlePrompt = ChatPromptTemplate.fromTemplate(\n _titlePrompt ?? defaultTitlePrompt\n );\n\n return new RunnableLambda({\n func: async (\n input: {\n convo: string;\n inputText: string;\n skipLanguage: boolean;\n },\n config?: Partial<RunnableConfig>\n ): Promise<{ language: string; title: string } | { title: string }> => {\n if (input.skipLanguage) {\n return (await titlePrompt.pipe(titleLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { title: string };\n }\n\n const result = (await titlePrompt.pipe(combinedLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { language: string; title: string } | undefined;\n\n return {\n language: result?.language ?? 'English',\n title: result?.title ?? '',\n };\n },\n });\n};\n\nconst defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using title case conventions. Only return the title itself.\n\nConversation:\n{convo}`;\n\nexport const createCompletionTitleRunnable = async (\n model: t.ChatModelInstance,\n titlePrompt?: string\n): Promise<Runnable> => {\n const completionPrompt = ChatPromptTemplate.fromTemplate(\n titlePrompt ?? defaultCompletionPrompt\n );\n\n return new RunnableLambda({\n func: async (\n input: {\n convo: string;\n inputText: string;\n skipLanguage: boolean;\n },\n config?: Partial<RunnableConfig>\n ): Promise<{ title: string }> => {\n const promptOutput = await completionPrompt.invoke({\n convo: input.convo,\n });\n\n const response = await model.invoke(promptOutput, config);\n let content = '';\n if (typeof response.content === 'string') {\n content = response.content;\n } else if (Array.isArray(response.content)) {\n content = response.content\n .filter(\n (part): part is { type: ContentTypes.TEXT; text: string } =>\n part.type === ContentTypes.TEXT\n )\n .map((part) => part.text)\n .join('');\n }\n const title = content.trim();\n return {\n title,\n };\n },\n });\n};\n"],"names":["z","ChatPromptTemplate","RunnableLambda","ContentTypes"],"mappings":";;;;;;;AAOA,MAAM,kBAAkB,GAAG,CAAA;;;;QAInB;AAER,MAAM,WAAW,GAAGA,KAAC,CAAC,MAAM,CAAC;AAC3B,IAAA,KAAK,EAAEA;AACJ,SAAA,MAAM;SACN,QAAQ,CACP,2FAA2F,CAC5F;AACJ,CAAA,CAAC;AAEF,M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AAI,uBAAuB,CACvC;IAED,OAAO,IAAIC,wBAAc,CAAC;AACxB,QAAA,IAAI,EAAE,OACJ,KAIC,EACD,MAAgC,KACF;AAC9B,YAAA,MAAM,YAAY,GAAG,MAAM,gBAAgB,CAAC,MAAM,CAAC;gBACjD,KAAK,EAAE,KAAK,CAAC,KAAK;AACnB,aAAA,CAAC;YAEF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC;YACzD,IAAI,OAAO,GAAG,EAAE;AAChB,YAAA,IAAI,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,EAAE;AACxC,gBAAA,OAAO,GAAG,QAAQ,CAAC,OAAO;;iBACrB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBAC1C,OAAO,GAAG,QAAQ,CAAC;AAChB,qBAAA,MAAM,CACL,CAAC,IAAI,KACH,IAAI,CAAC,IAAI,KAAKC,kBAAY,CAAC,IAAI;qBAElC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;qBACvB,IAAI,CAAC,EAAE,CAAC;;AAEb,YAAA,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE;YAC5B,OAAO;gBACL,KAAK;aACN;SACF;AACF,KAAA,CAAC;AACJ;;;;;"}
|
package/dist/esm/utils/title.mjs
CHANGED
|
@@ -45,7 +45,7 @@ const createTitleRunnable = async (model, _titlePrompt) => {
|
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
47
|
};
|
|
48
|
-
const defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using
|
|
48
|
+
const defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using title case conventions. Only return the title itself.
|
|
49
49
|
|
|
50
50
|
Conversation:
|
|
51
51
|
{convo}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.mjs","sources":["../../../src/utils/title.ts"],"sourcesContent":["import { z } from 'zod';\nimport { RunnableLambda } from '@langchain/core/runnables';\nimport { ChatPromptTemplate } from '@langchain/core/prompts';\nimport type { Runnable, RunnableConfig } from '@langchain/core/runnables';\nimport type * as t from '@/types';\nimport { ContentTypes } from '@/common';\n\nconst defaultTitlePrompt = `Analyze this conversation and provide:\n1. The detected language of the conversation\n2. A concise title in the detected language (5 words or less, no punctuation or quotation)\n\n{convo}`;\n\nconst titleSchema = z.object({\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nconst combinedSchema = z.object({\n language: z.string().describe('The detected language of the conversation'),\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nexport const createTitleRunnable = async (\n model: t.ChatModelInstance,\n _titlePrompt?: string\n): Promise<Runnable> => {\n // Disabled since this works fine\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const titleLLM = model.withStructuredOutput(titleSchema);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const combinedLLM = model.withStructuredOutput(combinedSchema);\n\n const titlePrompt = ChatPromptTemplate.fromTemplate(\n _titlePrompt ?? defaultTitlePrompt\n );\n\n return new RunnableLambda({\n func: async (\n input: {\n convo: string;\n inputText: string;\n skipLanguage: boolean;\n },\n config?: Partial<RunnableConfig>\n ): Promise<{ language: string; title: string } | { title: string }> => {\n if (input.skipLanguage) {\n return (await titlePrompt.pipe(titleLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { title: string };\n }\n\n const result = (await titlePrompt.pipe(combinedLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { language: string; title: string } | undefined;\n\n return {\n language: result?.language ?? 'English',\n title: result?.title ?? '',\n };\n },\n });\n};\n\nconst defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using
|
|
1
|
+
{"version":3,"file":"title.mjs","sources":["../../../src/utils/title.ts"],"sourcesContent":["import { z } from 'zod';\nimport { RunnableLambda } from '@langchain/core/runnables';\nimport { ChatPromptTemplate } from '@langchain/core/prompts';\nimport type { Runnable, RunnableConfig } from '@langchain/core/runnables';\nimport type * as t from '@/types';\nimport { ContentTypes } from '@/common';\n\nconst defaultTitlePrompt = `Analyze this conversation and provide:\n1. The detected language of the conversation\n2. A concise title in the detected language (5 words or less, no punctuation or quotation)\n\n{convo}`;\n\nconst titleSchema = z.object({\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nconst combinedSchema = z.object({\n language: z.string().describe('The detected language of the conversation'),\n title: z\n .string()\n .describe(\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation'\n ),\n});\n\nexport const createTitleRunnable = async (\n model: t.ChatModelInstance,\n _titlePrompt?: string\n): Promise<Runnable> => {\n // Disabled since this works fine\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const titleLLM = model.withStructuredOutput(titleSchema);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const combinedLLM = model.withStructuredOutput(combinedSchema);\n\n const titlePrompt = ChatPromptTemplate.fromTemplate(\n _titlePrompt ?? defaultTitlePrompt\n );\n\n return new RunnableLambda({\n func: async (\n input: {\n convo: string;\n inputText: string;\n skipLanguage: boolean;\n },\n config?: Partial<RunnableConfig>\n ): Promise<{ language: string; title: string } | { title: string }> => {\n if (input.skipLanguage) {\n return (await titlePrompt.pipe(titleLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { title: string };\n }\n\n const result = (await titlePrompt.pipe(combinedLLM).invoke(\n {\n convo: input.convo,\n },\n config\n )) as { language: string; title: string } | undefined;\n\n return {\n language: result?.language ?? 'English',\n title: result?.title ?? '',\n };\n },\n });\n};\n\nconst defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using title case conventions. Only return the title itself.\n\nConversation:\n{convo}`;\n\nexport const createCompletionTitleRunnable = async (\n model: t.ChatModelInstance,\n titlePrompt?: string\n): Promise<Runnable> => {\n const completionPrompt = ChatPromptTemplate.fromTemplate(\n titlePrompt ?? defaultCompletionPrompt\n );\n\n return new RunnableLambda({\n func: async (\n input: {\n convo: string;\n inputText: string;\n skipLanguage: boolean;\n },\n config?: Partial<RunnableConfig>\n ): Promise<{ title: string }> => {\n const promptOutput = await completionPrompt.invoke({\n convo: input.convo,\n });\n\n const response = await model.invoke(promptOutput, config);\n let content = '';\n if (typeof response.content === 'string') {\n content = response.content;\n } else if (Array.isArray(response.content)) {\n content = response.content\n .filter(\n (part): part is { type: ContentTypes.TEXT; text: string } =>\n part.type === ContentTypes.TEXT\n )\n .map((part) => part.text)\n .join('');\n }\n const title = content.trim();\n return {\n title,\n };\n },\n });\n};\n"],"names":[],"mappings":";;;;;AAOA,MAAM,kBAAkB,GAAG,CAAA;;;;QAInB;AAER,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;AAC3B,IAAA,KAAK,EAAE;AACJ,SAAA,MAAM;SACN,QAAQ,CACP,2FAA2F,CAC5F;AACJ,CAAA,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;AAC1E,IAAA,KAAK,EAAE;AACJ,SAAA,MAAM;SACN,QAAQ,CACP,2FAA2F,CAC5F;AACJ,CAAA,CAAC;AAEW,MAAA,mBAAmB,GAAG,OACjC,KAA0B,EAC1B,YAAqB,KACA;;;;IAIrB,MAAM,QAAQ,GAAG,KAAK,CAAC,oBAAoB,CAAC,WAAW,CAAC;;;IAGxD,MAAM,WAAW,GAAG,KAAK,CAAC,oBAAoB,CAAC,cAAc,CAAC;IAE9D,MAAM,WAAW,GAAG,kBAAkB,CAAC,YAAY,CACjD,YAAY,IAAI,kBAAkB,CACnC;IAED,OAAO,IAAI,cAAc,CAAC;AACxB,QAAA,IAAI,EAAE,OACJ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A,MAAM,CACL,CAAC,IAAI,KACH,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI;qBAElC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;qBACvB,IAAI,CAAC,EAAE,CAAC;;AAEb,YAAA,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE;YAC5B,OAAO;gBACL,KAAK;aACN;SACF;AACF,KAAA,CAAC;AACJ;;;;"}
|
package/package.json
CHANGED
package/src/utils/title.ts
CHANGED
|
@@ -77,7 +77,7 @@ export const createTitleRunnable = async (
|
|
|
77
77
|
});
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
const defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using
|
|
80
|
+
const defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using title case conventions. Only return the title itself.
|
|
81
81
|
|
|
82
82
|
Conversation:
|
|
83
83
|
{convo}`;
|