@agenite/llm
Advanced tools
+10
-0
| # @agenite/llm | ||
| ## 0.4.0-alpha.0 | ||
| ### Minor Changes | ||
| - 71295a4: feat: introduce new agent architecture | ||
| ### Patch Changes | ||
| - 2cab817: bump packages and add deepseek example | ||
| ## 0.3.0 | ||
@@ -4,0 +14,0 @@ |
+14
-0
@@ -30,6 +30,20 @@ 'use strict'; | ||
| // src/messages/utils.ts | ||
| var userTextMessage = (message) => { | ||
| return { | ||
| role: "user", | ||
| content: [ | ||
| { | ||
| type: "text", | ||
| text: message | ||
| } | ||
| ] | ||
| }; | ||
| }; | ||
| exports.BaseLLMProvider = BaseLLMProvider; | ||
| exports.convertStringToMessages = convertStringToMessages; | ||
| exports.iterateFromMethods = iterateFromMethods; | ||
| exports.userTextMessage = userTextMessage; | ||
| //# sourceMappingURL=index.cjs.map | ||
| //# sourceMappingURL=index.cjs.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/utils.ts"],"names":[],"mappings":";;;AAYO,SAAS,wBACd,OACe,EAAA;AACf,EAAI,IAAA,OAAO,YAAY,QAAU,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL;AAAA,QACE,IAAM,EAAA,MAAA;AAAA,QACN,SAAS,CAAC,EAAE,MAAM,MAAQ,EAAA,IAAA,EAAM,SAAS;AAAA;AAC3C,KACF;AAAA;AAGF,EAAO,OAAA,OAAA;AACT;AAKA,gBAAuB,kBAAA,CACrB,QACA,EAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,EAAM,MAAA,EAAE,QAAW,GAAA,OAAA;AAEnB,EAAA,IAAI,MAAQ,EAAA;AAEV,IAAA,MAAM,SAAY,GAAA,QAAA,CAAS,MAAO,CAAA,KAAA,EAAO,OAAO,CAAA;AAEhD,IAAA,OAAO,OAAO,SAAA;AAAA,GACT,MAAA;AAEL,IAAA,OAAO,MAAM,QAAA,CAAS,QAAS,CAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEjD;AAKO,IAAe,kBAAf,MAAsD;AAAA,EAc3D,OAAO,OACL,CAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,IAAA,OAAO,OAAO,kBAAA,CAAmB,IAAM,EAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEzD","file":"index.cjs","sourcesContent":["import type {\n BaseMessage,\n GenerateOptions,\n IterateGenerateOptions,\n LLMProvider,\n GenerateResponse,\n PartialReturn,\n} from './types';\n\n/**\n * Converts a string message to BaseMessage array\n */\nexport function convertStringToMessages(\n message: string | BaseMessage[]\n): BaseMessage[] {\n if (typeof message === 'string') {\n return [\n {\n role: 'user',\n content: [{ type: 'text', text: message }],\n },\n ];\n }\n\n return message;\n}\n\n/**\n * Base implementation of iterate using generate and stream\n */\nexport async function* iterateFromMethods(\n provider: LLMProvider,\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n const { stream } = options;\n\n if (stream) {\n // For streaming, use the stream method and yield each chunk\n const streamGen = provider.stream(input, options);\n\n return yield* streamGen;\n } else {\n // For non-streaming, use generate and return the response\n return await provider.generate(input, options);\n }\n}\n\n/**\n * Base class for LLM providers that implements iterate using generate and stream\n */\nexport abstract class BaseLLMProvider implements LLMProvider {\n abstract name: string;\n abstract version?: string;\n\n abstract generate(\n input: string,\n options?: Partial<GenerateOptions>\n ): Promise<GenerateResponse>;\n\n abstract stream(\n input: string,\n options?: Partial<GenerateOptions>\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown>;\n\n async *iterate(\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n return yield* iterateFromMethods(this, input, options);\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/utils.ts","../src/messages/utils.ts"],"names":[],"mappings":";;;AAYO,SAAS,wBACd,OACe,EAAA;AACf,EAAI,IAAA,OAAO,YAAY,QAAU,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL;AAAA,QACE,IAAM,EAAA,MAAA;AAAA,QACN,SAAS,CAAC,EAAE,MAAM,MAAQ,EAAA,IAAA,EAAM,SAAS;AAAA;AAC3C,KACF;AAAA;AAGF,EAAO,OAAA,OAAA;AACT;AAKA,gBAAuB,kBAAA,CACrB,QACA,EAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,EAAM,MAAA,EAAE,QAAW,GAAA,OAAA;AAEnB,EAAA,IAAI,MAAQ,EAAA;AAEV,IAAA,MAAM,SAAY,GAAA,QAAA,CAAS,MAAO,CAAA,KAAA,EAAO,OAAO,CAAA;AAEhD,IAAA,OAAO,OAAO,SAAA;AAAA,GACT,MAAA;AAEL,IAAA,OAAO,MAAM,QAAA,CAAS,QAAS,CAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEjD;AAKO,IAAe,kBAAf,MAAsD;AAAA,EAc3D,OAAO,OACL,CAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,IAAA,OAAO,OAAO,kBAAA,CAAmB,IAAM,EAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEzD;;;ACrEa,IAAA,eAAA,GAAkB,CAAC,OAAiC,KAAA;AAC/D,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP;AAAA,QACE,IAAM,EAAA,MAAA;AAAA,QACN,IAAM,EAAA;AAAA;AACR;AACF,GACF;AACF","file":"index.cjs","sourcesContent":["import type {\n BaseMessage,\n GenerateOptions,\n IterateGenerateOptions,\n LLMProvider,\n GenerateResponse,\n PartialReturn,\n} from './types';\n\n/**\n * Converts a string message to BaseMessage array\n */\nexport function convertStringToMessages(\n message: string | BaseMessage[]\n): BaseMessage[] {\n if (typeof message === 'string') {\n return [\n {\n role: 'user',\n content: [{ type: 'text', text: message }],\n },\n ];\n }\n\n return message;\n}\n\n/**\n * Base implementation of iterate using generate and stream\n */\nexport async function* iterateFromMethods(\n provider: LLMProvider,\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n const { stream } = options;\n\n if (stream) {\n // For streaming, use the stream method and yield each chunk\n const streamGen = provider.stream(input, options);\n\n return yield* streamGen;\n } else {\n // For non-streaming, use generate and return the response\n return await provider.generate(input, options);\n }\n}\n\n/**\n * Base class for LLM providers that implements iterate using generate and stream\n */\nexport abstract class BaseLLMProvider implements LLMProvider {\n abstract name: string;\n abstract version?: string;\n\n abstract generate(\n input: string,\n options?: Partial<GenerateOptions>\n ): Promise<GenerateResponse>;\n\n abstract stream(\n input: string,\n options?: Partial<GenerateOptions>\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown>;\n\n async *iterate(\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n return yield* iterateFromMethods(this, input, options);\n }\n}\n","import { BaseMessage } from '../types';\n\nexport const userTextMessage = (message: string): BaseMessage => {\n return {\n role: 'user',\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n };\n};\n"]} |
+27
-7
| /** | ||
| * Content block types for rich message content | ||
| */ | ||
| type ContentBlock = TextBlock | ImageBlock | ToolUseBlock | ToolResultBlock | ReasoningBlock; | ||
| interface ReasoningBlock { | ||
| type: 'reasoning'; | ||
| reasoning: string; | ||
| type ContentBlock = TextBlock | ImageBlock | ToolUseBlock | ToolResultBlock | DocumentBlock | ThinkingBlock | RedactedThinkingBlock; | ||
| interface ThinkingBlock { | ||
| type: 'thinking'; | ||
| thinking: string; | ||
| [key: string]: unknown; | ||
| } | ||
| interface RedactedThinkingBlock { | ||
| type: 'redactedThinking'; | ||
| redactedThinking: string; | ||
| [key: string]: unknown; | ||
| } | ||
| interface DocumentBlock { | ||
| source: { | ||
| [key: string]: unknown; | ||
| }; | ||
| type: 'document'; | ||
| [key: string]: unknown; | ||
| } | ||
| interface TextBlock { | ||
| type: 'text'; | ||
| text: string; | ||
| [key: string]: unknown; | ||
| } | ||
@@ -20,3 +33,7 @@ interface ImageBlock { | ||
| data: string; | ||
| } | { | ||
| type: 'url'; | ||
| url: string; | ||
| }; | ||
| [key: string]: unknown; | ||
| } | ||
@@ -28,2 +45,3 @@ interface ToolUseBlock { | ||
| input: unknown; | ||
| [key: string]: unknown; | ||
| } | ||
@@ -84,4 +102,4 @@ interface ToolResultBlock { | ||
| } | { | ||
| type: 'reasoning'; | ||
| reasoning: string; | ||
| type: 'thinking'; | ||
| thinking: string; | ||
| isStart?: boolean; | ||
@@ -160,2 +178,4 @@ isEnd?: boolean; | ||
| export { type BaseLLMConfig, BaseLLMProvider, type BaseMessage, type ContentBlock, type GenerateOptions, type GenerateResponse, type ImageBlock, type IterateGenerateOptions, type LLMProvider, type PartialReturn, type ReasoningBlock, type Role, type StopReason, type TextBlock, type TokenUsage, type ToolDefinition, type ToolResultBlock, type ToolSchema, type ToolUseBlock, convertStringToMessages, iterateFromMethods }; | ||
| declare const userTextMessage: (message: string) => BaseMessage; | ||
| export { type BaseLLMConfig, BaseLLMProvider, type BaseMessage, type ContentBlock, type DocumentBlock, type GenerateOptions, type GenerateResponse, type ImageBlock, type IterateGenerateOptions, type LLMProvider, type PartialReturn, type RedactedThinkingBlock, type Role, type StopReason, type TextBlock, type ThinkingBlock, type TokenUsage, type ToolDefinition, type ToolResultBlock, type ToolSchema, type ToolUseBlock, convertStringToMessages, iterateFromMethods, userTextMessage }; |
+27
-7
| /** | ||
| * Content block types for rich message content | ||
| */ | ||
| type ContentBlock = TextBlock | ImageBlock | ToolUseBlock | ToolResultBlock | ReasoningBlock; | ||
| interface ReasoningBlock { | ||
| type: 'reasoning'; | ||
| reasoning: string; | ||
| type ContentBlock = TextBlock | ImageBlock | ToolUseBlock | ToolResultBlock | DocumentBlock | ThinkingBlock | RedactedThinkingBlock; | ||
| interface ThinkingBlock { | ||
| type: 'thinking'; | ||
| thinking: string; | ||
| [key: string]: unknown; | ||
| } | ||
| interface RedactedThinkingBlock { | ||
| type: 'redactedThinking'; | ||
| redactedThinking: string; | ||
| [key: string]: unknown; | ||
| } | ||
| interface DocumentBlock { | ||
| source: { | ||
| [key: string]: unknown; | ||
| }; | ||
| type: 'document'; | ||
| [key: string]: unknown; | ||
| } | ||
| interface TextBlock { | ||
| type: 'text'; | ||
| text: string; | ||
| [key: string]: unknown; | ||
| } | ||
@@ -20,3 +33,7 @@ interface ImageBlock { | ||
| data: string; | ||
| } | { | ||
| type: 'url'; | ||
| url: string; | ||
| }; | ||
| [key: string]: unknown; | ||
| } | ||
@@ -28,2 +45,3 @@ interface ToolUseBlock { | ||
| input: unknown; | ||
| [key: string]: unknown; | ||
| } | ||
@@ -84,4 +102,4 @@ interface ToolResultBlock { | ||
| } | { | ||
| type: 'reasoning'; | ||
| reasoning: string; | ||
| type: 'thinking'; | ||
| thinking: string; | ||
| isStart?: boolean; | ||
@@ -160,2 +178,4 @@ isEnd?: boolean; | ||
| export { type BaseLLMConfig, BaseLLMProvider, type BaseMessage, type ContentBlock, type GenerateOptions, type GenerateResponse, type ImageBlock, type IterateGenerateOptions, type LLMProvider, type PartialReturn, type ReasoningBlock, type Role, type StopReason, type TextBlock, type TokenUsage, type ToolDefinition, type ToolResultBlock, type ToolSchema, type ToolUseBlock, convertStringToMessages, iterateFromMethods }; | ||
| declare const userTextMessage: (message: string) => BaseMessage; | ||
| export { type BaseLLMConfig, BaseLLMProvider, type BaseMessage, type ContentBlock, type DocumentBlock, type GenerateOptions, type GenerateResponse, type ImageBlock, type IterateGenerateOptions, type LLMProvider, type PartialReturn, type RedactedThinkingBlock, type Role, type StopReason, type TextBlock, type ThinkingBlock, type TokenUsage, type ToolDefinition, type ToolResultBlock, type ToolSchema, type ToolUseBlock, convertStringToMessages, iterateFromMethods, userTextMessage }; |
+14
-1
@@ -28,4 +28,17 @@ // src/utils.ts | ||
| export { BaseLLMProvider, convertStringToMessages, iterateFromMethods }; | ||
| // src/messages/utils.ts | ||
| var userTextMessage = (message) => { | ||
| return { | ||
| role: "user", | ||
| content: [ | ||
| { | ||
| type: "text", | ||
| text: message | ||
| } | ||
| ] | ||
| }; | ||
| }; | ||
| export { BaseLLMProvider, convertStringToMessages, iterateFromMethods, userTextMessage }; | ||
| //# sourceMappingURL=index.js.map | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"sources":["../src/utils.ts"],"names":[],"mappings":";AAYO,SAAS,wBACd,OACe,EAAA;AACf,EAAI,IAAA,OAAO,YAAY,QAAU,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL;AAAA,QACE,IAAM,EAAA,MAAA;AAAA,QACN,SAAS,CAAC,EAAE,MAAM,MAAQ,EAAA,IAAA,EAAM,SAAS;AAAA;AAC3C,KACF;AAAA;AAGF,EAAO,OAAA,OAAA;AACT;AAKA,gBAAuB,kBAAA,CACrB,QACA,EAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,EAAM,MAAA,EAAE,QAAW,GAAA,OAAA;AAEnB,EAAA,IAAI,MAAQ,EAAA;AAEV,IAAA,MAAM,SAAY,GAAA,QAAA,CAAS,MAAO,CAAA,KAAA,EAAO,OAAO,CAAA;AAEhD,IAAA,OAAO,OAAO,SAAA;AAAA,GACT,MAAA;AAEL,IAAA,OAAO,MAAM,QAAA,CAAS,QAAS,CAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEjD;AAKO,IAAe,kBAAf,MAAsD;AAAA,EAc3D,OAAO,OACL,CAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,IAAA,OAAO,OAAO,kBAAA,CAAmB,IAAM,EAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEzD","file":"index.js","sourcesContent":["import type {\n BaseMessage,\n GenerateOptions,\n IterateGenerateOptions,\n LLMProvider,\n GenerateResponse,\n PartialReturn,\n} from './types';\n\n/**\n * Converts a string message to BaseMessage array\n */\nexport function convertStringToMessages(\n message: string | BaseMessage[]\n): BaseMessage[] {\n if (typeof message === 'string') {\n return [\n {\n role: 'user',\n content: [{ type: 'text', text: message }],\n },\n ];\n }\n\n return message;\n}\n\n/**\n * Base implementation of iterate using generate and stream\n */\nexport async function* iterateFromMethods(\n provider: LLMProvider,\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n const { stream } = options;\n\n if (stream) {\n // For streaming, use the stream method and yield each chunk\n const streamGen = provider.stream(input, options);\n\n return yield* streamGen;\n } else {\n // For non-streaming, use generate and return the response\n return await provider.generate(input, options);\n }\n}\n\n/**\n * Base class for LLM providers that implements iterate using generate and stream\n */\nexport abstract class BaseLLMProvider implements LLMProvider {\n abstract name: string;\n abstract version?: string;\n\n abstract generate(\n input: string,\n options?: Partial<GenerateOptions>\n ): Promise<GenerateResponse>;\n\n abstract stream(\n input: string,\n options?: Partial<GenerateOptions>\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown>;\n\n async *iterate(\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n return yield* iterateFromMethods(this, input, options);\n }\n}\n"]} | ||
| {"version":3,"sources":["../src/utils.ts","../src/messages/utils.ts"],"names":[],"mappings":";AAYO,SAAS,wBACd,OACe,EAAA;AACf,EAAI,IAAA,OAAO,YAAY,QAAU,EAAA;AAC/B,IAAO,OAAA;AAAA,MACL;AAAA,QACE,IAAM,EAAA,MAAA;AAAA,QACN,SAAS,CAAC,EAAE,MAAM,MAAQ,EAAA,IAAA,EAAM,SAAS;AAAA;AAC3C,KACF;AAAA;AAGF,EAAO,OAAA,OAAA;AACT;AAKA,gBAAuB,kBAAA,CACrB,QACA,EAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,EAAM,MAAA,EAAE,QAAW,GAAA,OAAA;AAEnB,EAAA,IAAI,MAAQ,EAAA;AAEV,IAAA,MAAM,SAAY,GAAA,QAAA,CAAS,MAAO,CAAA,KAAA,EAAO,OAAO,CAAA;AAEhD,IAAA,OAAO,OAAO,SAAA;AAAA,GACT,MAAA;AAEL,IAAA,OAAO,MAAM,QAAA,CAAS,QAAS,CAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEjD;AAKO,IAAe,kBAAf,MAAsD;AAAA,EAc3D,OAAO,OACL,CAAA,KAAA,EACA,OAC0D,EAAA;AAC1D,IAAA,OAAO,OAAO,kBAAA,CAAmB,IAAM,EAAA,KAAA,EAAO,OAAO,CAAA;AAAA;AAEzD;;;ACrEa,IAAA,eAAA,GAAkB,CAAC,OAAiC,KAAA;AAC/D,EAAO,OAAA;AAAA,IACL,IAAM,EAAA,MAAA;AAAA,IACN,OAAS,EAAA;AAAA,MACP;AAAA,QACE,IAAM,EAAA,MAAA;AAAA,QACN,IAAM,EAAA;AAAA;AACR;AACF,GACF;AACF","file":"index.js","sourcesContent":["import type {\n BaseMessage,\n GenerateOptions,\n IterateGenerateOptions,\n LLMProvider,\n GenerateResponse,\n PartialReturn,\n} from './types';\n\n/**\n * Converts a string message to BaseMessage array\n */\nexport function convertStringToMessages(\n message: string | BaseMessage[]\n): BaseMessage[] {\n if (typeof message === 'string') {\n return [\n {\n role: 'user',\n content: [{ type: 'text', text: message }],\n },\n ];\n }\n\n return message;\n}\n\n/**\n * Base implementation of iterate using generate and stream\n */\nexport async function* iterateFromMethods(\n provider: LLMProvider,\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n const { stream } = options;\n\n if (stream) {\n // For streaming, use the stream method and yield each chunk\n const streamGen = provider.stream(input, options);\n\n return yield* streamGen;\n } else {\n // For non-streaming, use generate and return the response\n return await provider.generate(input, options);\n }\n}\n\n/**\n * Base class for LLM providers that implements iterate using generate and stream\n */\nexport abstract class BaseLLMProvider implements LLMProvider {\n abstract name: string;\n abstract version?: string;\n\n abstract generate(\n input: string,\n options?: Partial<GenerateOptions>\n ): Promise<GenerateResponse>;\n\n abstract stream(\n input: string,\n options?: Partial<GenerateOptions>\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown>;\n\n async *iterate(\n input: string | BaseMessage[],\n options: IterateGenerateOptions\n ): AsyncGenerator<PartialReturn, GenerateResponse, unknown> {\n return yield* iterateFromMethods(this, input, options);\n }\n}\n","import { BaseMessage } from '../types';\n\nexport const userTextMessage = (message: string): BaseMessage => {\n return {\n role: 'user',\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n };\n};\n"]} |
+6
-6
| { | ||
| "name": "@agenite/llm", | ||
| "version": "0.3.0", | ||
| "version": "0.4.0-alpha.0", | ||
| "description": "LLM interface for Agenite", | ||
@@ -18,8 +18,8 @@ "private": false, | ||
| "devDependencies": { | ||
| "@types/node": "^20.17.19", | ||
| "tsup": "^8.3.6", | ||
| "typescript": "^5.7.3", | ||
| "@repo/eslint-config": "0.0.4", | ||
| "@types/node": "^20.17.24", | ||
| "tsup": "^8.4.0", | ||
| "typescript": "^5.8.2", | ||
| "@repo/eslint-config": "0.1.0-alpha.0", | ||
| "@repo/tsup-config": "0.0.3", | ||
| "@repo/typescript-config": "0.0.1" | ||
| "@repo/typescript-config": "0.1.0-alpha.0" | ||
| }, | ||
@@ -26,0 +26,0 @@ "publishConfig": { |
21670
13.75%259
20.47%