@mate-academy/llm-gateway 8.8.2 → 8.8.3
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/LLMError.d.ts +12 -0
- package/dist/LLMError.js +36 -0
- package/dist/LLMError.js.map +1 -0
- package/dist/LLMGateway.d.ts +30 -0
- package/dist/LLMGateway.js +56 -0
- package/dist/LLMGateway.js.map +1 -0
- package/dist/LLMGateway.typedefs.d.ts +5 -0
- package/dist/LLMGateway.typedefs.js +3 -0
- package/dist/LLMGateway.typedefs.js.map +1 -0
- package/dist/LLMService.constants.d.ts +26309 -0
- package/dist/LLMService.constants.js +35 -0
- package/dist/LLMService.constants.js.map +1 -0
- package/dist/LLMService.factory.d.ts +71 -0
- package/dist/LLMService.factory.js +102 -0
- package/dist/LLMService.factory.js.map +1 -0
- package/dist/LLMService.typedefs.d.ts +655 -0
- package/dist/LLMService.typedefs.js +72 -0
- package/dist/LLMService.typedefs.js.map +1 -0
- package/dist/advanced.d.ts +11 -0
- package/dist/advanced.js +32 -0
- package/dist/advanced.js.map +1 -0
- package/dist/client/LLMAgent.d.ts +76 -0
- package/dist/client/LLMAgent.js +36 -0
- package/dist/client/LLMAgent.js.map +1 -0
- package/dist/client/LLMClientEngine.d.ts +110 -0
- package/dist/client/LLMClientEngine.js +406 -0
- package/dist/client/LLMClientEngine.js.map +1 -0
- package/dist/client/agentRun.typedefs.d.ts +200 -0
- package/dist/client/agentRun.typedefs.js +25 -0
- package/dist/client/agentRun.typedefs.js.map +1 -0
- package/dist/client/agentRunner.d.ts +161 -0
- package/dist/client/agentRunner.js +517 -0
- package/dist/client/agentRunner.js.map +1 -0
- package/dist/client/codegen/fetchPromptRecords.d.ts +14 -0
- package/dist/client/codegen/fetchPromptRecords.js +90 -0
- package/dist/client/codegen/fetchPromptRecords.js.map +1 -0
- package/dist/client/codegen/generateSnapshot.d.ts +19 -0
- package/dist/client/codegen/generateSnapshot.js +28 -0
- package/dist/client/codegen/generateSnapshot.js.map +1 -0
- package/dist/client/codegen/index.d.ts +6 -0
- package/dist/client/codegen/index.js +23 -0
- package/dist/client/codegen/index.js.map +1 -0
- package/dist/client/codegen/promptCatalog.typedefs.d.ts +51 -0
- package/dist/client/codegen/promptCatalog.typedefs.js +3 -0
- package/dist/client/codegen/promptCatalog.typedefs.js.map +1 -0
- package/dist/client/codegen/promptName.d.ts +8 -0
- package/dist/client/codegen/promptName.js +21 -0
- package/dist/client/codegen/promptName.js.map +1 -0
- package/dist/client/codegen/renderSnapshot.constants.d.ts +7 -0
- package/dist/client/codegen/renderSnapshot.constants.js +16 -0
- package/dist/client/codegen/renderSnapshot.constants.js.map +1 -0
- package/dist/client/codegen/renderSnapshot.d.ts +9 -0
- package/dist/client/codegen/renderSnapshot.js +109 -0
- package/dist/client/codegen/renderSnapshot.js.map +1 -0
- package/dist/client/codegen/renderSnapshot.typedefs.d.ts +19 -0
- package/dist/client/codegen/renderSnapshot.typedefs.js +3 -0
- package/dist/client/codegen/renderSnapshot.typedefs.js.map +1 -0
- package/dist/client/coerceToolResult.d.ts +10 -0
- package/dist/client/coerceToolResult.js +38 -0
- package/dist/client/coerceToolResult.js.map +1 -0
- package/dist/client/createLLMClient.d.ts +10 -0
- package/dist/client/createLLMClient.js +47 -0
- package/dist/client/createLLMClient.js.map +1 -0
- package/dist/client/defineLLMPrompts.d.ts +34 -0
- package/dist/client/defineLLMPrompts.js +13 -0
- package/dist/client/defineLLMPrompts.js.map +1 -0
- package/dist/client/errors.d.ts +57 -0
- package/dist/client/errors.js +70 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/index.d.ts +13 -0
- package/dist/client/index.js +30 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/llmClient.typedefs.d.ts +265 -0
- package/dist/client/llmClient.typedefs.js +11 -0
- package/dist/client/llmClient.typedefs.js.map +1 -0
- package/dist/client/llmConfig.schema.d.ts +53 -0
- package/dist/client/llmConfig.schema.js +49 -0
- package/dist/client/llmConfig.schema.js.map +1 -0
- package/dist/client/plainMessages.d.ts +12 -0
- package/dist/client/plainMessages.js +19 -0
- package/dist/client/plainMessages.js.map +1 -0
- package/dist/client/promptClientPort.typedefs.d.ts +60 -0
- package/dist/client/promptClientPort.typedefs.js +3 -0
- package/dist/client/promptClientPort.typedefs.js.map +1 -0
- package/dist/client/promptRegistry.runtime.d.ts +121 -0
- package/dist/client/promptRegistry.runtime.js +264 -0
- package/dist/client/promptRegistry.runtime.js.map +1 -0
- package/dist/client/promptSnapshot.typedefs.d.ts +55 -0
- package/dist/client/promptSnapshot.typedefs.js +3 -0
- package/dist/client/promptSnapshot.typedefs.js.map +1 -0
- package/dist/client/promptVariables.d.ts +7 -0
- package/dist/client/promptVariables.js +13 -0
- package/dist/client/promptVariables.js.map +1 -0
- package/dist/client/snapshotRuntime.d.ts +17 -0
- package/dist/client/snapshotRuntime.js +42 -0
- package/dist/client/snapshotRuntime.js.map +1 -0
- package/dist/client/snapshotRuntime.typedefs.d.ts +13 -0
- package/dist/client/snapshotRuntime.typedefs.js +3 -0
- package/dist/client/snapshotRuntime.typedefs.js.map +1 -0
- package/dist/client/validationGate.d.ts +24 -0
- package/dist/client/validationGate.js +54 -0
- package/dist/client/validationGate.js.map +1 -0
- package/dist/codegen.d.ts +6 -0
- package/dist/codegen.js +23 -0
- package/dist/codegen.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.d.ts +873 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js +269 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.constants.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.d.ts +24 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js +210 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.entity.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.d.ts +22 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.js +20 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAI.typedefs.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.d.ts +6 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.js +18 -0
- package/dist/providers/GoogleGenerativeAI/GoogleGenerativeAIService.factory.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/index.d.ts +5 -0
- package/dist/providers/GoogleGenerativeAI/index.js +22 -0
- package/dist/providers/GoogleGenerativeAI/index.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter.d.ts +12 -0
- package/dist/providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter.js +72 -0
- package/dist/providers/GoogleGenerativeAI/schemas/GoogleSchemaAdapter.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.d.ts +71 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js +876 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAIAssistance.service.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.d.ts +25 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js +216 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAICompletion.service.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.d.ts +10 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js +136 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAISpeechToText.service.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.d.ts +11 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.js +97 -0
- package/dist/providers/GoogleGenerativeAI/services/GoogleGenerativeAITextToSpeech.service.js.map +1 -0
- package/dist/providers/GoogleGenerativeAI/services/index.d.ts +4 -0
- package/dist/providers/GoogleGenerativeAI/services/index.js +21 -0
- package/dist/providers/GoogleGenerativeAI/services/index.js.map +1 -0
- package/dist/providers/LLMAPI/LLMAPI.constants.d.ts +35832 -0
- package/dist/providers/LLMAPI/LLMAPI.constants.js +8601 -0
- package/dist/providers/LLMAPI/LLMAPI.constants.js.map +1 -0
- package/dist/providers/LLMAPI/LLMAPI.entity.d.ts +6 -0
- package/dist/providers/LLMAPI/LLMAPI.entity.js +48 -0
- package/dist/providers/LLMAPI/LLMAPI.entity.js.map +1 -0
- package/dist/providers/LLMAPI/LLMAPI.typedefs.d.ts +516 -0
- package/dist/providers/LLMAPI/LLMAPI.typedefs.js +564 -0
- package/dist/providers/LLMAPI/LLMAPI.typedefs.js.map +1 -0
- package/dist/providers/LLMAPI/LLMAPI.voices.d.ts +376 -0
- package/dist/providers/LLMAPI/LLMAPI.voices.js +739 -0
- package/dist/providers/LLMAPI/LLMAPI.voices.js.map +1 -0
- package/dist/providers/LLMAPI/LLMAPIService.factory.d.ts +6 -0
- package/dist/providers/LLMAPI/LLMAPIService.factory.js +19 -0
- package/dist/providers/LLMAPI/LLMAPIService.factory.js.map +1 -0
- package/dist/providers/LLMAPI/index.d.ts +7 -0
- package/dist/providers/LLMAPI/index.js +24 -0
- package/dist/providers/LLMAPI/index.js.map +1 -0
- package/dist/providers/LLMAPI/schemas/LLMAPISchemaAdapter.d.ts +3 -0
- package/dist/providers/LLMAPI/schemas/LLMAPISchemaAdapter.js +8 -0
- package/dist/providers/LLMAPI/schemas/LLMAPISchemaAdapter.js.map +1 -0
- package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.d.ts +76 -0
- package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js +825 -0
- package/dist/providers/LLMAPI/services/LLMAPIAssistance.service.js.map +1 -0
- package/dist/providers/LLMAPI/services/LLMAPICompletion.service.d.ts +25 -0
- package/dist/providers/LLMAPI/services/LLMAPICompletion.service.js +177 -0
- package/dist/providers/LLMAPI/services/LLMAPICompletion.service.js.map +1 -0
- package/dist/providers/LLMAPI/services/LLMAPISpeechToText.service.d.ts +17 -0
- package/dist/providers/LLMAPI/services/LLMAPISpeechToText.service.js +34 -0
- package/dist/providers/LLMAPI/services/LLMAPISpeechToText.service.js.map +1 -0
- package/dist/providers/LLMAPI/services/LLMAPITextToSpeech.service.d.ts +20 -0
- package/dist/providers/LLMAPI/services/LLMAPITextToSpeech.service.js +36 -0
- package/dist/providers/LLMAPI/services/LLMAPITextToSpeech.service.js.map +1 -0
- package/dist/providers/LLMAPI/services/index.d.ts +4 -0
- package/dist/providers/LLMAPI/services/index.js +21 -0
- package/dist/providers/LLMAPI/services/index.js.map +1 -0
- package/dist/providers/LLMAPI/utilities/index.d.ts +4 -0
- package/dist/providers/LLMAPI/utilities/index.js +13 -0
- package/dist/providers/LLMAPI/utilities/index.js.map +1 -0
- package/dist/providers/LLMAPI/utilities/parseXmlToolCalls.d.ts +7 -0
- package/dist/providers/LLMAPI/utilities/parseXmlToolCalls.js +35 -0
- package/dist/providers/LLMAPI/utilities/parseXmlToolCalls.js.map +1 -0
- package/dist/providers/LLMAPI/utilities/stripThinkingTags.d.ts +1 -0
- package/dist/providers/LLMAPI/utilities/stripThinkingTags.js +7 -0
- package/dist/providers/LLMAPI/utilities/stripThinkingTags.js.map +1 -0
- package/dist/providers/LLMAPI/utilities/structuredOutput.d.ts +13 -0
- package/dist/providers/LLMAPI/utilities/structuredOutput.js +29 -0
- package/dist/providers/LLMAPI/utilities/structuredOutput.js.map +1 -0
- package/dist/providers/LLMAPI/utilities/validateStructuredResponse.d.ts +10 -0
- package/dist/providers/LLMAPI/utilities/validateStructuredResponse.js +21 -0
- package/dist/providers/LLMAPI/utilities/validateStructuredResponse.js.map +1 -0
- package/dist/providers/OpenAI/OpenAI.constants.d.ts +1664 -0
- package/dist/providers/OpenAI/OpenAI.constants.js +310 -0
- package/dist/providers/OpenAI/OpenAI.constants.js.map +1 -0
- package/dist/providers/OpenAI/OpenAI.entity.d.ts +15 -0
- package/dist/providers/OpenAI/OpenAI.entity.js +162 -0
- package/dist/providers/OpenAI/OpenAI.entity.js.map +1 -0
- package/dist/providers/OpenAI/OpenAI.typedefs.d.ts +61 -0
- package/dist/providers/OpenAI/OpenAI.typedefs.js +39 -0
- package/dist/providers/OpenAI/OpenAI.typedefs.js.map +1 -0
- package/dist/providers/OpenAI/OpenAIService.factory.d.ts +6 -0
- package/dist/providers/OpenAI/OpenAIService.factory.js +18 -0
- package/dist/providers/OpenAI/OpenAIService.factory.js.map +1 -0
- package/dist/providers/OpenAI/index.d.ts +5 -0
- package/dist/providers/OpenAI/index.js +22 -0
- package/dist/providers/OpenAI/index.js.map +1 -0
- package/dist/providers/OpenAI/schemas/OpenAISchemaAdapter.d.ts +14 -0
- package/dist/providers/OpenAI/schemas/OpenAISchemaAdapter.js +87 -0
- package/dist/providers/OpenAI/schemas/OpenAISchemaAdapter.js.map +1 -0
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.d.ts +42 -0
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.js +712 -0
- package/dist/providers/OpenAI/services/OpenAIAssistance.service.js.map +1 -0
- package/dist/providers/OpenAI/services/OpenAICompletion.service.d.ts +7 -0
- package/dist/providers/OpenAI/services/OpenAICompletion.service.js +12 -0
- package/dist/providers/OpenAI/services/OpenAICompletion.service.js.map +1 -0
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.d.ts +17 -0
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js +40 -0
- package/dist/providers/OpenAI/services/OpenAISpeechToText.service.js.map +1 -0
- package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.d.ts +13 -0
- package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.js +32 -0
- package/dist/providers/OpenAI/services/OpenAITextToSpeech.service.js.map +1 -0
- package/dist/providers/OpenAI/services/buildFunctionCallOutput.d.ts +3 -0
- package/dist/providers/OpenAI/services/buildFunctionCallOutput.js +19 -0
- package/dist/providers/OpenAI/services/buildFunctionCallOutput.js.map +1 -0
- package/dist/providers/OpenAI/services/index.d.ts +4 -0
- package/dist/providers/OpenAI/services/index.js +21 -0
- package/dist/providers/OpenAI/services/index.js.map +1 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.d.ts +30 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.js +233 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleCompletion.service.js.map +1 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.d.ts +22 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.js +98 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleSpeechToText.service.js.map +1 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleTextToSpeech.service.d.ts +22 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleTextToSpeech.service.js +67 -0
- package/dist/providers/OpenAICompatible/OpenAICompatibleTextToSpeech.service.js.map +1 -0
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.js +20 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/services/LLMAssistanceService.abstract.d.ts +39 -0
- package/dist/services/LLMAssistanceService.abstract.js +101 -0
- package/dist/services/LLMAssistanceService.abstract.js.map +1 -0
- package/dist/services/LLMBaseService.abstract.d.ts +161 -0
- package/dist/services/LLMBaseService.abstract.js +392 -0
- package/dist/services/LLMBaseService.abstract.js.map +1 -0
- package/dist/services/LLMCompletionService.abstract.d.ts +16 -0
- package/dist/services/LLMCompletionService.abstract.js +12 -0
- package/dist/services/LLMCompletionService.abstract.js.map +1 -0
- package/dist/services/LLMServicePurposeFactory.abstract.d.ts +12 -0
- package/dist/services/LLMServicePurposeFactory.abstract.js +7 -0
- package/dist/services/LLMServicePurposeFactory.abstract.js.map +1 -0
- package/dist/services/LLMSpeechToTextService.abstract.d.ts +8 -0
- package/dist/services/LLMSpeechToTextService.abstract.js +12 -0
- package/dist/services/LLMSpeechToTextService.abstract.js.map +1 -0
- package/dist/services/LLMTextToSpeechService.abstract.d.ts +8 -0
- package/dist/services/LLMTextToSpeechService.abstract.js +12 -0
- package/dist/services/LLMTextToSpeechService.abstract.js.map +1 -0
- package/dist/services/agentRounds/LLMAgentRounds.d.ts +32 -0
- package/dist/services/agentRounds/LLMAgentRounds.js +77 -0
- package/dist/services/agentRounds/LLMAgentRounds.js.map +1 -0
- package/dist/services/agentRounds/agentRounds.typedefs.d.ts +48 -0
- package/dist/services/agentRounds/agentRounds.typedefs.js +3 -0
- package/dist/services/agentRounds/agentRounds.typedefs.js.map +1 -0
- package/dist/services/agentRounds/index.d.ts +2 -0
- package/dist/services/agentRounds/index.js +19 -0
- package/dist/services/agentRounds/index.js.map +1 -0
- package/dist/services/chatState/CompletionsChatState.d.ts +35 -0
- package/dist/services/chatState/CompletionsChatState.js +118 -0
- package/dist/services/chatState/CompletionsChatState.js.map +1 -0
- package/dist/services/chatState/index.d.ts +1 -0
- package/dist/services/chatState/index.js +6 -0
- package/dist/services/chatState/index.js.map +1 -0
- package/dist/services/fileStorage/FileStorageToolExecutor.d.ts +15 -0
- package/dist/services/fileStorage/FileStorageToolExecutor.js +172 -0
- package/dist/services/fileStorage/FileStorageToolExecutor.js.map +1 -0
- package/dist/services/fileStorage/InMemoryFileStorage.d.ts +20 -0
- package/dist/services/fileStorage/InMemoryFileStorage.js +67 -0
- package/dist/services/fileStorage/InMemoryFileStorage.js.map +1 -0
- package/dist/services/fileStorage/fileStorageTools.d.ts +26 -0
- package/dist/services/fileStorage/fileStorageTools.js +68 -0
- package/dist/services/fileStorage/fileStorageTools.js.map +1 -0
- package/dist/services/fileStorage/index.d.ts +4 -0
- package/dist/services/fileStorage/index.js +11 -0
- package/dist/services/fileStorage/index.js.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.js +24 -0
- package/dist/services/index.js.map +1 -0
- package/dist/utilities/calculateCosts.d.ts +4 -0
- package/dist/utilities/calculateCosts.js +56 -0
- package/dist/utilities/calculateCosts.js.map +1 -0
- package/dist/utilities/functional.utils.d.ts +1 -0
- package/dist/utilities/functional.utils.js +9 -0
- package/dist/utilities/functional.utils.js.map +1 -0
- package/dist/utilities/index.d.ts +9 -0
- package/dist/utilities/index.js +26 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/llmTracing/index.d.ts +3 -0
- package/dist/utilities/llmTracing/index.js +20 -0
- package/dist/utilities/llmTracing/index.js.map +1 -0
- package/dist/utilities/llmTracing/llmTracing.constants.d.ts +7 -0
- package/dist/utilities/llmTracing/llmTracing.constants.js +11 -0
- package/dist/utilities/llmTracing/llmTracing.constants.js.map +1 -0
- package/dist/utilities/llmTracing/llmTracing.typedefs.d.ts +126 -0
- package/dist/utilities/llmTracing/llmTracing.typedefs.js +3 -0
- package/dist/utilities/llmTracing/llmTracing.typedefs.js.map +1 -0
- package/dist/utilities/llmTracing/noopLLMTracing.d.ts +3 -0
- package/dist/utilities/llmTracing/noopLLMTracing.js +36 -0
- package/dist/utilities/llmTracing/noopLLMTracing.js.map +1 -0
- package/dist/utilities/logger/LLMLoggerInterface.d.ts +36 -0
- package/dist/utilities/logger/LLMLoggerInterface.js +3 -0
- package/dist/utilities/logger/LLMLoggerInterface.js.map +1 -0
- package/dist/utilities/logger/index.d.ts +1 -0
- package/dist/utilities/logger/index.js +18 -0
- package/dist/utilities/logger/index.js.map +1 -0
- package/dist/utilities/promptBuilder.d.ts +58 -0
- package/dist/utilities/promptBuilder.js +92 -0
- package/dist/utilities/promptBuilder.js.map +1 -0
- package/dist/utilities/reporter/LLMReporterInterface.d.ts +46 -0
- package/dist/utilities/reporter/LLMReporterInterface.js +3 -0
- package/dist/utilities/reporter/LLMReporterInterface.js.map +1 -0
- package/dist/utilities/reporter/index.d.ts +1 -0
- package/dist/utilities/reporter/index.js +18 -0
- package/dist/utilities/reporter/index.js.map +1 -0
- package/dist/utilities/schema/LLMSchema.d.ts +112 -0
- package/dist/utilities/schema/LLMSchema.js +223 -0
- package/dist/utilities/schema/LLMSchema.js.map +1 -0
- package/dist/utilities/schema/LLMSchema.typedefs.d.ts +55 -0
- package/dist/utilities/schema/LLMSchema.typedefs.js +3 -0
- package/dist/utilities/schema/LLMSchema.typedefs.js.map +1 -0
- package/dist/utilities/schema/SchemaAdapterRegistry.d.ts +26 -0
- package/dist/utilities/schema/SchemaAdapterRegistry.js +32 -0
- package/dist/utilities/schema/SchemaAdapterRegistry.js.map +1 -0
- package/dist/utilities/schema/index.d.ts +2 -0
- package/dist/utilities/schema/index.js +19 -0
- package/dist/utilities/schema/index.js.map +1 -0
- package/dist/utilities/serializeError.d.ts +9 -0
- package/dist/utilities/serializeError.js +69 -0
- package/dist/utilities/serializeError.js.map +1 -0
- package/dist/utilities/tokenizer.d.ts +4 -0
- package/dist/utilities/tokenizer.js +14 -0
- package/dist/utilities/tokenizer.js.map +1 -0
- package/dist/utilities/tools/LLMTool.d.ts +5 -0
- package/dist/utilities/tools/LLMTool.js +10 -0
- package/dist/utilities/tools/LLMTool.js.map +1 -0
- package/dist/utilities/tools/index.d.ts +2 -0
- package/dist/utilities/tools/index.js +8 -0
- package/dist/utilities/tools/index.js.map +1 -0
- package/dist/utilities/tools/normalizeToolResult.d.ts +15 -0
- package/dist/utilities/tools/normalizeToolResult.js +18 -0
- package/dist/utilities/tools/normalizeToolResult.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { InMemoryFileStorage } from './InMemoryFileStorage';
|
|
2
|
+
export { FileStorageToolExecutor } from './FileStorageToolExecutor';
|
|
3
|
+
export { getFileStorageToolsForChatCompletions, FileStorageToolName, } from './fileStorageTools';
|
|
4
|
+
export type { SearchFilesArgs, ReadFileArgs, ReadFileLinesArgs, } from './fileStorageTools';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileStorageToolName = exports.getFileStorageToolsForChatCompletions = exports.FileStorageToolExecutor = exports.InMemoryFileStorage = void 0;
|
|
4
|
+
var InMemoryFileStorage_1 = require("./InMemoryFileStorage");
|
|
5
|
+
Object.defineProperty(exports, "InMemoryFileStorage", { enumerable: true, get: function () { return InMemoryFileStorage_1.InMemoryFileStorage; } });
|
|
6
|
+
var FileStorageToolExecutor_1 = require("./FileStorageToolExecutor");
|
|
7
|
+
Object.defineProperty(exports, "FileStorageToolExecutor", { enumerable: true, get: function () { return FileStorageToolExecutor_1.FileStorageToolExecutor; } });
|
|
8
|
+
var fileStorageTools_1 = require("./fileStorageTools");
|
|
9
|
+
Object.defineProperty(exports, "getFileStorageToolsForChatCompletions", { enumerable: true, get: function () { return fileStorageTools_1.getFileStorageToolsForChatCompletions; } });
|
|
10
|
+
Object.defineProperty(exports, "FileStorageToolName", { enumerable: true, get: function () { return fileStorageTools_1.FileStorageToolName; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/fileStorage/index.ts"],"names":[],"mappings":";;;AAAA,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,uDAG4B;AAF1B,yIAAA,qCAAqC,OAAA;AACrC,uHAAA,mBAAmB,OAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './agentRounds';
|
|
2
|
+
export * from './LLMBaseService.abstract';
|
|
3
|
+
export * from './LLMCompletionService.abstract';
|
|
4
|
+
export * from './LLMServicePurposeFactory.abstract';
|
|
5
|
+
export * from './LLMAssistanceService.abstract';
|
|
6
|
+
export * from './LLMSpeechToTextService.abstract';
|
|
7
|
+
export * from './LLMTextToSpeechService.abstract';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./agentRounds"), exports);
|
|
18
|
+
__exportStar(require("./LLMBaseService.abstract"), exports);
|
|
19
|
+
__exportStar(require("./LLMCompletionService.abstract"), exports);
|
|
20
|
+
__exportStar(require("./LLMServicePurposeFactory.abstract"), exports);
|
|
21
|
+
__exportStar(require("./LLMAssistanceService.abstract"), exports);
|
|
22
|
+
__exportStar(require("./LLMSpeechToTextService.abstract"), exports);
|
|
23
|
+
__exportStar(require("./LLMTextToSpeechService.abstract"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,gDAA8B;AAC9B,4DAA0C;AAC1C,kEAAgD;AAChD,sEAAoD;AACpD,kEAAgD;AAChD,oEAAkD;AAClD,oEAAkD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type LLMProviders, type LLMModel, type LLMModelUsage, type LLMCostsResult } from '../LLMService.typedefs';
|
|
2
|
+
export type { LLMModelUsage, LLMCostsResult } from '../LLMService.typedefs';
|
|
3
|
+
export declare function addUsage(first: LLMModelUsage, second: LLMModelUsage): LLMModelUsage;
|
|
4
|
+
export declare const calculateCosts: <Provider extends LLMProviders>(model: LLMModel<Provider> | null, usage: LLMModelUsage) => LLMCostsResult;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateCosts = void 0;
|
|
4
|
+
exports.addUsage = addUsage;
|
|
5
|
+
const USAGE_TOKEN_KEY_MAP = {
|
|
6
|
+
inputTextTokens: true,
|
|
7
|
+
outputTextTokens: true,
|
|
8
|
+
inputAudioTokens: true,
|
|
9
|
+
outputAudioTokens: true,
|
|
10
|
+
inputCachedTextTokens: true,
|
|
11
|
+
inputCachedAudioTokens: true,
|
|
12
|
+
outputReasoningTokens: true,
|
|
13
|
+
};
|
|
14
|
+
const USAGE_TOKEN_KEYS = Object.keys(USAGE_TOKEN_KEY_MAP);
|
|
15
|
+
function addUsage(first, second) {
|
|
16
|
+
return USAGE_TOKEN_KEYS.reduce((accumulated, tokenKey) => {
|
|
17
|
+
const total = (first[tokenKey] ?? 0) + (second[tokenKey] ?? 0);
|
|
18
|
+
if (total === 0) {
|
|
19
|
+
return accumulated;
|
|
20
|
+
}
|
|
21
|
+
return { ...accumulated, [tokenKey]: total };
|
|
22
|
+
}, {});
|
|
23
|
+
}
|
|
24
|
+
const calculateCosts = (model, usage) => {
|
|
25
|
+
const { inputTextTokens = 0, outputTextTokens = 0, inputAudioTokens = 0, outputAudioTokens = 0, inputCachedTextTokens = 0, inputCachedAudioTokens = 0, outputReasoningTokens = 0, } = usage;
|
|
26
|
+
if (!model) {
|
|
27
|
+
return {
|
|
28
|
+
input: 0,
|
|
29
|
+
output: 0,
|
|
30
|
+
total: 0,
|
|
31
|
+
currency: 'USD',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const { pricing } = model;
|
|
35
|
+
// Regular input costs
|
|
36
|
+
const regularInputCost = (pricing.getPriceForTextInput(inputTextTokens)
|
|
37
|
+
+ pricing.getPriceForAudioInput(inputAudioTokens));
|
|
38
|
+
// Cached input costs (use discounted rate if available, otherwise fall back to regular rate)
|
|
39
|
+
const cachedInputCost = ((pricing.getPriceForCachedTextInput?.(inputCachedTextTokens)
|
|
40
|
+
?? pricing.getPriceForTextInput(inputCachedTextTokens))
|
|
41
|
+
+ (pricing.getPriceForCachedAudioInput?.(inputCachedAudioTokens)
|
|
42
|
+
?? pricing.getPriceForAudioInput(inputCachedAudioTokens)));
|
|
43
|
+
// Output costs (reasoning tokens are charged as output tokens)
|
|
44
|
+
const outputCost = (pricing.getPriceForTextOutput(outputTextTokens + outputReasoningTokens)
|
|
45
|
+
+ pricing.getPriceForAudioOutput(outputAudioTokens));
|
|
46
|
+
const totalInputCost = regularInputCost + cachedInputCost;
|
|
47
|
+
const totalCost = totalInputCost + outputCost;
|
|
48
|
+
return {
|
|
49
|
+
input: Number(totalInputCost.toFixed(6)),
|
|
50
|
+
output: Number(outputCost.toFixed(6)),
|
|
51
|
+
total: Number(totalCost.toFixed(6)),
|
|
52
|
+
currency: model.pricing.currency,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
exports.calculateCosts = calculateCosts;
|
|
56
|
+
//# sourceMappingURL=calculateCosts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateCosts.js","sourceRoot":"","sources":["../../src/utilities/calculateCosts.ts"],"names":[],"mappings":";;;AAuBA,4BAgBC;AA9BD,MAAM,mBAAmB,GAAG;IAC1B,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,IAAI;IACtB,gBAAgB,EAAE,IAAI;IACtB,iBAAiB,EAAE,IAAI;IACvB,qBAAqB,EAAE,IAAI;IAC3B,sBAAsB,EAAE,IAAI;IAC5B,qBAAqB,EAAE,IAAI;CAC0B,CAAC;AAExD,MAAM,gBAAgB,GAAG,MAAM,CAAC,IAAI,CAClC,mBAAmB,CACO,CAAC;AAE7B,SAAgB,QAAQ,CACtB,KAAoB,EACpB,MAAqB;IAErB,OAAO,gBAAgB,CAAC,MAAM,CAC5B,CAAC,WAAW,EAAE,QAAQ,EAAE,EAAE;QACxB,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAE/D,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YAChB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,OAAO,EAAE,GAAG,WAAW,EAAE,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,CAAC;IAC/C,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC;AAEM,MAAM,cAAc,GAAG,CAC5B,KAAgC,EAChC,KAAoB,EACJ,EAAE;IAClB,MAAM,EACJ,eAAe,GAAG,CAAC,EACnB,gBAAgB,GAAG,CAAC,EACpB,gBAAgB,GAAG,CAAC,EACpB,iBAAiB,GAAG,CAAC,EACrB,qBAAqB,GAAG,CAAC,EACzB,sBAAsB,GAAG,CAAC,EAC1B,qBAAqB,GAAG,CAAC,GAC1B,GAAG,KAAK,CAAC;IAEV,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO;YACL,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE,KAAK;SAChB,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAE1B,sBAAsB;IACtB,MAAM,gBAAgB,GAAG,CACvB,OAAO,CAAC,oBAAoB,CAAC,eAAe,CAAC;UAC3C,OAAO,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAClD,CAAC;IAEF,6FAA6F;IAC7F,MAAM,eAAe,GAAG,CACtB,CAAC,OAAO,CAAC,0BAA0B,EAAE,CAAC,qBAAqB,CAAC;WACvD,OAAO,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC;UACvD,CAAC,OAAO,CAAC,2BAA2B,EAAE,CAAC,sBAAsB,CAAC;eAC3D,OAAO,CAAC,qBAAqB,CAAC,sBAAsB,CAAC,CAAC,CAC5D,CAAC;IAEF,+DAA+D;IAC/D,MAAM,UAAU,GAAG,CACjB,OAAO,CAAC,qBAAqB,CAAC,gBAAgB,GAAG,qBAAqB,CAAC;UACrE,OAAO,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CACpD,CAAC;IAEF,MAAM,cAAc,GAAG,gBAAgB,GAAG,eAAe,CAAC;IAC1D,MAAM,SAAS,GAAG,cAAc,GAAG,UAAU,CAAC;IAE9C,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACxC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACrC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACnC,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ;KACjC,CAAC;AACJ,CAAC,CAAC;AAtDW,QAAA,cAAc,kBAsDzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pick: <T, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pick = void 0;
|
|
4
|
+
const pick = (obj, keys) => (keys.reduce((acc, key) => {
|
|
5
|
+
Object.assign(acc, { [key]: obj[key] });
|
|
6
|
+
return acc;
|
|
7
|
+
}, {}));
|
|
8
|
+
exports.pick = pick;
|
|
9
|
+
//# sourceMappingURL=functional.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functional.utils.js","sourceRoot":"","sources":["../../src/utilities/functional.utils.ts"],"names":[],"mappings":";;;AAAO,MAAM,IAAI,GAAG,CAAuB,GAAM,EAAE,IAAS,EAAc,EAAE,CAAC,CAC3E,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IACvB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAExC,OAAO,GAAG,CAAC;AACb,CAAC,EAAE,EAAgB,CAAC,CACrB,CAAC;AANW,QAAA,IAAI,QAMf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './functional.utils';
|
|
2
|
+
export * from './llmTracing';
|
|
3
|
+
export * from './promptBuilder';
|
|
4
|
+
export * from './calculateCosts';
|
|
5
|
+
export * from './logger';
|
|
6
|
+
export * from './reporter';
|
|
7
|
+
export * from './schema';
|
|
8
|
+
export * from './serializeError';
|
|
9
|
+
export * from './tools';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./functional.utils"), exports);
|
|
18
|
+
__exportStar(require("./llmTracing"), exports);
|
|
19
|
+
__exportStar(require("./promptBuilder"), exports);
|
|
20
|
+
__exportStar(require("./calculateCosts"), exports);
|
|
21
|
+
__exportStar(require("./logger"), exports);
|
|
22
|
+
__exportStar(require("./reporter"), exports);
|
|
23
|
+
__exportStar(require("./schema"), exports);
|
|
24
|
+
__exportStar(require("./serializeError"), exports);
|
|
25
|
+
__exportStar(require("./tools"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,+CAA6B;AAC7B,kDAAgC;AAChC,mDAAiC;AACjC,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB;AACzB,mDAAiC;AACjC,0CAAwB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./llmTracing.typedefs"), exports);
|
|
18
|
+
__exportStar(require("./llmTracing.constants"), exports);
|
|
19
|
+
__exportStar(require("./noopLLMTracing"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/llmTracing/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,yDAAuC;AACvC,mDAAiC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudWatch namespace + metric name for the prompt-fallback-serving alarm.
|
|
3
|
+
* The alarm is provisioned against these exact string values, so they are a
|
|
4
|
+
* published contract — renaming a value requires re-pointing the alarm first.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LLM_GATEWAY_METRIC_NAMESPACE = "LLMGateway";
|
|
7
|
+
export declare const PROMPT_FALLBACK_SERVED_METRIC = "LangfuseFallbackServed";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PROMPT_FALLBACK_SERVED_METRIC = exports.LLM_GATEWAY_METRIC_NAMESPACE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* CloudWatch namespace + metric name for the prompt-fallback-serving alarm.
|
|
6
|
+
* The alarm is provisioned against these exact string values, so they are a
|
|
7
|
+
* published contract — renaming a value requires re-pointing the alarm first.
|
|
8
|
+
*/
|
|
9
|
+
exports.LLM_GATEWAY_METRIC_NAMESPACE = 'LLMGateway';
|
|
10
|
+
exports.PROMPT_FALLBACK_SERVED_METRIC = 'LangfuseFallbackServed';
|
|
11
|
+
//# sourceMappingURL=llmTracing.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmTracing.constants.js","sourceRoot":"","sources":["../../../src/utilities/llmTracing/llmTracing.constants.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,4BAA4B,GAAG,YAAY,CAAC;AAE5C,QAAA,6BAA6B,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace/observation metadata. Values are coerced to strings before they reach
|
|
3
|
+
* the SDK, so callers may pass scalars.
|
|
4
|
+
*/
|
|
5
|
+
export type LLMTraceMetadata = Record<string, string | number | boolean>;
|
|
6
|
+
export interface LLMTraceContext {
|
|
7
|
+
/** Overrides the trace name (defaults to the wrapping operation name). */
|
|
8
|
+
name?: string;
|
|
9
|
+
userId?: string;
|
|
10
|
+
sessionId?: string;
|
|
11
|
+
tags?: string[];
|
|
12
|
+
metadata?: LLMTraceMetadata;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Structural reference to the managed prompt a generation was produced from.
|
|
16
|
+
* SDK-free by design: the gateway only carries `name`/`version`/`isFallback`,
|
|
17
|
+
* and the tracer implementation turns it into a prompt link (a fallback
|
|
18
|
+
* prompt intentionally produces no link).
|
|
19
|
+
*/
|
|
20
|
+
export interface LLMTracedPrompt {
|
|
21
|
+
name: string;
|
|
22
|
+
version: number;
|
|
23
|
+
isFallback?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Escape-hatch update applied to the active trace of a single tracer. `name`,
|
|
27
|
+
* `input` and `output` replace the previous values; `metadata` merges. Outside
|
|
28
|
+
* an active scope the call is a safe no-op.
|
|
29
|
+
*
|
|
30
|
+
* `output` is the only way a trace gets one: the root never harvests the
|
|
31
|
+
* wrapped operation's return value, so a feature that wants a meaningful trace
|
|
32
|
+
* output states it here, in whatever trimmed shape is worth reading.
|
|
33
|
+
*/
|
|
34
|
+
export interface LLMActiveTraceUpdate {
|
|
35
|
+
name?: string;
|
|
36
|
+
input?: unknown;
|
|
37
|
+
output?: unknown;
|
|
38
|
+
metadata?: LLMTraceMetadata;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Per-call generation capture passed from a provider service to the base
|
|
42
|
+
* service's success/error metric points. The observation name defaults to the
|
|
43
|
+
* service method when no prompt name is threaded through.
|
|
44
|
+
*/
|
|
45
|
+
export interface LLMGenerationTrace {
|
|
46
|
+
name: string;
|
|
47
|
+
input?: unknown;
|
|
48
|
+
output?: unknown;
|
|
49
|
+
modelParameters?: Record<string, unknown>;
|
|
50
|
+
metadata?: LLMTraceMetadata;
|
|
51
|
+
/**
|
|
52
|
+
* The managed prompt this generation used. Threaded through so the tracer can
|
|
53
|
+
* link the observation to its prompt version.
|
|
54
|
+
*/
|
|
55
|
+
prompt?: LLMTracedPrompt;
|
|
56
|
+
/**
|
|
57
|
+
* The user this call was made for. A typed trace attribute, never a metadata
|
|
58
|
+
* key: the tracer promotes it to the trace's own user field, which is what
|
|
59
|
+
* Langfuse filters and groups on.
|
|
60
|
+
*/
|
|
61
|
+
userId?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Groups every trace of one conversation, review, or agent run under a single
|
|
64
|
+
* Langfuse session. Typed trace attribute, never a metadata key.
|
|
65
|
+
*/
|
|
66
|
+
sessionId?: string;
|
|
67
|
+
/** Langfuse trace tags. Typed trace attribute, never a metadata key. */
|
|
68
|
+
tags?: string[];
|
|
69
|
+
/** Epoch milliseconds captured immediately before the provider call. */
|
|
70
|
+
startedAt: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Full per-call generation record passed to `recordGeneration`. Extracted from
|
|
74
|
+
* `LLMGenerationTrace` so the gateway and `@mate-academy/llm-tracer` share the
|
|
75
|
+
* exact same recorded shape.
|
|
76
|
+
*/
|
|
77
|
+
export interface LLMGenerationTraceRecord extends LLMGenerationTrace {
|
|
78
|
+
/** Epoch milliseconds stamped when the generation is handed to the tracer. */
|
|
79
|
+
endedAt: number;
|
|
80
|
+
model: string | null;
|
|
81
|
+
usageDetails?: Record<string, number>;
|
|
82
|
+
costDetails?: Record<string, number>;
|
|
83
|
+
isError?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The tracing surface the gateway depends on. Any implementation (the no-op,
|
|
87
|
+
* or a real tracer from `@mate-academy/llm-tracer`) satisfies it, so
|
|
88
|
+
* consumers hold a single type regardless of whether tracing is configured.
|
|
89
|
+
*/
|
|
90
|
+
export interface LLMGatewayTracer {
|
|
91
|
+
readonly isEnabled: boolean;
|
|
92
|
+
withTrace<Result>(name: string, context: LLMTraceContext, fn: () => Promise<Result>): Promise<Result>;
|
|
93
|
+
recordGeneration(generation: LLMGenerationTraceRecord): void;
|
|
94
|
+
withToolObservation<Result>(name: string, input: unknown, fn: () => Promise<Result>): Promise<Result>;
|
|
95
|
+
withAgentObservation<Result>(name: string, input: unknown, fn: () => Promise<Result>): Promise<Result>;
|
|
96
|
+
/**
|
|
97
|
+
* Updates the active trace of this tracer only (name/input replace, metadata
|
|
98
|
+
* merges). A no-op outside an active scope. Isolated per tracer so it can
|
|
99
|
+
* never touch another project's trace.
|
|
100
|
+
*/
|
|
101
|
+
updateActiveTrace(update: LLMActiveTraceUpdate): void;
|
|
102
|
+
/**
|
|
103
|
+
* The context the active scope was opened with, or `undefined` outside a
|
|
104
|
+
* scope. It is what lets a consumer resolve what the surrounding operation
|
|
105
|
+
* declared (its user, session, tags) without the application threading that
|
|
106
|
+
* context through every call.
|
|
107
|
+
*/
|
|
108
|
+
getActiveTraceContext(): LLMTraceContext | undefined;
|
|
109
|
+
flush(): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Tears down the tracer's provider/exporter. Optional so a 7.8 minor does not
|
|
112
|
+
* break external structural implementations that predate the method.
|
|
113
|
+
*/
|
|
114
|
+
shutdown?(): Promise<void>;
|
|
115
|
+
}
|
|
116
|
+
export interface LLMFallbackMetricDimensions {
|
|
117
|
+
feature?: string;
|
|
118
|
+
promptName?: string;
|
|
119
|
+
reason?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Emits a single fallback-served data point. Consumers inject a real CloudWatch
|
|
123
|
+
* implementation when they build the gateway; the default is a no-op so the
|
|
124
|
+
* gateway carries no AWS dependency and tracing stays fire-and-forget.
|
|
125
|
+
*/
|
|
126
|
+
export type LLMFallbackMetricEmitter = (dimensions: LLMFallbackMetricDimensions) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llmTracing.typedefs.js","sourceRoot":"","sources":["../../../src/utilities/llmTracing/llmTracing.typedefs.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.noopFallbackMetricEmitter = exports.noopLLMGatewayTracer = void 0;
|
|
4
|
+
class NoopLLMGatewayTracer {
|
|
5
|
+
isEnabled = false;
|
|
6
|
+
async withTrace(_name, _context, fn) {
|
|
7
|
+
return fn();
|
|
8
|
+
}
|
|
9
|
+
recordGeneration() {
|
|
10
|
+
// no-op when disabled
|
|
11
|
+
}
|
|
12
|
+
async withToolObservation(_name, _input, fn) {
|
|
13
|
+
return fn();
|
|
14
|
+
}
|
|
15
|
+
async withAgentObservation(_name, _input, fn) {
|
|
16
|
+
return fn();
|
|
17
|
+
}
|
|
18
|
+
updateActiveTrace() {
|
|
19
|
+
// no-op when disabled
|
|
20
|
+
}
|
|
21
|
+
getActiveTraceContext() {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
async flush() {
|
|
25
|
+
// no-op when disabled
|
|
26
|
+
}
|
|
27
|
+
async shutdown() {
|
|
28
|
+
// no-op when disabled
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.noopLLMGatewayTracer = new NoopLLMGatewayTracer();
|
|
32
|
+
const noopFallbackMetricEmitter = () => {
|
|
33
|
+
// no-op when no emitter is injected
|
|
34
|
+
};
|
|
35
|
+
exports.noopFallbackMetricEmitter = noopFallbackMetricEmitter;
|
|
36
|
+
//# sourceMappingURL=noopLLMTracing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"noopLLMTracing.js","sourceRoot":"","sources":["../../../src/utilities/llmTracing/noopLLMTracing.ts"],"names":[],"mappings":";;;AAMA,MAAM,oBAAoB;IACf,SAAS,GAAG,KAAK,CAAC;IAE3B,KAAK,CAAC,SAAS,CACb,KAAa,EACb,QAAyB,EACzB,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,gBAAgB;QACd,sBAAsB;IACxB,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,KAAa,EACb,MAAe,EACf,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,KAAa,EACb,MAAe,EACf,EAAyB;QAEzB,OAAO,EAAE,EAAE,CAAC;IACd,CAAC;IAED,iBAAiB;QACf,sBAAsB;IACxB,CAAC;IAED,qBAAqB;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,sBAAsB;IACxB,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,sBAAsB;IACxB,CAAC;CACF;AAEY,QAAA,oBAAoB,GAAqB,IAAI,oBAAoB,EAAE,CAAC;AAE1E,MAAM,yBAAyB,GAA6B,GAAG,EAAE;IACtE,oCAAoC;AACtC,CAAC,CAAC;AAFW,QAAA,yBAAyB,6BAEpC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal logger interface for the LLM Gateway package.
|
|
3
|
+
* Compatible with common logging libraries.
|
|
4
|
+
*/
|
|
5
|
+
export interface LLMLoggerInterface {
|
|
6
|
+
/**
|
|
7
|
+
* Log informational messages
|
|
8
|
+
* @param message - The message to log
|
|
9
|
+
* @param meta - Optional metadata to include with the log
|
|
10
|
+
*/
|
|
11
|
+
info(message: string, meta?: Record<string, any>): void;
|
|
12
|
+
/**
|
|
13
|
+
* Log error messages
|
|
14
|
+
* @param message - The error message to log
|
|
15
|
+
* @param meta - Optional metadata to include with the log
|
|
16
|
+
*/
|
|
17
|
+
error(message: string, meta?: Record<string, any>): void;
|
|
18
|
+
/**
|
|
19
|
+
* Log warning messages
|
|
20
|
+
* @param message - The warning message to log
|
|
21
|
+
* @param meta - Optional metadata to include with the log
|
|
22
|
+
*/
|
|
23
|
+
warn(message: string, meta?: Record<string, any>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Log debug messages (optional)
|
|
26
|
+
* @param message - The debug message to log
|
|
27
|
+
* @param meta - Optional metadata to include with the log
|
|
28
|
+
*/
|
|
29
|
+
debug?(message: string, meta?: Record<string, any>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Create a child logger with additional context
|
|
32
|
+
* @param context - The context to add to the child logger
|
|
33
|
+
* @returns A new logger instance with the additional context
|
|
34
|
+
*/
|
|
35
|
+
child(context: string): LLMLoggerInterface;
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LLMLoggerInterface.js","sourceRoot":"","sources":["../../../src/utilities/logger/LLMLoggerInterface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LLMLoggerInterface';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./LLMLoggerInterface"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/logger/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility types and functions for handling prompts with dynamic replacements and conditional sections.
|
|
3
|
+
* This allows for type-safe string templates with placeholders that can be replaced with actual values.
|
|
4
|
+
* The `createPromptTemplate` function helps create typed prompts with automatic extraction of replacement keys.
|
|
5
|
+
*
|
|
6
|
+
* @module promptBuilder
|
|
7
|
+
* @example
|
|
8
|
+
* // Example usage:
|
|
9
|
+
* const PROMPTS = {
|
|
10
|
+
* welcomeMessage: createPromptTemplate(`
|
|
11
|
+
* Generate a welcome message for a user who has just started their auto tech check attempt on {{topicTitle}}.
|
|
12
|
+
* {{#hasBonus}}
|
|
13
|
+
* This topic includes bonus content: {{bonusContent}}
|
|
14
|
+
* {{/hasBonus}}
|
|
15
|
+
*
|
|
16
|
+
* {{#valueAsCondition}}
|
|
17
|
+
* This is a conditional section that will only appear if the value is truthy.
|
|
18
|
+
* Value can be used inside the section: {{valueAsCondition}}
|
|
19
|
+
* {{/valueAsCondition}}
|
|
20
|
+
*
|
|
21
|
+
* {{#!skipSection}}
|
|
22
|
+
* This negative conditional section will only appear if skipSection is falsy.
|
|
23
|
+
* {{/skipSection}}
|
|
24
|
+
* `),
|
|
25
|
+
* };
|
|
26
|
+
*
|
|
27
|
+
* const instruction = PROMPTS.welcomeMessage({
|
|
28
|
+
* topicTitle: 'JavaScript Basics',
|
|
29
|
+
* hasBonus: true,
|
|
30
|
+
* bonusContent: 'Advanced debugging techniques',
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // This will generate a prompt:
|
|
34
|
+
* // "Generate a welcome message for a user who has just started their auto tech check attempt on JavaScript Basics.
|
|
35
|
+
* // This topic includes bonus content: Advanced debugging techniques"
|
|
36
|
+
*/
|
|
37
|
+
type RegularValue = string | number;
|
|
38
|
+
type ConditionalValue = RegularValue | boolean | undefined | null;
|
|
39
|
+
type ExtractAllVariables<T extends string> = T extends `${string}{{${infer Key}}}${infer Rest}` ? Key extends `${infer CleanKey}` ? CleanKey | ExtractAllVariables<Rest> : never : never;
|
|
40
|
+
type ExtractSectionVariables<T extends string> = T extends `${string}{{#!${infer Key}}}${infer Rest}` ? Key | ExtractSectionVariables<Rest> : T extends `${string}{{#${infer Key}}}${infer Rest}` ? Key | ExtractSectionVariables<Rest> : never;
|
|
41
|
+
type ExtractClosingTagVariables<T extends string> = T extends `${string}{{/${infer Key}}}${infer Rest}` ? Key | ExtractClosingTagVariables<Rest> : never;
|
|
42
|
+
type AllSectionVariables<T extends string> = ExtractSectionVariables<T> | ExtractClosingTagVariables<T>;
|
|
43
|
+
type ExtractRegularVariables<T extends string> = ExtractAllVariables<T> extends infer All ? All extends string ? All extends `#!${string}` | `#${string}` | `/${string}` ? never : All : never : never;
|
|
44
|
+
type CreateVariableRecord<T extends string> = ExtractRegularVariables<T> extends never ? AllSectionVariables<T> extends never ? Record<string, never> : Record<AllSectionVariables<T>, ConditionalValue> : AllSectionVariables<T> extends never ? Record<ExtractRegularVariables<T>, RegularValue> : Omit<Record<ExtractRegularVariables<T>, RegularValue>, AllSectionVariables<T>> & Record<AllSectionVariables<T>, ConditionalValue>;
|
|
45
|
+
type HasVariables<T extends string> = ExtractAllVariables<T> extends never ? false : true;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a prompt template function that can be used to generate prompts
|
|
48
|
+
* with dynamic replacements and conditional sections.
|
|
49
|
+
* @template T The type of the template string. Inferred from the provided template.
|
|
50
|
+
* @param {T} template The template string with placeholders:
|
|
51
|
+
* - for dynamic values (e.g., `{{topicTitle}}`)
|
|
52
|
+
* - for conditional sections (e.g., `{{#section}}...{{/section}}`)
|
|
53
|
+
* - for negative conditional sections (e.g., `{{#!section}}...{{/section}}`)
|
|
54
|
+
* - for sections that use conditional variables as values (e.g., `{{#bonus}}...{{bonus}}...{{/bonus}}`)
|
|
55
|
+
* @returns A function that takes the dynamic values and returns the generated prompt.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createPromptTemplate<T extends string>(template: T): (...args: HasVariables<T> extends false ? [] : [variables: CreateVariableRecord<T>]) => string;
|
|
58
|
+
export {};
|