tekimax-ts 0.1.7 → 0.1.8
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/README.md +113 -26
- package/dist/adapter-BtbeHotF.d.cts +81 -0
- package/dist/adapter-BtbeHotF.d.ts +81 -0
- package/dist/adapter-C5iFgx6o.d.cts +162 -0
- package/dist/adapter-C5iFgx6o.d.ts +162 -0
- package/dist/adapter-CMu9Gvvm.d.cts +81 -0
- package/dist/adapter-CMu9Gvvm.d.ts +81 -0
- package/dist/adapter-DeUJcFAn.d.cts +43 -0
- package/dist/adapter-DeUJcFAn.d.ts +43 -0
- package/dist/adapter-K9NFtBg8.d.cts +81 -0
- package/dist/adapter-K9NFtBg8.d.ts +81 -0
- package/dist/adapter-TuDzMu0Y.d.cts +43 -0
- package/dist/adapter-TuDzMu0Y.d.ts +43 -0
- package/dist/adapter-YcdKK3By.d.cts +63 -0
- package/dist/adapter-YcdKK3By.d.ts +63 -0
- package/dist/adapter-xdRwibId.d.cts +144 -0
- package/dist/adapter-xdRwibId.d.ts +144 -0
- package/dist/adapter-zXqUGXCx.d.cts +81 -0
- package/dist/adapter-zXqUGXCx.d.ts +81 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/gen/index.js +1572 -378
- package/dist/gen/types.js +290 -201
- package/dist/gen/zod/allowedToolChoiceSchema.js +17 -13
- package/dist/gen/zod/allowedToolsParamSchema.js +28 -13
- package/dist/gen/zod/annotationSchema.js +16 -11
- package/dist/gen/zod/assistantMessageItemParamSchema.js +52 -19
- package/dist/gen/zod/createResponseBodySchema.js +142 -44
- package/dist/gen/zod/createresponseSchema.js +23 -12
- package/dist/gen/zod/detailEnumSchema.js +8 -8
- package/dist/gen/zod/developerMessageItemParamSchema.js +35 -16
- package/dist/gen/zod/emptyModelParamSchema.js +8 -8
- package/dist/gen/zod/errorPayloadSchema.js +27 -14
- package/dist/gen/zod/errorSchema.js +17 -11
- package/dist/gen/zod/errorStreamingEventSchema.js +23 -13
- package/dist/gen/zod/functionCallItemParamSchema.js +38 -15
- package/dist/gen/zod/functionCallItemStatusSchema.js +12 -8
- package/dist/gen/zod/functionCallOutputItemParamSchema.js +90 -27
- package/dist/gen/zod/functionCallOutputSchema.js +67 -24
- package/dist/gen/zod/functionCallOutputStatusEnumSchema.js +12 -8
- package/dist/gen/zod/functionCallSchema.js +29 -16
- package/dist/gen/zod/functionCallStatusSchema.js +12 -8
- package/dist/gen/zod/functionToolChoiceSchema.js +10 -10
- package/dist/gen/zod/functionToolParamSchema.js +25 -14
- package/dist/gen/zod/functionToolSchema.js +24 -14
- package/dist/gen/zod/imageDetailSchema.js +8 -8
- package/dist/gen/zod/includeEnumSchema.js +11 -8
- package/dist/gen/zod/incompleteDetailsSchema.js +14 -10
- package/dist/gen/zod/index.js +871 -213
- package/dist/gen/zod/inputFileContentParamSchema.js +24 -13
- package/dist/gen/zod/inputFileContentSchema.js +23 -12
- package/dist/gen/zod/inputImageContentParamAutoParamSchema.js +29 -13
- package/dist/gen/zod/inputImageContentSchema.js +22 -13
- package/dist/gen/zod/inputTextContentParamSchema.js +19 -11
- package/dist/gen/zod/inputTextContentSchema.js +16 -11
- package/dist/gen/zod/inputTokensDetailsSchema.js +15 -10
- package/dist/gen/zod/inputVideoContentSchema.js +17 -11
- package/dist/gen/zod/itemFieldSchema.js +45 -20
- package/dist/gen/zod/itemParamSchema.js +55 -23
- package/dist/gen/zod/itemReferenceParamSchema.js +15 -11
- package/dist/gen/zod/jsonObjectResponseFormatSchema.js +9 -9
- package/dist/gen/zod/jsonSchemaResponseFormatParamSchema.js +38 -13
- package/dist/gen/zod/jsonSchemaResponseFormatSchema.js +13 -13
- package/dist/gen/zod/logProbSchema.js +20 -14
- package/dist/gen/zod/messageRoleSchema.js +13 -8
- package/dist/gen/zod/messageSchema.js +109 -43
- package/dist/gen/zod/messageStatusSchema.js +12 -8
- package/dist/gen/zod/metadataParamSchema.js +13 -8
- package/dist/gen/zod/outputTextContentParamSchema.js +21 -12
- package/dist/gen/zod/outputTextContentSchema.js +30 -15
- package/dist/gen/zod/outputTokensDetailsSchema.js +17 -10
- package/dist/gen/zod/reasoningBodySchema.js +173 -54
- package/dist/gen/zod/reasoningEffortEnumSchema.js +14 -8
- package/dist/gen/zod/reasoningItemParamSchema.js +26 -14
- package/dist/gen/zod/reasoningParamSchema.js +33 -13
- package/dist/gen/zod/reasoningSchema.js +27 -13
- package/dist/gen/zod/reasoningSummaryContentParamSchema.js +13 -10
- package/dist/gen/zod/reasoningSummaryEnumSchema.js +12 -8
- package/dist/gen/zod/reasoningTextContentSchema.js +16 -11
- package/dist/gen/zod/refusalContentParamSchema.js +13 -10
- package/dist/gen/zod/refusalContentSchema.js +18 -11
- package/dist/gen/zod/responseCompletedStreamingEventSchema.js +23 -13
- package/dist/gen/zod/responseContentPartAddedStreamingEventSchema.js +98 -39
- package/dist/gen/zod/responseContentPartDoneStreamingEventSchema.js +98 -39
- package/dist/gen/zod/responseCreatedStreamingEventSchema.js +23 -13
- package/dist/gen/zod/responseFailedStreamingEventSchema.js +23 -13
- package/dist/gen/zod/responseFunctionCallArgumentsDeltaStreamingEventSchema.js +38 -15
- package/dist/gen/zod/responseFunctionCallArgumentsDoneStreamingEventSchema.js +33 -14
- package/dist/gen/zod/responseInProgressStreamingEventSchema.js +23 -13
- package/dist/gen/zod/responseIncompleteStreamingEventSchema.js +23 -13
- package/dist/gen/zod/responseOutputItemAddedStreamingEventSchema.js +32 -14
- package/dist/gen/zod/responseOutputItemDoneStreamingEventSchema.js +30 -14
- package/dist/gen/zod/responseOutputTextAnnotationAddedStreamingEventSchema.js +43 -17
- package/dist/gen/zod/responseOutputTextDeltaStreamingEventSchema.js +48 -18
- package/dist/gen/zod/responseOutputTextDoneStreamingEventSchema.js +39 -17
- package/dist/gen/zod/responseQueuedStreamingEventSchema.js +23 -13
- package/dist/gen/zod/responseReasoningDeltaStreamingEventSchema.js +40 -16
- package/dist/gen/zod/responseReasoningDoneStreamingEventSchema.js +31 -15
- package/dist/gen/zod/responseReasoningSummaryDeltaStreamingEventSchema.js +42 -16
- package/dist/gen/zod/responseReasoningSummaryDoneStreamingEventSchema.js +33 -15
- package/dist/gen/zod/responseReasoningSummaryPartAddedStreamingEventSchema.js +102 -39
- package/dist/gen/zod/responseReasoningSummaryPartDoneStreamingEventSchema.js +102 -39
- package/dist/gen/zod/responseRefusalDeltaStreamingEventSchema.js +33 -15
- package/dist/gen/zod/responseRefusalDoneStreamingEventSchema.js +31 -15
- package/dist/gen/zod/responseResourceSchema.js +146 -51
- package/dist/gen/zod/responsesToolParamSchema.js +15 -11
- package/dist/gen/zod/serviceTierEnumSchema.js +13 -8
- package/dist/gen/zod/specificFunctionParamSchema.js +13 -10
- package/dist/gen/zod/specificToolChoiceParamSchema.js +11 -9
- package/dist/gen/zod/streamOptionsParamSchema.js +18 -10
- package/dist/gen/zod/summaryTextContentSchema.js +18 -11
- package/dist/gen/zod/systemMessageItemParamSchema.js +35 -16
- package/dist/gen/zod/textContentSchema.js +13 -11
- package/dist/gen/zod/textFieldSchema.js +24 -14
- package/dist/gen/zod/textFormatParamSchema.js +16 -10
- package/dist/gen/zod/textParamSchema.js +23 -12
- package/dist/gen/zod/textResponseFormatSchema.js +9 -9
- package/dist/gen/zod/toolChoiceParamSchema.js +21 -11
- package/dist/gen/zod/toolChoiceValueEnumSchema.js +8 -8
- package/dist/gen/zod/toolSchema.js +16 -11
- package/dist/gen/zod/topLogProbSchema.js +14 -12
- package/dist/gen/zod/truncationEnumSchema.js +8 -8
- package/dist/gen/zod/urlCitationBodySchema.js +29 -14
- package/dist/gen/zod/urlCitationParamSchema.js +28 -13
- package/dist/gen/zod/usageSchema.js +35 -16
- package/dist/gen/zod/userMessageItemParamSchema.js +64 -22
- package/dist/gen/zod/verbosityEnumSchema.js +8 -8
- package/dist/index.cjs +1574 -0
- package/dist/index.d.cts +2823 -0
- package/dist/index.d.mts +51000 -31111
- package/dist/index.d.ts +407 -29296
- package/dist/index.js +1136 -1405
- package/dist/index.mjs +2441 -1010
- package/dist/react/index.cjs +216 -0
- package/dist/react/index.d.cts +25 -0
- package/dist/react/index.d.ts +25 -0
- package/dist/react/index.js +191 -0
- package/dist/tekimax-C-DJ0z27.d.cts +283 -0
- package/dist/tekimax-C-DJ0z27.d.ts +283 -0
- package/package.json +47 -9
- package/.dockerignore +0 -5
- package/Dockerfile +0 -25
- package/kubb.config.js +0 -30
- package/kubb.config.ts +0 -35
- package/public/logos/tekimax-logo-ScreenRGB-2.png +0 -0
- package/spec/openapi.json +0 -3876
- package/src/client.ts +0 -129
- package/src/gen/.kubb/config.ts +0 -43
- package/src/gen/client/createresponse.ts +0 -27
- package/src/gen/client/index.ts +0 -1
- package/src/gen/index.ts +0 -187
- package/src/gen/schemas/allowedToolChoice.json +0 -1
- package/src/gen/schemas/allowedToolsParam.json +0 -1
- package/src/gen/schemas/annotation.json +0 -1
- package/src/gen/schemas/assistantMessageItemParam.json +0 -1
- package/src/gen/schemas/createResponseBody.json +0 -1
- package/src/gen/schemas/detailEnum.json +0 -1
- package/src/gen/schemas/developerMessageItemParam.json +0 -1
- package/src/gen/schemas/emptyModelParam.json +0 -1
- package/src/gen/schemas/error.json +0 -1
- package/src/gen/schemas/errorPayload.json +0 -1
- package/src/gen/schemas/errorStreamingEvent.json +0 -1
- package/src/gen/schemas/functionCall.json +0 -1
- package/src/gen/schemas/functionCallItemParam.json +0 -1
- package/src/gen/schemas/functionCallItemStatus.json +0 -1
- package/src/gen/schemas/functionCallOutput.json +0 -1
- package/src/gen/schemas/functionCallOutputItemParam.json +0 -1
- package/src/gen/schemas/functionCallOutputStatusEnum.json +0 -1
- package/src/gen/schemas/functionCallStatus.json +0 -1
- package/src/gen/schemas/functionTool.json +0 -1
- package/src/gen/schemas/functionToolChoice.json +0 -1
- package/src/gen/schemas/functionToolParam.json +0 -1
- package/src/gen/schemas/imageDetail.json +0 -1
- package/src/gen/schemas/includeEnum.json +0 -1
- package/src/gen/schemas/incompleteDetails.json +0 -1
- package/src/gen/schemas/inputFileContent.json +0 -1
- package/src/gen/schemas/inputFileContentParam.json +0 -1
- package/src/gen/schemas/inputImageContent.json +0 -1
- package/src/gen/schemas/inputImageContentParamAutoParam.json +0 -1
- package/src/gen/schemas/inputTextContent.json +0 -1
- package/src/gen/schemas/inputTextContentParam.json +0 -1
- package/src/gen/schemas/inputTokensDetails.json +0 -1
- package/src/gen/schemas/inputVideoContent.json +0 -1
- package/src/gen/schemas/itemField.json +0 -1
- package/src/gen/schemas/itemParam.json +0 -1
- package/src/gen/schemas/itemReferenceParam.json +0 -1
- package/src/gen/schemas/jsonObjectResponseFormat.json +0 -1
- package/src/gen/schemas/jsonSchemaResponseFormat.json +0 -1
- package/src/gen/schemas/jsonSchemaResponseFormatParam.json +0 -1
- package/src/gen/schemas/logProb.json +0 -1
- package/src/gen/schemas/message.json +0 -1
- package/src/gen/schemas/messageRole.json +0 -1
- package/src/gen/schemas/messageStatus.json +0 -1
- package/src/gen/schemas/metadataParam.json +0 -1
- package/src/gen/schemas/outputTextContent.json +0 -1
- package/src/gen/schemas/outputTextContentParam.json +0 -1
- package/src/gen/schemas/outputTokensDetails.json +0 -1
- package/src/gen/schemas/reasoning.json +0 -1
- package/src/gen/schemas/reasoningBody.json +0 -1
- package/src/gen/schemas/reasoningEffortEnum.json +0 -1
- package/src/gen/schemas/reasoningItemParam.json +0 -1
- package/src/gen/schemas/reasoningParam.json +0 -1
- package/src/gen/schemas/reasoningSummaryContentParam.json +0 -1
- package/src/gen/schemas/reasoningSummaryEnum.json +0 -1
- package/src/gen/schemas/reasoningTextContent.json +0 -1
- package/src/gen/schemas/refusalContent.json +0 -1
- package/src/gen/schemas/refusalContentParam.json +0 -1
- package/src/gen/schemas/responseCompletedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseContentPartAddedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseContentPartDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseCreatedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseFailedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseFunctionCallArgumentsDeltaStreamingEvent.json +0 -1
- package/src/gen/schemas/responseFunctionCallArgumentsDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseInProgressStreamingEvent.json +0 -1
- package/src/gen/schemas/responseIncompleteStreamingEvent.json +0 -1
- package/src/gen/schemas/responseOutputItemAddedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseOutputItemDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseOutputTextAnnotationAddedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseOutputTextDeltaStreamingEvent.json +0 -1
- package/src/gen/schemas/responseOutputTextDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseQueuedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseReasoningDeltaStreamingEvent.json +0 -1
- package/src/gen/schemas/responseReasoningDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseReasoningSummaryDeltaStreamingEvent.json +0 -1
- package/src/gen/schemas/responseReasoningSummaryDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseReasoningSummaryPartAddedStreamingEvent.json +0 -1
- package/src/gen/schemas/responseReasoningSummaryPartDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseRefusalDeltaStreamingEvent.json +0 -1
- package/src/gen/schemas/responseRefusalDoneStreamingEvent.json +0 -1
- package/src/gen/schemas/responseResource.json +0 -1
- package/src/gen/schemas/responsesToolParam.json +0 -1
- package/src/gen/schemas/serviceTierEnum.json +0 -1
- package/src/gen/schemas/specificFunctionParam.json +0 -1
- package/src/gen/schemas/specificToolChoiceParam.json +0 -1
- package/src/gen/schemas/streamOptionsParam.json +0 -1
- package/src/gen/schemas/summaryTextContent.json +0 -1
- package/src/gen/schemas/systemMessageItemParam.json +0 -1
- package/src/gen/schemas/textContent.json +0 -1
- package/src/gen/schemas/textField.json +0 -1
- package/src/gen/schemas/textFormatParam.json +0 -1
- package/src/gen/schemas/textParam.json +0 -1
- package/src/gen/schemas/textResponseFormat.json +0 -1
- package/src/gen/schemas/tool.json +0 -1
- package/src/gen/schemas/toolChoiceParam.json +0 -1
- package/src/gen/schemas/toolChoiceValueEnum.json +0 -1
- package/src/gen/schemas/topLogProb.json +0 -1
- package/src/gen/schemas/truncationEnum.json +0 -1
- package/src/gen/schemas/urlCitationBody.json +0 -1
- package/src/gen/schemas/urlCitationParam.json +0 -1
- package/src/gen/schemas/usage.json +0 -1
- package/src/gen/schemas/userMessageItemParam.json +0 -1
- package/src/gen/schemas/verbosityEnum.json +0 -1
- package/src/gen/types.ts +0 -2613
- package/src/gen/zod/allowedToolChoiceSchema.ts +0 -14
- package/src/gen/zod/allowedToolsParamSchema.ts +0 -14
- package/src/gen/zod/annotationSchema.ts +0 -14
- package/src/gen/zod/assistantMessageItemParamSchema.ts +0 -20
- package/src/gen/zod/createResponseBodySchema.ts +0 -45
- package/src/gen/zod/createresponseSchema.ts +0 -17
- package/src/gen/zod/detailEnumSchema.ts +0 -8
- package/src/gen/zod/developerMessageItemParamSchema.ts +0 -17
- package/src/gen/zod/emptyModelParamSchema.ts +0 -10
- package/src/gen/zod/errorPayloadSchema.ts +0 -19
- package/src/gen/zod/errorSchema.ts +0 -14
- package/src/gen/zod/errorStreamingEventSchema.ts +0 -16
- package/src/gen/zod/functionCallItemParamSchema.ts +0 -16
- package/src/gen/zod/functionCallItemStatusSchema.ts +0 -8
- package/src/gen/zod/functionCallOutputItemParamSchema.ts +0 -30
- package/src/gen/zod/functionCallOutputSchema.ts +0 -27
- package/src/gen/zod/functionCallOutputStatusEnumSchema.ts +0 -11
- package/src/gen/zod/functionCallSchema.ts +0 -19
- package/src/gen/zod/functionCallStatusSchema.ts +0 -8
- package/src/gen/zod/functionToolChoiceSchema.ts +0 -11
- package/src/gen/zod/functionToolParamSchema.ts +0 -15
- package/src/gen/zod/functionToolSchema.ts +0 -19
- package/src/gen/zod/imageDetailSchema.ts +0 -8
- package/src/gen/zod/includeEnumSchema.ts +0 -8
- package/src/gen/zod/incompleteDetailsSchema.ts +0 -13
- package/src/gen/zod/index.ts +0 -103
- package/src/gen/zod/inputFileContentParamSchema.ts +0 -16
- package/src/gen/zod/inputFileContentSchema.ts +0 -15
- package/src/gen/zod/inputImageContentParamAutoParamSchema.ts +0 -16
- package/src/gen/zod/inputImageContentSchema.ts +0 -16
- package/src/gen/zod/inputTextContentParamSchema.ts +0 -14
- package/src/gen/zod/inputTextContentSchema.ts +0 -14
- package/src/gen/zod/inputTokensDetailsSchema.ts +0 -13
- package/src/gen/zod/inputVideoContentSchema.ts +0 -14
- package/src/gen/zod/itemFieldSchema.ts +0 -23
- package/src/gen/zod/itemParamSchema.ts +0 -23
- package/src/gen/zod/itemReferenceParamSchema.ts +0 -14
- package/src/gen/zod/jsonObjectResponseFormatSchema.ts +0 -10
- package/src/gen/zod/jsonSchemaResponseFormatParamSchema.ts +0 -16
- package/src/gen/zod/jsonSchemaResponseFormatSchema.ts +0 -14
- package/src/gen/zod/logProbSchema.ts +0 -17
- package/src/gen/zod/messageRoleSchema.ts +0 -8
- package/src/gen/zod/messageSchema.ts +0 -46
- package/src/gen/zod/messageStatusSchema.ts +0 -8
- package/src/gen/zod/metadataParamSchema.ts +0 -13
- package/src/gen/zod/outputTextContentParamSchema.ts +0 -13
- package/src/gen/zod/outputTextContentSchema.ts +0 -18
- package/src/gen/zod/outputTokensDetailsSchema.ts +0 -13
- package/src/gen/zod/reasoningBodySchema.ts +0 -57
- package/src/gen/zod/reasoningEffortEnumSchema.ts +0 -8
- package/src/gen/zod/reasoningItemParamSchema.ts +0 -15
- package/src/gen/zod/reasoningParamSchema.ts +0 -16
- package/src/gen/zod/reasoningSchema.ts +0 -16
- package/src/gen/zod/reasoningSummaryContentParamSchema.ts +0 -11
- package/src/gen/zod/reasoningSummaryEnumSchema.ts +0 -8
- package/src/gen/zod/reasoningTextContentSchema.ts +0 -14
- package/src/gen/zod/refusalContentParamSchema.ts +0 -11
- package/src/gen/zod/refusalContentSchema.ts +0 -14
- package/src/gen/zod/responseCompletedStreamingEventSchema.ts +0 -16
- package/src/gen/zod/responseContentPartAddedStreamingEventSchema.ts +0 -42
- package/src/gen/zod/responseContentPartDoneStreamingEventSchema.ts +0 -42
- package/src/gen/zod/responseCreatedStreamingEventSchema.ts +0 -16
- package/src/gen/zod/responseFailedStreamingEventSchema.ts +0 -16
- package/src/gen/zod/responseFunctionCallArgumentsDeltaStreamingEventSchema.ts +0 -18
- package/src/gen/zod/responseFunctionCallArgumentsDoneStreamingEventSchema.ts +0 -17
- package/src/gen/zod/responseInProgressStreamingEventSchema.ts +0 -16
- package/src/gen/zod/responseIncompleteStreamingEventSchema.ts +0 -16
- package/src/gen/zod/responseOutputItemAddedStreamingEventSchema.ts +0 -17
- package/src/gen/zod/responseOutputItemDoneStreamingEventSchema.ts +0 -17
- package/src/gen/zod/responseOutputTextAnnotationAddedStreamingEventSchema.ts +0 -20
- package/src/gen/zod/responseOutputTextDeltaStreamingEventSchema.ts +0 -21
- package/src/gen/zod/responseOutputTextDoneStreamingEventSchema.ts +0 -20
- package/src/gen/zod/responseQueuedStreamingEventSchema.ts +0 -16
- package/src/gen/zod/responseReasoningDeltaStreamingEventSchema.ts +0 -19
- package/src/gen/zod/responseReasoningDoneStreamingEventSchema.ts +0 -18
- package/src/gen/zod/responseReasoningSummaryDeltaStreamingEventSchema.ts +0 -19
- package/src/gen/zod/responseReasoningSummaryDoneStreamingEventSchema.ts +0 -18
- package/src/gen/zod/responseReasoningSummaryPartAddedStreamingEventSchema.ts +0 -42
- package/src/gen/zod/responseReasoningSummaryPartDoneStreamingEventSchema.ts +0 -42
- package/src/gen/zod/responseRefusalDeltaStreamingEventSchema.ts +0 -18
- package/src/gen/zod/responseRefusalDoneStreamingEventSchema.ts +0 -18
- package/src/gen/zod/responseResourceSchema.ts +0 -54
- package/src/gen/zod/responsesToolParamSchema.ts +0 -11
- package/src/gen/zod/serviceTierEnumSchema.ts +0 -8
- package/src/gen/zod/specificFunctionParamSchema.ts +0 -11
- package/src/gen/zod/specificToolChoiceParamSchema.ts +0 -9
- package/src/gen/zod/streamOptionsParamSchema.ts +0 -13
- package/src/gen/zod/summaryTextContentSchema.ts +0 -14
- package/src/gen/zod/systemMessageItemParamSchema.ts +0 -17
- package/src/gen/zod/textContentSchema.ts +0 -14
- package/src/gen/zod/textFieldSchema.ts +0 -15
- package/src/gen/zod/textFormatParamSchema.ts +0 -10
- package/src/gen/zod/textParamSchema.ts +0 -13
- package/src/gen/zod/textResponseFormatSchema.ts +0 -10
- package/src/gen/zod/toolChoiceParamSchema.ts +0 -14
- package/src/gen/zod/toolChoiceValueEnumSchema.ts +0 -8
- package/src/gen/zod/toolSchema.ts +0 -14
- package/src/gen/zod/topLogProbSchema.ts +0 -15
- package/src/gen/zod/truncationEnumSchema.ts +0 -8
- package/src/gen/zod/urlCitationBodySchema.ts +0 -17
- package/src/gen/zod/urlCitationParamSchema.ts +0 -14
- package/src/gen/zod/usageSchema.ts +0 -19
- package/src/gen/zod/userMessageItemParamSchema.ts +0 -23
- package/src/gen/zod/verbosityEnumSchema.ts +0 -8
- package/src/index.ts +0 -3
- package/tsconfig.json +0 -21
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1574 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
AnthropicProvider: () => AnthropicProvider,
|
|
34
|
+
ApiTypes: () => types_exports,
|
|
35
|
+
GeminiProvider: () => GeminiProvider,
|
|
36
|
+
GrokProvider: () => GrokProvider,
|
|
37
|
+
OllamaProvider: () => OllamaProvider,
|
|
38
|
+
OpenAIProvider: () => OpenAIProvider,
|
|
39
|
+
OpenRouterProvider: () => OpenRouterProvider,
|
|
40
|
+
Tekimax: () => Tekimax,
|
|
41
|
+
TekimaxClient: () => TekimaxClient,
|
|
42
|
+
TekimaxProvider: () => TekimaxProvider,
|
|
43
|
+
fileToBase64: () => fileToBase64,
|
|
44
|
+
generateText: () => generateText,
|
|
45
|
+
parseThinking: () => parseThinking,
|
|
46
|
+
tool: () => tool
|
|
47
|
+
});
|
|
48
|
+
module.exports = __toCommonJS(index_exports);
|
|
49
|
+
|
|
50
|
+
// src/providers/tekimax/client.ts
|
|
51
|
+
var import_eventsource_parser = require("eventsource-parser");
|
|
52
|
+
var TekimaxResponse = class {
|
|
53
|
+
constructor(_raw) {
|
|
54
|
+
this._raw = _raw;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Access the raw response object returned by the API.
|
|
58
|
+
*/
|
|
59
|
+
get raw() {
|
|
60
|
+
return this._raw;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Automatically extracts the text content from the response.
|
|
64
|
+
* It looks for the first "output_text" item in the response content.
|
|
65
|
+
*/
|
|
66
|
+
get text() {
|
|
67
|
+
for (const item of this._raw.output) {
|
|
68
|
+
if (item.type === "message") {
|
|
69
|
+
for (const contentPart of item.content) {
|
|
70
|
+
if (contentPart.type === "output_text" || contentPart.type === "text") {
|
|
71
|
+
return contentPart.text;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return void 0;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The ID of the response.
|
|
80
|
+
*/
|
|
81
|
+
get id() {
|
|
82
|
+
return this._raw.id;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* The model used to generate the response.
|
|
86
|
+
*/
|
|
87
|
+
get model() {
|
|
88
|
+
return this._raw.model;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
var TekimaxClient = class {
|
|
92
|
+
/**
|
|
93
|
+
* Creates a new TekimaxClient.
|
|
94
|
+
*
|
|
95
|
+
* @param options - Configuration options for the client.
|
|
96
|
+
* @param options.baseUrl - The base URL of the API (default: "https://api.tekimax.com").
|
|
97
|
+
* @param options.apiKey - Your Tekimax API key.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* const client = new TekimaxClient({ apiKey: "tm_..." });
|
|
101
|
+
*/
|
|
102
|
+
constructor(options = {}) {
|
|
103
|
+
this.baseUrl = options.baseUrl || "https://api.tekimax.com";
|
|
104
|
+
this.headers = {
|
|
105
|
+
"Content-Type": "application/json",
|
|
106
|
+
...options.apiKey ? { Authorization: `Bearer ${options.apiKey}` } : {}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async request(path, body, options) {
|
|
110
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
111
|
+
method: "POST",
|
|
112
|
+
headers: this.headers,
|
|
113
|
+
body: JSON.stringify(body),
|
|
114
|
+
signal: options?.signal
|
|
115
|
+
});
|
|
116
|
+
if (!response.ok) {
|
|
117
|
+
throw new Error(
|
|
118
|
+
`Tekimax API Error: ${response.status} ${response.statusText}`
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
const data = await response.json();
|
|
122
|
+
return new TekimaxResponse(data);
|
|
123
|
+
}
|
|
124
|
+
async *requestStream(path, body, options) {
|
|
125
|
+
const response = await fetch(`${this.baseUrl}${path}`, {
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: this.headers,
|
|
128
|
+
body: JSON.stringify(body),
|
|
129
|
+
signal: options?.signal
|
|
130
|
+
});
|
|
131
|
+
if (!response.ok) {
|
|
132
|
+
throw new Error(
|
|
133
|
+
`Tekimax API Error: ${response.status} ${response.statusText}`
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
if (!response.body) {
|
|
137
|
+
throw new Error("No response body received for streaming request");
|
|
138
|
+
}
|
|
139
|
+
const reader = response.body.getReader();
|
|
140
|
+
const decoder = new TextDecoder();
|
|
141
|
+
const buffer = [];
|
|
142
|
+
const parser = (0, import_eventsource_parser.createParser)({
|
|
143
|
+
onEvent(event) {
|
|
144
|
+
if (event.type === "event") {
|
|
145
|
+
try {
|
|
146
|
+
if (event.data === "[DONE]") return;
|
|
147
|
+
buffer.push(JSON.parse(event.data));
|
|
148
|
+
} catch (e) {
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
try {
|
|
154
|
+
while (true) {
|
|
155
|
+
const { done, value } = await reader.read();
|
|
156
|
+
if (done) break;
|
|
157
|
+
parser.feed(decoder.decode(value, { stream: true }));
|
|
158
|
+
while (buffer.length > 0) {
|
|
159
|
+
yield buffer.shift();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
} finally {
|
|
163
|
+
reader.releaseLock();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Creates a new session and sends the initial message.
|
|
168
|
+
*
|
|
169
|
+
* @param message - The initial message text or array of message items to start the session.
|
|
170
|
+
* @param options - Additional configuration options (model, temperature, etc.).
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* const response = await client.createSession("Hello, world!", { model: "gpt-4" });
|
|
174
|
+
* console.log(response.text);
|
|
175
|
+
*/
|
|
176
|
+
async createSession(message, options) {
|
|
177
|
+
const body = {
|
|
178
|
+
...options,
|
|
179
|
+
input: message
|
|
180
|
+
};
|
|
181
|
+
const { signal } = options || {};
|
|
182
|
+
const cleanBody = { ...body };
|
|
183
|
+
delete cleanBody.signal;
|
|
184
|
+
return this.request("/responses", cleanBody, { signal });
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Sends a message to an existing session or starts a new one if no previous_response_id is provided.
|
|
188
|
+
*
|
|
189
|
+
* @param message - The message text or history array to send.
|
|
190
|
+
* @param options - Additional configuration options.
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* const response = await client.sendMessage("What is the weather?", {
|
|
194
|
+
* previous_response_id: "resp_123"
|
|
195
|
+
* });
|
|
196
|
+
* console.log(response.text);
|
|
197
|
+
*/
|
|
198
|
+
async sendMessage(message, options) {
|
|
199
|
+
const body = {
|
|
200
|
+
...options,
|
|
201
|
+
input: message,
|
|
202
|
+
stream: false
|
|
203
|
+
};
|
|
204
|
+
const { signal } = options || {};
|
|
205
|
+
const cleanBody = { ...body };
|
|
206
|
+
delete cleanBody.signal;
|
|
207
|
+
return this.request("/responses", cleanBody, { signal });
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Sends a message and returns an asynchronous iterable of streaming events.
|
|
211
|
+
*/
|
|
212
|
+
async *sendMessageStream(message, options) {
|
|
213
|
+
const body = {
|
|
214
|
+
...options,
|
|
215
|
+
input: message,
|
|
216
|
+
stream: true
|
|
217
|
+
};
|
|
218
|
+
const { signal } = options || {};
|
|
219
|
+
const cleanBody = { ...body };
|
|
220
|
+
delete cleanBody.signal;
|
|
221
|
+
yield* this.requestStream("/responses", cleanBody, { signal });
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
// src/providers/tekimax/index.ts
|
|
226
|
+
var TekimaxProvider = class {
|
|
227
|
+
constructor(options = {}) {
|
|
228
|
+
this.name = "tekimax";
|
|
229
|
+
this.client = new TekimaxClient(options);
|
|
230
|
+
}
|
|
231
|
+
async chat(options) {
|
|
232
|
+
const tools = options.tools?.map((t) => ({
|
|
233
|
+
type: "function",
|
|
234
|
+
name: t.function.name,
|
|
235
|
+
description: t.function.description ?? void 0,
|
|
236
|
+
parameters: t.function.parameters ?? void 0
|
|
237
|
+
}));
|
|
238
|
+
const input = this.mapMessages(options.messages);
|
|
239
|
+
const response = await this.client.sendMessage(input, {
|
|
240
|
+
model: options.model,
|
|
241
|
+
temperature: options.temperature,
|
|
242
|
+
max_output_tokens: options.maxTokens,
|
|
243
|
+
tools,
|
|
244
|
+
signal: options.signal
|
|
245
|
+
});
|
|
246
|
+
if (response.raw.output) {
|
|
247
|
+
const toolCalls = [];
|
|
248
|
+
for (const item of response.raw.output) {
|
|
249
|
+
if (item.type === "function_call") {
|
|
250
|
+
toolCalls.push({
|
|
251
|
+
id: item.call_id,
|
|
252
|
+
type: "function",
|
|
253
|
+
function: {
|
|
254
|
+
name: item.name,
|
|
255
|
+
arguments: item.arguments
|
|
256
|
+
// Already a string in generated types
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if (toolCalls.length > 0) {
|
|
262
|
+
return {
|
|
263
|
+
message: {
|
|
264
|
+
role: "assistant",
|
|
265
|
+
content: response.text || null,
|
|
266
|
+
toolCalls
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
if (!response.text) {
|
|
272
|
+
if (options.tools && options.tools.length > 0) {
|
|
273
|
+
return { message: { role: "assistant", content: null } };
|
|
274
|
+
}
|
|
275
|
+
throw new Error("No text content in response");
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
message: {
|
|
279
|
+
role: "assistant",
|
|
280
|
+
content: response.text
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
async *chatStream(options) {
|
|
285
|
+
const tools = options.tools?.map((t) => ({
|
|
286
|
+
type: "function",
|
|
287
|
+
name: t.function.name,
|
|
288
|
+
description: t.function.description ?? void 0,
|
|
289
|
+
parameters: t.function.parameters ?? void 0
|
|
290
|
+
}));
|
|
291
|
+
const input = this.mapMessages(options.messages);
|
|
292
|
+
const stream = this.client.sendMessageStream(input, {
|
|
293
|
+
model: options.model,
|
|
294
|
+
temperature: options.temperature,
|
|
295
|
+
max_output_tokens: options.maxTokens,
|
|
296
|
+
tools,
|
|
297
|
+
signal: options.signal
|
|
298
|
+
});
|
|
299
|
+
for await (const event of stream) {
|
|
300
|
+
if (event.type === "response.output_text.delta" && event.delta) {
|
|
301
|
+
yield {
|
|
302
|
+
delta: event.delta
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// Returning any[] because generated ItemParam union is missing UserMessageItemParam
|
|
308
|
+
mapMessages(messages) {
|
|
309
|
+
const items = [];
|
|
310
|
+
for (const msg of messages) {
|
|
311
|
+
if (msg.role === "user") {
|
|
312
|
+
items.push({
|
|
313
|
+
type: "message",
|
|
314
|
+
role: "user",
|
|
315
|
+
content: msg.content || ""
|
|
316
|
+
});
|
|
317
|
+
} else if (msg.role === "assistant") {
|
|
318
|
+
if (msg.content) {
|
|
319
|
+
items.push({
|
|
320
|
+
type: "message",
|
|
321
|
+
role: "assistant",
|
|
322
|
+
content: [{ type: "output_text", text: msg.content }]
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return items;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
// src/providers/anthropic/index.ts
|
|
332
|
+
var import_sdk = __toESM(require("@anthropic-ai/sdk"), 1);
|
|
333
|
+
var AnthropicProvider = class {
|
|
334
|
+
constructor(options) {
|
|
335
|
+
this.name = "anthropic";
|
|
336
|
+
this.client = new import_sdk.default({ apiKey: options.apiKey });
|
|
337
|
+
}
|
|
338
|
+
async chat(options) {
|
|
339
|
+
const response = await this.client.messages.create({
|
|
340
|
+
model: options.model || "claude-3-5-sonnet-20240620",
|
|
341
|
+
max_tokens: options.maxTokens || 1024,
|
|
342
|
+
messages: this.mapMessages(options.messages),
|
|
343
|
+
tools: options.tools?.map(this.mapTool)
|
|
344
|
+
});
|
|
345
|
+
const textBlocks = response.content.filter((c) => c.type === "text");
|
|
346
|
+
const toolUseBlocks = response.content.filter((c) => c.type === "tool_use");
|
|
347
|
+
const text = textBlocks.map((b) => b.text).join("");
|
|
348
|
+
let toolCalls = void 0;
|
|
349
|
+
if (toolUseBlocks.length > 0) {
|
|
350
|
+
toolCalls = toolUseBlocks.map((b) => ({
|
|
351
|
+
id: b.id,
|
|
352
|
+
type: "function",
|
|
353
|
+
function: {
|
|
354
|
+
name: b.name,
|
|
355
|
+
arguments: JSON.stringify(b.input)
|
|
356
|
+
}
|
|
357
|
+
}));
|
|
358
|
+
}
|
|
359
|
+
return {
|
|
360
|
+
usage: {
|
|
361
|
+
promptTokens: response.usage.input_tokens,
|
|
362
|
+
completionTokens: response.usage.output_tokens,
|
|
363
|
+
totalTokens: response.usage.input_tokens + response.usage.output_tokens
|
|
364
|
+
},
|
|
365
|
+
message: {
|
|
366
|
+
role: "assistant",
|
|
367
|
+
content: text,
|
|
368
|
+
toolCalls
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
async *chatStream(options) {
|
|
373
|
+
const stream = await this.client.messages.create({
|
|
374
|
+
model: options.model || "claude-3-5-sonnet-20240620",
|
|
375
|
+
max_tokens: options.maxTokens || 1024,
|
|
376
|
+
messages: this.mapMessages(options.messages),
|
|
377
|
+
stream: true
|
|
378
|
+
});
|
|
379
|
+
for await (const chunk of stream) {
|
|
380
|
+
if (chunk.type === "content_block_delta" && chunk.delta.type === "text_delta") {
|
|
381
|
+
yield {
|
|
382
|
+
delta: chunk.delta.text
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
mapMessages(messages) {
|
|
388
|
+
return messages.filter((m) => m.role === "user" || m.role === "assistant").map((m) => {
|
|
389
|
+
let content = "";
|
|
390
|
+
if (typeof m.content === "string") {
|
|
391
|
+
content = m.content || "";
|
|
392
|
+
} else if (Array.isArray(m.content)) {
|
|
393
|
+
content = m.content.map((part) => {
|
|
394
|
+
if (part.type === "text") {
|
|
395
|
+
return { type: "text", text: part.text };
|
|
396
|
+
}
|
|
397
|
+
if (part.type === "image_url") {
|
|
398
|
+
const match = part.image_url.url.match(/^data:([^;]+);base64,(.+)$/);
|
|
399
|
+
if (match) {
|
|
400
|
+
const mimeType = match[1];
|
|
401
|
+
return {
|
|
402
|
+
type: "image",
|
|
403
|
+
source: {
|
|
404
|
+
type: "base64",
|
|
405
|
+
media_type: mimeType,
|
|
406
|
+
data: match[2] || ""
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return { type: "text", text: "" };
|
|
412
|
+
}).filter((part) => part.text !== "");
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
role: m.role,
|
|
416
|
+
content
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
mapTool(tool2) {
|
|
421
|
+
return {
|
|
422
|
+
name: tool2.function.name,
|
|
423
|
+
description: tool2.function.description,
|
|
424
|
+
input_schema: tool2.function.parameters
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
// src/providers/gemini/index.ts
|
|
430
|
+
var import_generative_ai = require("@google/generative-ai");
|
|
431
|
+
var GeminiProvider = class {
|
|
432
|
+
constructor(options) {
|
|
433
|
+
this.name = "gemini";
|
|
434
|
+
this.client = new import_generative_ai.GoogleGenerativeAI(options.apiKey);
|
|
435
|
+
}
|
|
436
|
+
convertContent(content) {
|
|
437
|
+
if (!content) return "";
|
|
438
|
+
if (typeof content === "string") return content;
|
|
439
|
+
return content.map((part) => {
|
|
440
|
+
if (part.type === "text") {
|
|
441
|
+
return { text: part.text };
|
|
442
|
+
}
|
|
443
|
+
if (part.type === "image_url") {
|
|
444
|
+
const match = part.image_url.url.match(/^data:([^;]+);base64,(.+)$/);
|
|
445
|
+
if (match) {
|
|
446
|
+
return {
|
|
447
|
+
inlineData: {
|
|
448
|
+
mimeType: match[1],
|
|
449
|
+
data: match[2] || ""
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
return { text: "[Image Url not supported directly, please use base64 data uri]" };
|
|
454
|
+
}
|
|
455
|
+
return { text: "" };
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
async chat(options) {
|
|
459
|
+
const model = this.client.getGenerativeModel({
|
|
460
|
+
model: options.model || "gemini-pro",
|
|
461
|
+
tools: options.tools ? [{ functionDeclarations: options.tools.map(this.mapTool) }] : void 0
|
|
462
|
+
});
|
|
463
|
+
const chat = model.startChat({
|
|
464
|
+
history: this.mapHistory(options.messages),
|
|
465
|
+
generationConfig: {
|
|
466
|
+
maxOutputTokens: options.maxTokens,
|
|
467
|
+
temperature: options.temperature
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
const lastMsg = options.messages[options.messages.length - 1];
|
|
471
|
+
if (!lastMsg) {
|
|
472
|
+
return { message: { role: "assistant", content: "" } };
|
|
473
|
+
}
|
|
474
|
+
const content = this.convertContent(lastMsg.content);
|
|
475
|
+
const result = await chat.sendMessage(content);
|
|
476
|
+
const response = result.response;
|
|
477
|
+
const text = response.text();
|
|
478
|
+
const functionCalls = response.functionCalls();
|
|
479
|
+
let toolCalls = void 0;
|
|
480
|
+
if (functionCalls && functionCalls.length > 0) {
|
|
481
|
+
toolCalls = functionCalls.map((fc) => ({
|
|
482
|
+
id: fc.name,
|
|
483
|
+
// Gemini doesn't always provide unique call IDs, usage depends on flow.
|
|
484
|
+
type: "function",
|
|
485
|
+
function: {
|
|
486
|
+
name: fc.name,
|
|
487
|
+
arguments: JSON.stringify(fc.args)
|
|
488
|
+
}
|
|
489
|
+
}));
|
|
490
|
+
}
|
|
491
|
+
return {
|
|
492
|
+
message: {
|
|
493
|
+
role: "assistant",
|
|
494
|
+
content: text,
|
|
495
|
+
toolCalls
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
}
|
|
499
|
+
async *chatStream(options) {
|
|
500
|
+
const model = this.client.getGenerativeModel({
|
|
501
|
+
model: options.model || "gemini-pro",
|
|
502
|
+
tools: options.tools ? [{ functionDeclarations: options.tools.map(this.mapTool) }] : void 0
|
|
503
|
+
});
|
|
504
|
+
const chat = model.startChat({
|
|
505
|
+
history: this.mapHistory(options.messages),
|
|
506
|
+
generationConfig: {
|
|
507
|
+
maxOutputTokens: options.maxTokens,
|
|
508
|
+
temperature: options.temperature
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
const lastMsg = options.messages[options.messages.length - 1];
|
|
512
|
+
if (!lastMsg) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
const content = this.convertContent(lastMsg.content);
|
|
516
|
+
const result = await chat.sendMessageStream(content);
|
|
517
|
+
for await (const chunk of result.stream) {
|
|
518
|
+
const chunkText = chunk.text();
|
|
519
|
+
const functionCalls = chunk.functionCalls();
|
|
520
|
+
if (functionCalls && functionCalls.length > 0) {
|
|
521
|
+
for (const fc of functionCalls) {
|
|
522
|
+
yield {
|
|
523
|
+
delta: "",
|
|
524
|
+
toolCallDelta: {
|
|
525
|
+
index: 0,
|
|
526
|
+
// simplistic index
|
|
527
|
+
type: "function",
|
|
528
|
+
function: {
|
|
529
|
+
name: fc.name,
|
|
530
|
+
arguments: JSON.stringify(fc.args)
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
if (chunkText) {
|
|
537
|
+
yield {
|
|
538
|
+
delta: chunkText
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
mapHistory(messages) {
|
|
544
|
+
return messages.slice(0, -1).map((m) => {
|
|
545
|
+
const parts = [];
|
|
546
|
+
if (m.role === "assistant" && m.toolCalls) {
|
|
547
|
+
m.toolCalls.forEach((tc) => {
|
|
548
|
+
parts.push({
|
|
549
|
+
functionCall: {
|
|
550
|
+
name: tc.function.name,
|
|
551
|
+
args: JSON.parse(tc.function.arguments)
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
if (m.role === "tool") {
|
|
557
|
+
parts.push({
|
|
558
|
+
functionResponse: {
|
|
559
|
+
name: m.name || "unknown",
|
|
560
|
+
response: { content: m.content }
|
|
561
|
+
}
|
|
562
|
+
});
|
|
563
|
+
} else {
|
|
564
|
+
const contentParts = this.convertContent(m.content);
|
|
565
|
+
if (Array.isArray(contentParts)) {
|
|
566
|
+
parts.push(...contentParts);
|
|
567
|
+
} else if (contentParts) {
|
|
568
|
+
parts.push({ text: contentParts });
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return {
|
|
572
|
+
role: m.role === "user" ? "user" : "model",
|
|
573
|
+
parts
|
|
574
|
+
};
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
mapTool(tool2) {
|
|
578
|
+
return {
|
|
579
|
+
name: tool2.function.name,
|
|
580
|
+
description: tool2.function.description,
|
|
581
|
+
parameters: tool2.function.parameters
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
|
|
586
|
+
// src/providers/ollama/index.ts
|
|
587
|
+
var import_browser = require("ollama/browser");
|
|
588
|
+
var OllamaProvider = class {
|
|
589
|
+
constructor(options) {
|
|
590
|
+
this.name = "ollama";
|
|
591
|
+
this.client = new import_browser.Ollama({
|
|
592
|
+
host: options?.host || "http://127.0.0.1:11434",
|
|
593
|
+
fetch: options?.apiKey ? (url, init) => {
|
|
594
|
+
const headers = new Headers(init?.headers);
|
|
595
|
+
headers.set("Authorization", `Bearer ${options.apiKey}`);
|
|
596
|
+
return fetch(url, {
|
|
597
|
+
...init,
|
|
598
|
+
headers
|
|
599
|
+
});
|
|
600
|
+
} : void 0
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
async chat(options) {
|
|
604
|
+
const response = await this.client.chat({
|
|
605
|
+
model: options.model || "llama2",
|
|
606
|
+
messages: this.mapMessages(options.messages),
|
|
607
|
+
tools: options.tools?.map(this.mapTool),
|
|
608
|
+
stream: false,
|
|
609
|
+
// @ts-ignore - Ollama types might not be updated yet
|
|
610
|
+
think: options.think
|
|
611
|
+
});
|
|
612
|
+
let toolCalls = void 0;
|
|
613
|
+
if (response.message.tool_calls) {
|
|
614
|
+
toolCalls = response.message.tool_calls.map((tc) => ({
|
|
615
|
+
id: `call_${Math.random().toString(36).slice(2)}`,
|
|
616
|
+
type: "function",
|
|
617
|
+
function: {
|
|
618
|
+
name: tc.function.name,
|
|
619
|
+
arguments: JSON.stringify(tc.function.arguments)
|
|
620
|
+
}
|
|
621
|
+
}));
|
|
622
|
+
}
|
|
623
|
+
return {
|
|
624
|
+
message: {
|
|
625
|
+
role: "assistant",
|
|
626
|
+
content: response.message.content,
|
|
627
|
+
// @ts-ignore
|
|
628
|
+
thinking: response.message.thinking,
|
|
629
|
+
// Native thinking field
|
|
630
|
+
toolCalls
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
async *chatStream(options) {
|
|
635
|
+
const stream = await this.client.chat({
|
|
636
|
+
model: options.model || "llama2",
|
|
637
|
+
messages: this.mapMessages(options.messages),
|
|
638
|
+
tools: options.tools?.map(this.mapTool),
|
|
639
|
+
stream: true,
|
|
640
|
+
// @ts-ignore
|
|
641
|
+
think: options.think
|
|
642
|
+
});
|
|
643
|
+
for await (const part of stream) {
|
|
644
|
+
const chunk = {
|
|
645
|
+
delta: part.message.content
|
|
646
|
+
};
|
|
647
|
+
if (part.message.thinking) {
|
|
648
|
+
chunk.thinking = part.message.thinking;
|
|
649
|
+
}
|
|
650
|
+
if (part.message.tool_calls) {
|
|
651
|
+
for (let i = 0; i < part.message.tool_calls.length; i++) {
|
|
652
|
+
const tc = part.message.tool_calls[i];
|
|
653
|
+
chunk.toolCallDelta = {
|
|
654
|
+
index: i,
|
|
655
|
+
type: "function",
|
|
656
|
+
function: {
|
|
657
|
+
name: tc.function.name,
|
|
658
|
+
arguments: JSON.stringify(tc.function.arguments)
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
yield {
|
|
662
|
+
delta: "",
|
|
663
|
+
toolCallDelta: {
|
|
664
|
+
index: i,
|
|
665
|
+
type: "function",
|
|
666
|
+
function: {
|
|
667
|
+
name: tc.function.name,
|
|
668
|
+
arguments: JSON.stringify(tc.function.arguments)
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
if (!part.message.content && !part.message.thinking) continue;
|
|
674
|
+
}
|
|
675
|
+
yield chunk;
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
mapMessages(messages) {
|
|
679
|
+
return messages.map((m) => {
|
|
680
|
+
let content = "";
|
|
681
|
+
const images = [];
|
|
682
|
+
if (typeof m.content === "string") {
|
|
683
|
+
content = m.content || "";
|
|
684
|
+
} else if (Array.isArray(m.content)) {
|
|
685
|
+
for (const part of m.content) {
|
|
686
|
+
if (part.type === "text") {
|
|
687
|
+
content += part.text;
|
|
688
|
+
} else if (part.type === "image_url") {
|
|
689
|
+
const match = part.image_url.url.match(/^data:image\/[a-z]+;base64,(.+)$/);
|
|
690
|
+
if (match) {
|
|
691
|
+
images.push(match[1]);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
if (m.role === "tool") {
|
|
697
|
+
return {
|
|
698
|
+
role: "tool",
|
|
699
|
+
content,
|
|
700
|
+
// Ollama needs tool_name or name? Docs say tool_name in one example
|
|
701
|
+
// but python sdk usage shows name matching.
|
|
702
|
+
// REST API docs say `tool_name` for role `tool`.
|
|
703
|
+
name: m.name
|
|
704
|
+
// tool_name: m.name // redundancy
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
return {
|
|
708
|
+
role: m.role,
|
|
709
|
+
content,
|
|
710
|
+
images: images.length > 0 ? images : void 0,
|
|
711
|
+
tool_calls: m.toolCalls ? m.toolCalls.map((tc) => ({
|
|
712
|
+
type: "function",
|
|
713
|
+
function: {
|
|
714
|
+
name: tc.function.name,
|
|
715
|
+
arguments: JSON.parse(tc.function.arguments)
|
|
716
|
+
}
|
|
717
|
+
})) : void 0
|
|
718
|
+
};
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
mapTool(tool2) {
|
|
722
|
+
return {
|
|
723
|
+
type: "function",
|
|
724
|
+
function: {
|
|
725
|
+
name: tool2.function.name,
|
|
726
|
+
description: tool2.function.description,
|
|
727
|
+
parameters: tool2.function.parameters
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// src/providers/openai/index.ts
|
|
734
|
+
var import_openai = __toESM(require("openai"), 1);
|
|
735
|
+
var OpenAIProvider = class {
|
|
736
|
+
constructor(options) {
|
|
737
|
+
this.name = "openai";
|
|
738
|
+
this.client = new import_openai.default({
|
|
739
|
+
apiKey: options.apiKey,
|
|
740
|
+
dangerouslyAllowBrowser: options.dangerouslyAllowBrowser
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
async chat(options) {
|
|
744
|
+
const response = await this.client.chat.completions.create({
|
|
745
|
+
model: options.model,
|
|
746
|
+
messages: this.mapMessages(options.messages),
|
|
747
|
+
tools: options.tools?.map(this.mapTool),
|
|
748
|
+
temperature: options.temperature,
|
|
749
|
+
max_tokens: options.maxTokens
|
|
750
|
+
});
|
|
751
|
+
const choice = response.choices[0];
|
|
752
|
+
if (!choice) throw new Error("No choice returned from OpenAI");
|
|
753
|
+
return {
|
|
754
|
+
usage: response.usage ? {
|
|
755
|
+
promptTokens: response.usage.prompt_tokens,
|
|
756
|
+
completionTokens: response.usage.completion_tokens,
|
|
757
|
+
totalTokens: response.usage.total_tokens
|
|
758
|
+
} : void 0,
|
|
759
|
+
message: this.mapResponseMessage(choice.message)
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
async *chatStream(options) {
|
|
763
|
+
const stream = await this.client.chat.completions.create({
|
|
764
|
+
model: options.model,
|
|
765
|
+
messages: this.mapMessages(options.messages),
|
|
766
|
+
tools: options.tools?.map(this.mapTool),
|
|
767
|
+
temperature: options.temperature,
|
|
768
|
+
max_tokens: options.maxTokens,
|
|
769
|
+
stream: true
|
|
770
|
+
});
|
|
771
|
+
for await (const chunk of stream) {
|
|
772
|
+
const choice = chunk.choices[0];
|
|
773
|
+
if (!choice) continue;
|
|
774
|
+
const delta = choice.delta;
|
|
775
|
+
let toolCallDelta = void 0;
|
|
776
|
+
if (delta.tool_calls && delta.tool_calls.length > 0) {
|
|
777
|
+
const tc = delta.tool_calls[0];
|
|
778
|
+
if (tc) {
|
|
779
|
+
toolCallDelta = {
|
|
780
|
+
index: tc.index,
|
|
781
|
+
id: tc.id,
|
|
782
|
+
type: "function",
|
|
783
|
+
function: tc.function ? {
|
|
784
|
+
name: tc.function.name,
|
|
785
|
+
arguments: tc.function.arguments
|
|
786
|
+
} : void 0
|
|
787
|
+
};
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
yield {
|
|
791
|
+
delta: delta.content || "",
|
|
792
|
+
toolCallDelta,
|
|
793
|
+
usage: void 0
|
|
794
|
+
// OpenAI stream doesn't always perform usage
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
// --- Mappers ---
|
|
799
|
+
mapMessages(messages) {
|
|
800
|
+
return messages.map((m) => {
|
|
801
|
+
if (m.role === "tool") {
|
|
802
|
+
return {
|
|
803
|
+
role: "tool",
|
|
804
|
+
content: m.content || "",
|
|
805
|
+
tool_call_id: m.toolCallId || "unknown"
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
if (m.role === "user") {
|
|
809
|
+
if (Array.isArray(m.content)) {
|
|
810
|
+
return {
|
|
811
|
+
role: "user",
|
|
812
|
+
content: m.content.map((c) => {
|
|
813
|
+
if (c.type === "text") {
|
|
814
|
+
return { type: "text", text: c.text };
|
|
815
|
+
}
|
|
816
|
+
if (c.type === "image_url") {
|
|
817
|
+
return {
|
|
818
|
+
type: "image_url",
|
|
819
|
+
image_url: {
|
|
820
|
+
url: c.image_url.url,
|
|
821
|
+
detail: c.image_url.detail
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
return void 0;
|
|
826
|
+
}).filter(Boolean)
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
return { role: "user", content: m.content || "" };
|
|
830
|
+
}
|
|
831
|
+
if (m.role === "system") {
|
|
832
|
+
return { role: "system", content: (typeof m.content === "string" ? m.content : "") || "" };
|
|
833
|
+
}
|
|
834
|
+
if (m.role === "assistant") {
|
|
835
|
+
const tool_calls = m.toolCalls?.map((tc) => ({
|
|
836
|
+
id: tc.id,
|
|
837
|
+
type: "function",
|
|
838
|
+
function: {
|
|
839
|
+
name: tc.function.name,
|
|
840
|
+
arguments: tc.function.arguments
|
|
841
|
+
}
|
|
842
|
+
}));
|
|
843
|
+
return {
|
|
844
|
+
role: "assistant",
|
|
845
|
+
content: m.content || null,
|
|
846
|
+
tool_calls
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
throw new Error(`Unknown role: ${m.role}`);
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
mapTool(tool2) {
|
|
853
|
+
return {
|
|
854
|
+
type: "function",
|
|
855
|
+
function: {
|
|
856
|
+
name: tool2.function.name,
|
|
857
|
+
description: tool2.function.description,
|
|
858
|
+
parameters: tool2.function.parameters
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
mapResponseMessage(msg) {
|
|
863
|
+
return {
|
|
864
|
+
role: msg.role,
|
|
865
|
+
content: msg.content || "",
|
|
866
|
+
toolCalls: msg.tool_calls?.map((tc) => {
|
|
867
|
+
if (tc.type === "function") {
|
|
868
|
+
return {
|
|
869
|
+
id: tc.id,
|
|
870
|
+
function: {
|
|
871
|
+
name: tc.function.name,
|
|
872
|
+
arguments: tc.function.arguments
|
|
873
|
+
},
|
|
874
|
+
type: "function"
|
|
875
|
+
};
|
|
876
|
+
}
|
|
877
|
+
return void 0;
|
|
878
|
+
}).filter(Boolean)
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/providers/grok/index.ts
|
|
884
|
+
var import_openai2 = __toESM(require("openai"), 1);
|
|
885
|
+
var GrokProvider = class {
|
|
886
|
+
constructor(options) {
|
|
887
|
+
this.name = "grok";
|
|
888
|
+
this.client = new import_openai2.default({
|
|
889
|
+
apiKey: options.apiKey,
|
|
890
|
+
baseURL: "https://api.x.ai/v1"
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
async chat(options) {
|
|
894
|
+
const response = await this.client.chat.completions.create({
|
|
895
|
+
model: options.model || "grok-beta",
|
|
896
|
+
messages: options.messages,
|
|
897
|
+
// Simple cast for compat
|
|
898
|
+
temperature: options.temperature,
|
|
899
|
+
max_tokens: options.maxTokens
|
|
900
|
+
});
|
|
901
|
+
const choice = response.choices[0];
|
|
902
|
+
return {
|
|
903
|
+
message: {
|
|
904
|
+
role: "assistant",
|
|
905
|
+
content: choice?.message?.content || ""
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
async *chatStream(options) {
|
|
910
|
+
const stream = await this.client.chat.completions.create({
|
|
911
|
+
model: options.model || "grok-beta",
|
|
912
|
+
messages: options.messages,
|
|
913
|
+
stream: true
|
|
914
|
+
});
|
|
915
|
+
for await (const chunk of stream) {
|
|
916
|
+
yield {
|
|
917
|
+
delta: chunk.choices[0]?.delta?.content || ""
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
|
|
923
|
+
// src/providers/openrouter/index.ts
|
|
924
|
+
var import_openai3 = __toESM(require("openai"), 1);
|
|
925
|
+
var OpenRouterProvider = class {
|
|
926
|
+
constructor(options) {
|
|
927
|
+
this.name = "openrouter";
|
|
928
|
+
this.client = new import_openai3.default({
|
|
929
|
+
apiKey: options.apiKey,
|
|
930
|
+
baseURL: "https://openrouter.ai/api/v1",
|
|
931
|
+
defaultHeaders: {
|
|
932
|
+
"HTTP-Referer": "https://tekimax.com",
|
|
933
|
+
// Required by OpenRouter
|
|
934
|
+
"X-Title": "Tekimax SDK"
|
|
935
|
+
}
|
|
936
|
+
});
|
|
937
|
+
}
|
|
938
|
+
async chat(options) {
|
|
939
|
+
const response = await this.client.chat.completions.create({
|
|
940
|
+
model: options.model,
|
|
941
|
+
messages: options.messages,
|
|
942
|
+
temperature: options.temperature,
|
|
943
|
+
max_tokens: options.maxTokens
|
|
944
|
+
});
|
|
945
|
+
const choice = response.choices[0];
|
|
946
|
+
return {
|
|
947
|
+
message: {
|
|
948
|
+
role: "assistant",
|
|
949
|
+
content: choice?.message?.content || ""
|
|
950
|
+
}
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
async *chatStream(options) {
|
|
954
|
+
const stream = await this.client.chat.completions.create({
|
|
955
|
+
model: options.model,
|
|
956
|
+
messages: options.messages,
|
|
957
|
+
stream: true
|
|
958
|
+
});
|
|
959
|
+
for await (const chunk of stream) {
|
|
960
|
+
yield {
|
|
961
|
+
delta: chunk.choices[0]?.delta?.content || ""
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
};
|
|
966
|
+
|
|
967
|
+
// src/gen/types.ts
|
|
968
|
+
var types_exports = {};
|
|
969
|
+
__export(types_exports, {
|
|
970
|
+
allowedToolChoiceTypeEnum: () => allowedToolChoiceTypeEnum,
|
|
971
|
+
allowedToolsParamTypeEnum: () => allowedToolsParamTypeEnum,
|
|
972
|
+
assistantMessageItemParamRoleEnum: () => assistantMessageItemParamRoleEnum,
|
|
973
|
+
assistantMessageItemParamTypeEnum: () => assistantMessageItemParamTypeEnum,
|
|
974
|
+
detailEnumEnum: () => detailEnumEnum,
|
|
975
|
+
developerMessageItemParamRoleEnum: () => developerMessageItemParamRoleEnum,
|
|
976
|
+
developerMessageItemParamTypeEnum: () => developerMessageItemParamTypeEnum,
|
|
977
|
+
errorStreamingEventTypeEnum: () => errorStreamingEventTypeEnum,
|
|
978
|
+
functionCallItemParamTypeEnum: () => functionCallItemParamTypeEnum,
|
|
979
|
+
functionCallItemStatusEnum: () => functionCallItemStatusEnum,
|
|
980
|
+
functionCallOutputItemParamTypeEnum: () => functionCallOutputItemParamTypeEnum,
|
|
981
|
+
functionCallOutputStatusEnumEnum: () => functionCallOutputStatusEnumEnum,
|
|
982
|
+
functionCallOutputTypeEnum: () => functionCallOutputTypeEnum,
|
|
983
|
+
functionCallStatusEnum: () => functionCallStatusEnum,
|
|
984
|
+
functionCallTypeEnum: () => functionCallTypeEnum,
|
|
985
|
+
functionToolChoiceTypeEnum: () => functionToolChoiceTypeEnum,
|
|
986
|
+
functionToolParamTypeEnum: () => functionToolParamTypeEnum,
|
|
987
|
+
functionToolTypeEnum: () => functionToolTypeEnum,
|
|
988
|
+
imageDetailEnum: () => imageDetailEnum,
|
|
989
|
+
includeEnumEnum: () => includeEnumEnum,
|
|
990
|
+
inputFileContentParamTypeEnum: () => inputFileContentParamTypeEnum,
|
|
991
|
+
inputFileContentTypeEnum: () => inputFileContentTypeEnum,
|
|
992
|
+
inputImageContentParamAutoParamTypeEnum: () => inputImageContentParamAutoParamTypeEnum,
|
|
993
|
+
inputImageContentTypeEnum: () => inputImageContentTypeEnum,
|
|
994
|
+
inputTextContentParamTypeEnum: () => inputTextContentParamTypeEnum,
|
|
995
|
+
inputTextContentTypeEnum: () => inputTextContentTypeEnum,
|
|
996
|
+
inputVideoContentTypeEnum: () => inputVideoContentTypeEnum,
|
|
997
|
+
itemReferenceParamTypeEnum: () => itemReferenceParamTypeEnum,
|
|
998
|
+
jsonObjectResponseFormatTypeEnum: () => jsonObjectResponseFormatTypeEnum,
|
|
999
|
+
jsonSchemaResponseFormatParamTypeEnum: () => jsonSchemaResponseFormatParamTypeEnum,
|
|
1000
|
+
jsonSchemaResponseFormatTypeEnum: () => jsonSchemaResponseFormatTypeEnum,
|
|
1001
|
+
messageRoleEnum: () => messageRoleEnum,
|
|
1002
|
+
messageStatusEnum: () => messageStatusEnum,
|
|
1003
|
+
messageTypeEnum: () => messageTypeEnum,
|
|
1004
|
+
outputTextContentParamTypeEnum: () => outputTextContentParamTypeEnum,
|
|
1005
|
+
outputTextContentTypeEnum: () => outputTextContentTypeEnum,
|
|
1006
|
+
reasoningBodyTypeEnum: () => reasoningBodyTypeEnum,
|
|
1007
|
+
reasoningEffortEnumEnum: () => reasoningEffortEnumEnum,
|
|
1008
|
+
reasoningItemParamTypeEnum: () => reasoningItemParamTypeEnum,
|
|
1009
|
+
reasoningSummaryContentParamTypeEnum: () => reasoningSummaryContentParamTypeEnum,
|
|
1010
|
+
reasoningSummaryEnumEnum: () => reasoningSummaryEnumEnum,
|
|
1011
|
+
reasoningTextContentTypeEnum: () => reasoningTextContentTypeEnum,
|
|
1012
|
+
refusalContentParamTypeEnum: () => refusalContentParamTypeEnum,
|
|
1013
|
+
refusalContentTypeEnum: () => refusalContentTypeEnum,
|
|
1014
|
+
responseCompletedStreamingEventTypeEnum: () => responseCompletedStreamingEventTypeEnum,
|
|
1015
|
+
responseContentPartAddedStreamingEventTypeEnum: () => responseContentPartAddedStreamingEventTypeEnum,
|
|
1016
|
+
responseContentPartDoneStreamingEventTypeEnum: () => responseContentPartDoneStreamingEventTypeEnum,
|
|
1017
|
+
responseCreatedStreamingEventTypeEnum: () => responseCreatedStreamingEventTypeEnum,
|
|
1018
|
+
responseFailedStreamingEventTypeEnum: () => responseFailedStreamingEventTypeEnum,
|
|
1019
|
+
responseFunctionCallArgumentsDeltaStreamingEventTypeEnum: () => responseFunctionCallArgumentsDeltaStreamingEventTypeEnum,
|
|
1020
|
+
responseFunctionCallArgumentsDoneStreamingEventTypeEnum: () => responseFunctionCallArgumentsDoneStreamingEventTypeEnum,
|
|
1021
|
+
responseInProgressStreamingEventTypeEnum: () => responseInProgressStreamingEventTypeEnum,
|
|
1022
|
+
responseIncompleteStreamingEventTypeEnum: () => responseIncompleteStreamingEventTypeEnum,
|
|
1023
|
+
responseOutputItemAddedStreamingEventTypeEnum: () => responseOutputItemAddedStreamingEventTypeEnum,
|
|
1024
|
+
responseOutputItemDoneStreamingEventTypeEnum: () => responseOutputItemDoneStreamingEventTypeEnum,
|
|
1025
|
+
responseOutputTextAnnotationAddedStreamingEventTypeEnum: () => responseOutputTextAnnotationAddedStreamingEventTypeEnum,
|
|
1026
|
+
responseOutputTextDeltaStreamingEventTypeEnum: () => responseOutputTextDeltaStreamingEventTypeEnum,
|
|
1027
|
+
responseOutputTextDoneStreamingEventTypeEnum: () => responseOutputTextDoneStreamingEventTypeEnum,
|
|
1028
|
+
responseQueuedStreamingEventTypeEnum: () => responseQueuedStreamingEventTypeEnum,
|
|
1029
|
+
responseReasoningDeltaStreamingEventTypeEnum: () => responseReasoningDeltaStreamingEventTypeEnum,
|
|
1030
|
+
responseReasoningDoneStreamingEventTypeEnum: () => responseReasoningDoneStreamingEventTypeEnum,
|
|
1031
|
+
responseReasoningSummaryDeltaStreamingEventTypeEnum: () => responseReasoningSummaryDeltaStreamingEventTypeEnum,
|
|
1032
|
+
responseReasoningSummaryDoneStreamingEventTypeEnum: () => responseReasoningSummaryDoneStreamingEventTypeEnum,
|
|
1033
|
+
responseReasoningSummaryPartAddedStreamingEventTypeEnum: () => responseReasoningSummaryPartAddedStreamingEventTypeEnum,
|
|
1034
|
+
responseReasoningSummaryPartDoneStreamingEventTypeEnum: () => responseReasoningSummaryPartDoneStreamingEventTypeEnum,
|
|
1035
|
+
responseRefusalDeltaStreamingEventTypeEnum: () => responseRefusalDeltaStreamingEventTypeEnum,
|
|
1036
|
+
responseRefusalDoneStreamingEventTypeEnum: () => responseRefusalDoneStreamingEventTypeEnum,
|
|
1037
|
+
responseResourceObjectEnum: () => responseResourceObjectEnum,
|
|
1038
|
+
serviceTierEnumEnum: () => serviceTierEnumEnum,
|
|
1039
|
+
specificFunctionParamTypeEnum: () => specificFunctionParamTypeEnum,
|
|
1040
|
+
summaryTextContentTypeEnum: () => summaryTextContentTypeEnum,
|
|
1041
|
+
systemMessageItemParamRoleEnum: () => systemMessageItemParamRoleEnum,
|
|
1042
|
+
systemMessageItemParamTypeEnum: () => systemMessageItemParamTypeEnum,
|
|
1043
|
+
textContentTypeEnum: () => textContentTypeEnum,
|
|
1044
|
+
textResponseFormatTypeEnum: () => textResponseFormatTypeEnum,
|
|
1045
|
+
toolChoiceValueEnumEnum: () => toolChoiceValueEnumEnum,
|
|
1046
|
+
truncationEnumEnum: () => truncationEnumEnum,
|
|
1047
|
+
urlCitationBodyTypeEnum: () => urlCitationBodyTypeEnum,
|
|
1048
|
+
urlCitationParamTypeEnum: () => urlCitationParamTypeEnum,
|
|
1049
|
+
userMessageItemParamRoleEnum: () => userMessageItemParamRoleEnum,
|
|
1050
|
+
userMessageItemParamTypeEnum: () => userMessageItemParamTypeEnum,
|
|
1051
|
+
verbosityEnumEnum: () => verbosityEnumEnum
|
|
1052
|
+
});
|
|
1053
|
+
var itemReferenceParamTypeEnum = {
|
|
1054
|
+
item_reference: "item_reference"
|
|
1055
|
+
};
|
|
1056
|
+
var reasoningSummaryContentParamTypeEnum = {
|
|
1057
|
+
summary_text: "summary_text"
|
|
1058
|
+
};
|
|
1059
|
+
var reasoningItemParamTypeEnum = {
|
|
1060
|
+
reasoning: "reasoning"
|
|
1061
|
+
};
|
|
1062
|
+
var inputTextContentParamTypeEnum = {
|
|
1063
|
+
input_text: "input_text"
|
|
1064
|
+
};
|
|
1065
|
+
var detailEnumEnum = {
|
|
1066
|
+
low: "low",
|
|
1067
|
+
high: "high",
|
|
1068
|
+
auto: "auto"
|
|
1069
|
+
};
|
|
1070
|
+
var imageDetailEnum = {
|
|
1071
|
+
low: "low",
|
|
1072
|
+
high: "high",
|
|
1073
|
+
auto: "auto"
|
|
1074
|
+
};
|
|
1075
|
+
var inputImageContentParamAutoParamTypeEnum = {
|
|
1076
|
+
input_image: "input_image"
|
|
1077
|
+
};
|
|
1078
|
+
var inputFileContentParamTypeEnum = {
|
|
1079
|
+
input_file: "input_file"
|
|
1080
|
+
};
|
|
1081
|
+
var userMessageItemParamTypeEnum = {
|
|
1082
|
+
message: "message"
|
|
1083
|
+
};
|
|
1084
|
+
var userMessageItemParamRoleEnum = {
|
|
1085
|
+
user: "user"
|
|
1086
|
+
};
|
|
1087
|
+
var systemMessageItemParamTypeEnum = {
|
|
1088
|
+
message: "message"
|
|
1089
|
+
};
|
|
1090
|
+
var systemMessageItemParamRoleEnum = {
|
|
1091
|
+
system: "system"
|
|
1092
|
+
};
|
|
1093
|
+
var developerMessageItemParamTypeEnum = {
|
|
1094
|
+
message: "message"
|
|
1095
|
+
};
|
|
1096
|
+
var developerMessageItemParamRoleEnum = {
|
|
1097
|
+
developer: "developer"
|
|
1098
|
+
};
|
|
1099
|
+
var urlCitationParamTypeEnum = {
|
|
1100
|
+
url_citation: "url_citation"
|
|
1101
|
+
};
|
|
1102
|
+
var outputTextContentParamTypeEnum = {
|
|
1103
|
+
output_text: "output_text"
|
|
1104
|
+
};
|
|
1105
|
+
var refusalContentParamTypeEnum = {
|
|
1106
|
+
refusal: "refusal"
|
|
1107
|
+
};
|
|
1108
|
+
var assistantMessageItemParamTypeEnum = {
|
|
1109
|
+
message: "message"
|
|
1110
|
+
};
|
|
1111
|
+
var assistantMessageItemParamRoleEnum = {
|
|
1112
|
+
assistant: "assistant"
|
|
1113
|
+
};
|
|
1114
|
+
var functionCallItemStatusEnum = {
|
|
1115
|
+
in_progress: "in_progress",
|
|
1116
|
+
completed: "completed",
|
|
1117
|
+
incomplete: "incomplete"
|
|
1118
|
+
};
|
|
1119
|
+
var functionCallStatusEnum = {
|
|
1120
|
+
in_progress: "in_progress",
|
|
1121
|
+
completed: "completed",
|
|
1122
|
+
incomplete: "incomplete"
|
|
1123
|
+
};
|
|
1124
|
+
var functionCallItemParamTypeEnum = {
|
|
1125
|
+
function_call: "function_call"
|
|
1126
|
+
};
|
|
1127
|
+
var inputVideoContentTypeEnum = {
|
|
1128
|
+
input_video: "input_video"
|
|
1129
|
+
};
|
|
1130
|
+
var functionCallOutputItemParamTypeEnum = {
|
|
1131
|
+
function_call_output: "function_call_output"
|
|
1132
|
+
};
|
|
1133
|
+
var includeEnumEnum = {
|
|
1134
|
+
"reasoning.encrypted_content": "reasoning.encrypted_content",
|
|
1135
|
+
"message.output_text.logprobs": "message.output_text.logprobs"
|
|
1136
|
+
};
|
|
1137
|
+
var functionToolParamTypeEnum = {
|
|
1138
|
+
function: "function"
|
|
1139
|
+
};
|
|
1140
|
+
var specificFunctionParamTypeEnum = {
|
|
1141
|
+
function: "function"
|
|
1142
|
+
};
|
|
1143
|
+
var toolChoiceValueEnumEnum = {
|
|
1144
|
+
none: "none",
|
|
1145
|
+
auto: "auto",
|
|
1146
|
+
required: "required"
|
|
1147
|
+
};
|
|
1148
|
+
var allowedToolsParamTypeEnum = {
|
|
1149
|
+
allowed_tools: "allowed_tools"
|
|
1150
|
+
};
|
|
1151
|
+
var verbosityEnumEnum = {
|
|
1152
|
+
low: "low",
|
|
1153
|
+
medium: "medium",
|
|
1154
|
+
high: "high"
|
|
1155
|
+
};
|
|
1156
|
+
var textResponseFormatTypeEnum = {
|
|
1157
|
+
text: "text"
|
|
1158
|
+
};
|
|
1159
|
+
var jsonSchemaResponseFormatParamTypeEnum = {
|
|
1160
|
+
json_schema: "json_schema"
|
|
1161
|
+
};
|
|
1162
|
+
var reasoningEffortEnumEnum = {
|
|
1163
|
+
none: "none",
|
|
1164
|
+
low: "low",
|
|
1165
|
+
medium: "medium",
|
|
1166
|
+
high: "high",
|
|
1167
|
+
xhigh: "xhigh"
|
|
1168
|
+
};
|
|
1169
|
+
var reasoningSummaryEnumEnum = {
|
|
1170
|
+
concise: "concise",
|
|
1171
|
+
detailed: "detailed",
|
|
1172
|
+
auto: "auto"
|
|
1173
|
+
};
|
|
1174
|
+
var truncationEnumEnum = {
|
|
1175
|
+
auto: "auto",
|
|
1176
|
+
disabled: "disabled"
|
|
1177
|
+
};
|
|
1178
|
+
var serviceTierEnumEnum = {
|
|
1179
|
+
auto: "auto",
|
|
1180
|
+
default: "default",
|
|
1181
|
+
flex: "flex",
|
|
1182
|
+
priority: "priority"
|
|
1183
|
+
};
|
|
1184
|
+
var messageRoleEnum = {
|
|
1185
|
+
user: "user",
|
|
1186
|
+
assistant: "assistant",
|
|
1187
|
+
system: "system",
|
|
1188
|
+
developer: "developer"
|
|
1189
|
+
};
|
|
1190
|
+
var inputTextContentTypeEnum = {
|
|
1191
|
+
input_text: "input_text"
|
|
1192
|
+
};
|
|
1193
|
+
var urlCitationBodyTypeEnum = {
|
|
1194
|
+
url_citation: "url_citation"
|
|
1195
|
+
};
|
|
1196
|
+
var outputTextContentTypeEnum = {
|
|
1197
|
+
output_text: "output_text"
|
|
1198
|
+
};
|
|
1199
|
+
var textContentTypeEnum = {
|
|
1200
|
+
text: "text"
|
|
1201
|
+
};
|
|
1202
|
+
var summaryTextContentTypeEnum = {
|
|
1203
|
+
summary_text: "summary_text"
|
|
1204
|
+
};
|
|
1205
|
+
var reasoningTextContentTypeEnum = {
|
|
1206
|
+
reasoning_text: "reasoning_text"
|
|
1207
|
+
};
|
|
1208
|
+
var refusalContentTypeEnum = {
|
|
1209
|
+
refusal: "refusal"
|
|
1210
|
+
};
|
|
1211
|
+
var inputImageContentTypeEnum = {
|
|
1212
|
+
input_image: "input_image"
|
|
1213
|
+
};
|
|
1214
|
+
var inputFileContentTypeEnum = {
|
|
1215
|
+
input_file: "input_file"
|
|
1216
|
+
};
|
|
1217
|
+
var messageStatusEnum = {
|
|
1218
|
+
in_progress: "in_progress",
|
|
1219
|
+
completed: "completed",
|
|
1220
|
+
incomplete: "incomplete"
|
|
1221
|
+
};
|
|
1222
|
+
var messageTypeEnum = {
|
|
1223
|
+
message: "message"
|
|
1224
|
+
};
|
|
1225
|
+
var functionCallTypeEnum = {
|
|
1226
|
+
function_call: "function_call"
|
|
1227
|
+
};
|
|
1228
|
+
var functionCallOutputStatusEnumEnum = {
|
|
1229
|
+
in_progress: "in_progress",
|
|
1230
|
+
completed: "completed",
|
|
1231
|
+
incomplete: "incomplete"
|
|
1232
|
+
};
|
|
1233
|
+
var functionCallOutputTypeEnum = {
|
|
1234
|
+
function_call_output: "function_call_output"
|
|
1235
|
+
};
|
|
1236
|
+
var reasoningBodyTypeEnum = {
|
|
1237
|
+
reasoning: "reasoning"
|
|
1238
|
+
};
|
|
1239
|
+
var functionToolTypeEnum = {
|
|
1240
|
+
function: "function"
|
|
1241
|
+
};
|
|
1242
|
+
var functionToolChoiceTypeEnum = {
|
|
1243
|
+
function: "function"
|
|
1244
|
+
};
|
|
1245
|
+
var allowedToolChoiceTypeEnum = {
|
|
1246
|
+
allowed_tools: "allowed_tools"
|
|
1247
|
+
};
|
|
1248
|
+
var jsonObjectResponseFormatTypeEnum = {
|
|
1249
|
+
json_object: "json_object"
|
|
1250
|
+
};
|
|
1251
|
+
var jsonSchemaResponseFormatTypeEnum = {
|
|
1252
|
+
json_schema: "json_schema"
|
|
1253
|
+
};
|
|
1254
|
+
var responseResourceObjectEnum = {
|
|
1255
|
+
response: "response"
|
|
1256
|
+
};
|
|
1257
|
+
var responseCreatedStreamingEventTypeEnum = {
|
|
1258
|
+
"response.created": "response.created"
|
|
1259
|
+
};
|
|
1260
|
+
var responseQueuedStreamingEventTypeEnum = {
|
|
1261
|
+
"response.queued": "response.queued"
|
|
1262
|
+
};
|
|
1263
|
+
var responseInProgressStreamingEventTypeEnum = {
|
|
1264
|
+
"response.in_progress": "response.in_progress"
|
|
1265
|
+
};
|
|
1266
|
+
var responseCompletedStreamingEventTypeEnum = {
|
|
1267
|
+
"response.completed": "response.completed"
|
|
1268
|
+
};
|
|
1269
|
+
var responseFailedStreamingEventTypeEnum = {
|
|
1270
|
+
"response.failed": "response.failed"
|
|
1271
|
+
};
|
|
1272
|
+
var responseIncompleteStreamingEventTypeEnum = {
|
|
1273
|
+
"response.incomplete": "response.incomplete"
|
|
1274
|
+
};
|
|
1275
|
+
var responseOutputItemAddedStreamingEventTypeEnum = {
|
|
1276
|
+
"response.output_item.added": "response.output_item.added"
|
|
1277
|
+
};
|
|
1278
|
+
var responseOutputItemDoneStreamingEventTypeEnum = {
|
|
1279
|
+
"response.output_item.done": "response.output_item.done"
|
|
1280
|
+
};
|
|
1281
|
+
var responseReasoningSummaryPartAddedStreamingEventTypeEnum = {
|
|
1282
|
+
"response.reasoning_summary_part.added": "response.reasoning_summary_part.added"
|
|
1283
|
+
};
|
|
1284
|
+
var responseReasoningSummaryPartDoneStreamingEventTypeEnum = {
|
|
1285
|
+
"response.reasoning_summary_part.done": "response.reasoning_summary_part.done"
|
|
1286
|
+
};
|
|
1287
|
+
var responseContentPartAddedStreamingEventTypeEnum = {
|
|
1288
|
+
"response.content_part.added": "response.content_part.added"
|
|
1289
|
+
};
|
|
1290
|
+
var responseContentPartDoneStreamingEventTypeEnum = {
|
|
1291
|
+
"response.content_part.done": "response.content_part.done"
|
|
1292
|
+
};
|
|
1293
|
+
var responseOutputTextDeltaStreamingEventTypeEnum = {
|
|
1294
|
+
"response.output_text.delta": "response.output_text.delta"
|
|
1295
|
+
};
|
|
1296
|
+
var responseOutputTextDoneStreamingEventTypeEnum = {
|
|
1297
|
+
"response.output_text.done": "response.output_text.done"
|
|
1298
|
+
};
|
|
1299
|
+
var responseRefusalDeltaStreamingEventTypeEnum = {
|
|
1300
|
+
"response.refusal.delta": "response.refusal.delta"
|
|
1301
|
+
};
|
|
1302
|
+
var responseRefusalDoneStreamingEventTypeEnum = {
|
|
1303
|
+
"response.refusal.done": "response.refusal.done"
|
|
1304
|
+
};
|
|
1305
|
+
var responseReasoningDeltaStreamingEventTypeEnum = {
|
|
1306
|
+
"response.reasoning.delta": "response.reasoning.delta"
|
|
1307
|
+
};
|
|
1308
|
+
var responseReasoningDoneStreamingEventTypeEnum = {
|
|
1309
|
+
"response.reasoning.done": "response.reasoning.done"
|
|
1310
|
+
};
|
|
1311
|
+
var responseReasoningSummaryDeltaStreamingEventTypeEnum = {
|
|
1312
|
+
"response.reasoning_summary_text.delta": "response.reasoning_summary_text.delta"
|
|
1313
|
+
};
|
|
1314
|
+
var responseReasoningSummaryDoneStreamingEventTypeEnum = {
|
|
1315
|
+
"response.reasoning_summary_text.done": "response.reasoning_summary_text.done"
|
|
1316
|
+
};
|
|
1317
|
+
var responseOutputTextAnnotationAddedStreamingEventTypeEnum = {
|
|
1318
|
+
"response.output_text.annotation.added": "response.output_text.annotation.added"
|
|
1319
|
+
};
|
|
1320
|
+
var responseFunctionCallArgumentsDeltaStreamingEventTypeEnum = {
|
|
1321
|
+
"response.function_call_arguments.delta": "response.function_call_arguments.delta"
|
|
1322
|
+
};
|
|
1323
|
+
var responseFunctionCallArgumentsDoneStreamingEventTypeEnum = {
|
|
1324
|
+
"response.function_call_arguments.done": "response.function_call_arguments.done"
|
|
1325
|
+
};
|
|
1326
|
+
var errorStreamingEventTypeEnum = {
|
|
1327
|
+
error: "error"
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
// src/core/tool.ts
|
|
1331
|
+
function tool(def) {
|
|
1332
|
+
return def;
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
// src/core/generate.ts
|
|
1336
|
+
async function generateText({
|
|
1337
|
+
adapter,
|
|
1338
|
+
...options
|
|
1339
|
+
}) {
|
|
1340
|
+
const { model, tools, maxSteps = 1, temperature, maxTokens, signal } = options;
|
|
1341
|
+
const currentMessages = [...options.messages];
|
|
1342
|
+
let steps = 0;
|
|
1343
|
+
const toolDefinitions = tools ? Object.values(tools) : void 0;
|
|
1344
|
+
while (steps < maxSteps) {
|
|
1345
|
+
steps++;
|
|
1346
|
+
const result = await adapter.chat({
|
|
1347
|
+
model,
|
|
1348
|
+
messages: currentMessages,
|
|
1349
|
+
tools: toolDefinitions,
|
|
1350
|
+
temperature,
|
|
1351
|
+
maxTokens,
|
|
1352
|
+
signal
|
|
1353
|
+
});
|
|
1354
|
+
const { message } = result;
|
|
1355
|
+
currentMessages.push(message);
|
|
1356
|
+
if (!message.toolCalls || message.toolCalls.length === 0) {
|
|
1357
|
+
return {
|
|
1358
|
+
text: typeof message.content === "string" ? message.content || "" : Array.isArray(message.content) ? message.content.filter((p) => p.type === "text").map((p) => p.text).join("") : "",
|
|
1359
|
+
toolCalls: [],
|
|
1360
|
+
toolResults: [],
|
|
1361
|
+
finishReason: "stop",
|
|
1362
|
+
usage: result.usage || { promptTokens: 0, completionTokens: 0, totalTokens: 0 }
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
const toolResults = await Promise.all(
|
|
1366
|
+
message.toolCalls.map(async (call) => {
|
|
1367
|
+
const tool2 = tools?.[call.function.name];
|
|
1368
|
+
if (!tool2) {
|
|
1369
|
+
return {
|
|
1370
|
+
id: call.id,
|
|
1371
|
+
result: `Error: Tool ${call.function.name} not found`
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
try {
|
|
1375
|
+
const args = JSON.parse(call.function.arguments);
|
|
1376
|
+
const output = await tool2.execute(args);
|
|
1377
|
+
return {
|
|
1378
|
+
id: call.id,
|
|
1379
|
+
result: output
|
|
1380
|
+
};
|
|
1381
|
+
} catch (error) {
|
|
1382
|
+
return {
|
|
1383
|
+
id: call.id,
|
|
1384
|
+
result: `Error executing tool: ${error.message}`
|
|
1385
|
+
};
|
|
1386
|
+
}
|
|
1387
|
+
})
|
|
1388
|
+
);
|
|
1389
|
+
for (const res of toolResults) {
|
|
1390
|
+
currentMessages.push({
|
|
1391
|
+
role: "tool",
|
|
1392
|
+
content: JSON.stringify(res.result),
|
|
1393
|
+
toolCallId: res.id,
|
|
1394
|
+
name: message.toolCalls.find((c) => c.id === res.id)?.function.name
|
|
1395
|
+
});
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
return {
|
|
1399
|
+
text: "",
|
|
1400
|
+
toolCalls: [],
|
|
1401
|
+
toolResults: [],
|
|
1402
|
+
finishReason: "length",
|
|
1403
|
+
// or 'tool_calls' if strictly ending on tools
|
|
1404
|
+
usage: { promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
1405
|
+
warnings: ["Max steps reached"]
|
|
1406
|
+
};
|
|
1407
|
+
}
|
|
1408
|
+
|
|
1409
|
+
// src/core/utils.ts
|
|
1410
|
+
var fileToBase64 = (file) => {
|
|
1411
|
+
return new Promise((resolve, reject) => {
|
|
1412
|
+
const reader = new FileReader();
|
|
1413
|
+
reader.readAsDataURL(file);
|
|
1414
|
+
reader.onload = () => resolve(reader.result);
|
|
1415
|
+
reader.onerror = (error) => reject(error);
|
|
1416
|
+
});
|
|
1417
|
+
};
|
|
1418
|
+
var parseThinking = (content) => {
|
|
1419
|
+
const thinkRegex = /<think>([\s\S]*?)<\/think>/;
|
|
1420
|
+
const match = content.match(thinkRegex);
|
|
1421
|
+
if (match) {
|
|
1422
|
+
return {
|
|
1423
|
+
think: match[1],
|
|
1424
|
+
rest: content.replace(thinkRegex, "").trim()
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
if (content.startsWith("<think>")) {
|
|
1428
|
+
return {
|
|
1429
|
+
think: content.replace("<think>", ""),
|
|
1430
|
+
rest: ""
|
|
1431
|
+
// Still thinking
|
|
1432
|
+
};
|
|
1433
|
+
}
|
|
1434
|
+
return { think: null, rest: content };
|
|
1435
|
+
};
|
|
1436
|
+
|
|
1437
|
+
// src/namespaces/text.ts
|
|
1438
|
+
var TextNamespace = class {
|
|
1439
|
+
constructor(provider) {
|
|
1440
|
+
this.provider = provider;
|
|
1441
|
+
}
|
|
1442
|
+
/**
|
|
1443
|
+
* Generate text from a prompt (Chat Completion).
|
|
1444
|
+
*/
|
|
1445
|
+
async generate(options) {
|
|
1446
|
+
return this.provider.chat(options);
|
|
1447
|
+
}
|
|
1448
|
+
/**
|
|
1449
|
+
* Stream text generation.
|
|
1450
|
+
*/
|
|
1451
|
+
async *generateStream(options) {
|
|
1452
|
+
for await (const chunk of this.provider.chatStream(options)) {
|
|
1453
|
+
yield chunk;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
// Alias for 'chat' to match OpenAI conventions if needed
|
|
1457
|
+
get chat() {
|
|
1458
|
+
return {
|
|
1459
|
+
completions: {
|
|
1460
|
+
create: (options) => this.generate(options),
|
|
1461
|
+
createStream: (options) => this.generateStream(options)
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
// src/namespaces/images.ts
|
|
1468
|
+
var ImagesNamespace = class {
|
|
1469
|
+
constructor(provider) {
|
|
1470
|
+
this.provider = provider;
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Generate images from a prompt.
|
|
1474
|
+
*/
|
|
1475
|
+
async generate(options) {
|
|
1476
|
+
if (!this.provider.generateImage) {
|
|
1477
|
+
throw new Error(`Provider '${this.provider.name}' does not support image generation`);
|
|
1478
|
+
}
|
|
1479
|
+
return this.provider.generateImage(options);
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Edit an image with a prompt.
|
|
1483
|
+
*/
|
|
1484
|
+
async edit(options) {
|
|
1485
|
+
if (!this.provider.editImage) {
|
|
1486
|
+
throw new Error(`Provider '${this.provider.name}' does not support image editing`);
|
|
1487
|
+
}
|
|
1488
|
+
return this.provider.editImage(options);
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Analyze an image (Vision).
|
|
1492
|
+
*/
|
|
1493
|
+
async analyze(options) {
|
|
1494
|
+
if (!this.provider.analyzeImage) {
|
|
1495
|
+
throw new Error(`Provider '${this.provider.name}' does not support image analysis`);
|
|
1496
|
+
}
|
|
1497
|
+
return this.provider.analyzeImage(options);
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
|
|
1501
|
+
// src/namespaces/audio.ts
|
|
1502
|
+
var AudioNamespace = class {
|
|
1503
|
+
constructor(provider) {
|
|
1504
|
+
this.provider = provider;
|
|
1505
|
+
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Convert text to speech.
|
|
1508
|
+
*/
|
|
1509
|
+
async speak(options) {
|
|
1510
|
+
if (!this.provider.generateSpeech) {
|
|
1511
|
+
throw new Error(`Provider '${this.provider.name}' does not support speech generation`);
|
|
1512
|
+
}
|
|
1513
|
+
return this.provider.generateSpeech(options);
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
|
|
1517
|
+
// src/namespaces/videos.ts
|
|
1518
|
+
var VideosNamespace = class {
|
|
1519
|
+
constructor(provider) {
|
|
1520
|
+
this.provider = provider;
|
|
1521
|
+
}
|
|
1522
|
+
/**
|
|
1523
|
+
* Generate a video from a prompt.
|
|
1524
|
+
*/
|
|
1525
|
+
async generate(options) {
|
|
1526
|
+
if (!this.provider.generateVideo) {
|
|
1527
|
+
throw new Error(`Provider '${this.provider.name}' does not support video generation`);
|
|
1528
|
+
}
|
|
1529
|
+
return this.provider.generateVideo(options);
|
|
1530
|
+
}
|
|
1531
|
+
/**
|
|
1532
|
+
* Analyze a video (Video-to-Text).
|
|
1533
|
+
*/
|
|
1534
|
+
async analyze(options) {
|
|
1535
|
+
if (!this.provider.analyzeVideo) {
|
|
1536
|
+
throw new Error(`Provider '${this.provider.name}' does not support video analysis`);
|
|
1537
|
+
}
|
|
1538
|
+
return this.provider.analyzeVideo(options);
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
|
|
1542
|
+
// src/tekimax.ts
|
|
1543
|
+
var Tekimax = class {
|
|
1544
|
+
constructor(options) {
|
|
1545
|
+
this.provider = options.provider;
|
|
1546
|
+
this.text = new TextNamespace(this.provider);
|
|
1547
|
+
this.images = new ImagesNamespace(this.provider);
|
|
1548
|
+
this.audio = new AudioNamespace(this.provider);
|
|
1549
|
+
this.videos = new VideosNamespace(this.provider);
|
|
1550
|
+
}
|
|
1551
|
+
/**
|
|
1552
|
+
* @deprecated Use client.text.chat instead. Kept for backward compatibility.
|
|
1553
|
+
*/
|
|
1554
|
+
get chat() {
|
|
1555
|
+
return this.text.chat;
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1559
|
+
0 && (module.exports = {
|
|
1560
|
+
AnthropicProvider,
|
|
1561
|
+
ApiTypes,
|
|
1562
|
+
GeminiProvider,
|
|
1563
|
+
GrokProvider,
|
|
1564
|
+
OllamaProvider,
|
|
1565
|
+
OpenAIProvider,
|
|
1566
|
+
OpenRouterProvider,
|
|
1567
|
+
Tekimax,
|
|
1568
|
+
TekimaxClient,
|
|
1569
|
+
TekimaxProvider,
|
|
1570
|
+
fileToBase64,
|
|
1571
|
+
generateText,
|
|
1572
|
+
parseThinking,
|
|
1573
|
+
tool
|
|
1574
|
+
});
|