@particle-academy/prism 0.0.0
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/LICENSE +21 -0
- package/README.md +155 -0
- package/dist/audio/pending-request.d.ts +37 -0
- package/dist/audio/pending-request.d.ts.map +1 -0
- package/dist/audio/pending-request.js +91 -0
- package/dist/audio/pending-request.js.map +1 -0
- package/dist/audio/request.d.ts +37 -0
- package/dist/audio/request.d.ts.map +1 -0
- package/dist/audio/request.js +50 -0
- package/dist/audio/request.js.map +1 -0
- package/dist/audio/response.d.ts +24 -0
- package/dist/audio/response.d.ts.map +1 -0
- package/dist/audio/response.js +36 -0
- package/dist/audio/response.js.map +1 -0
- package/dist/batch/batch-job.d.ts +91 -0
- package/dist/batch/batch-job.d.ts.map +1 -0
- package/dist/batch/batch-job.js +156 -0
- package/dist/batch/batch-job.js.map +1 -0
- package/dist/batch/pending-request.d.ts +29 -0
- package/dist/batch/pending-request.d.ts.map +1 -0
- package/dist/batch/pending-request.js +73 -0
- package/dist/batch/pending-request.js.map +1 -0
- package/dist/batch/request.d.ts +73 -0
- package/dist/batch/request.d.ts.map +1 -0
- package/dist/batch/request.js +79 -0
- package/dist/batch/request.js.map +1 -0
- package/dist/embeddings/pending-request.d.ts +38 -0
- package/dist/embeddings/pending-request.d.ts.map +1 -0
- package/dist/embeddings/pending-request.js +86 -0
- package/dist/embeddings/pending-request.js.map +1 -0
- package/dist/embeddings/request.d.ts +27 -0
- package/dist/embeddings/request.d.ts.map +1 -0
- package/dist/embeddings/request.js +38 -0
- package/dist/embeddings/request.js.map +1 -0
- package/dist/embeddings/response.d.ts +19 -0
- package/dist/embeddings/response.d.ts.map +1 -0
- package/dist/embeddings/response.js +21 -0
- package/dist/embeddings/response.js.map +1 -0
- package/dist/enums.d.ts +52 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +69 -0
- package/dist/enums.js.map +1 -0
- package/dist/errors.d.ts +119 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +115 -0
- package/dist/errors.js.map +1 -0
- package/dist/files/file-data.d.ts +53 -0
- package/dist/files/file-data.d.ts.map +1 -0
- package/dist/files/file-data.js +79 -0
- package/dist/files/file-data.js.map +1 -0
- package/dist/files/pending-request.d.ts +38 -0
- package/dist/files/pending-request.d.ts.map +1 -0
- package/dist/files/pending-request.js +96 -0
- package/dist/files/pending-request.js.map +1 -0
- package/dist/files/request.d.ts +77 -0
- package/dist/files/request.d.ts.map +1 -0
- package/dist/files/request.js +81 -0
- package/dist/files/request.js.map +1 -0
- package/dist/fim/pending-request.d.ts +31 -0
- package/dist/fim/pending-request.d.ts.map +1 -0
- package/dist/fim/pending-request.js +89 -0
- package/dist/fim/pending-request.js.map +1 -0
- package/dist/fim/request.d.ts +39 -0
- package/dist/fim/request.d.ts.map +1 -0
- package/dist/fim/request.js +65 -0
- package/dist/fim/request.js.map +1 -0
- package/dist/fim/response.d.ts +21 -0
- package/dist/fim/response.d.ts.map +1 -0
- package/dist/fim/response.js +30 -0
- package/dist/fim/response.js.map +1 -0
- package/dist/http/header-names.d.ts +36 -0
- package/dist/http/header-names.d.ts.map +1 -0
- package/dist/http/header-names.js +44 -0
- package/dist/http/header-names.js.map +1 -0
- package/dist/http/transport.d.ts +94 -0
- package/dist/http/transport.d.ts.map +1 -0
- package/dist/http/transport.js +131 -0
- package/dist/http/transport.js.map +1 -0
- package/dist/images/pending-request.d.ts +30 -0
- package/dist/images/pending-request.d.ts.map +1 -0
- package/dist/images/pending-request.js +66 -0
- package/dist/images/pending-request.js.map +1 -0
- package/dist/images/request.d.ts +19 -0
- package/dist/images/request.d.ts.map +1 -0
- package/dist/images/request.js +30 -0
- package/dist/images/request.js.map +1 -0
- package/dist/images/response.d.ts +29 -0
- package/dist/images/response.d.ts.map +1 -0
- package/dist/images/response.js +34 -0
- package/dist/images/response.js.map +1 -0
- package/dist/index.d.ts +108 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +84 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/filters.d.ts +40 -0
- package/dist/internal/filters.d.ts.map +1 -0
- package/dist/internal/filters.js +83 -0
- package/dist/internal/filters.js.map +1 -0
- package/dist/json.d.ts +41 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +75 -0
- package/dist/json.js.map +1 -0
- package/dist/moderation/pending-request.d.ts +24 -0
- package/dist/moderation/pending-request.d.ts.map +1 -0
- package/dist/moderation/pending-request.js +60 -0
- package/dist/moderation/pending-request.js.map +1 -0
- package/dist/moderation/request.d.ts +20 -0
- package/dist/moderation/request.d.ts.map +1 -0
- package/dist/moderation/request.js +31 -0
- package/dist/moderation/request.js.map +1 -0
- package/dist/moderation/response.d.ts +26 -0
- package/dist/moderation/response.d.ts.map +1 -0
- package/dist/moderation/response.js +34 -0
- package/dist/moderation/response.js.map +1 -0
- package/dist/prism.d.ts +43 -0
- package/dist/prism.d.ts.map +1 -0
- package/dist/prism.js +79 -0
- package/dist/prism.js.map +1 -0
- package/dist/providers/anthropic/anthropic.d.ts +67 -0
- package/dist/providers/anthropic/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic/anthropic.js +172 -0
- package/dist/providers/anthropic/anthropic.js.map +1 -0
- package/dist/providers/anthropic/build-request-body.d.ts +15 -0
- package/dist/providers/anthropic/build-request-body.d.ts.map +1 -0
- package/dist/providers/anthropic/build-request-body.js +51 -0
- package/dist/providers/anthropic/build-request-body.js.map +1 -0
- package/dist/providers/anthropic/maps/finish-reason-map.d.ts +14 -0
- package/dist/providers/anthropic/maps/finish-reason-map.d.ts.map +1 -0
- package/dist/providers/anthropic/maps/finish-reason-map.js +30 -0
- package/dist/providers/anthropic/maps/finish-reason-map.js.map +1 -0
- package/dist/providers/anthropic/maps/media-map.d.ts +25 -0
- package/dist/providers/anthropic/maps/media-map.d.ts.map +1 -0
- package/dist/providers/anthropic/maps/media-map.js +87 -0
- package/dist/providers/anthropic/maps/media-map.js.map +1 -0
- package/dist/providers/anthropic/maps/message-map.d.ts +31 -0
- package/dist/providers/anthropic/maps/message-map.d.ts.map +1 -0
- package/dist/providers/anthropic/maps/message-map.js +121 -0
- package/dist/providers/anthropic/maps/message-map.js.map +1 -0
- package/dist/providers/anthropic/maps/tool-choice-map.d.ts +11 -0
- package/dist/providers/anthropic/maps/tool-choice-map.d.ts.map +1 -0
- package/dist/providers/anthropic/maps/tool-choice-map.js +25 -0
- package/dist/providers/anthropic/maps/tool-choice-map.js.map +1 -0
- package/dist/providers/anthropic/maps/tool-map.d.ts +14 -0
- package/dist/providers/anthropic/maps/tool-map.d.ts.map +1 -0
- package/dist/providers/anthropic/maps/tool-map.js +22 -0
- package/dist/providers/anthropic/maps/tool-map.js.map +1 -0
- package/dist/providers/anthropic/parse-response.d.ts +21 -0
- package/dist/providers/anthropic/parse-response.d.ts.map +1 -0
- package/dist/providers/anthropic/parse-response.js +109 -0
- package/dist/providers/anthropic/parse-response.js.map +1 -0
- package/dist/providers/anthropic/rate-limits.d.ts +4 -0
- package/dist/providers/anthropic/rate-limits.d.ts.map +1 -0
- package/dist/providers/anthropic/rate-limits.js +47 -0
- package/dist/providers/anthropic/rate-limits.js.map +1 -0
- package/dist/providers/anthropic/stream-events.d.ts +27 -0
- package/dist/providers/anthropic/stream-events.d.ts.map +1 -0
- package/dist/providers/anthropic/stream-events.js +147 -0
- package/dist/providers/anthropic/stream-events.js.map +1 -0
- package/dist/providers/mistral/build-request-body.d.ts +32 -0
- package/dist/providers/mistral/build-request-body.d.ts.map +1 -0
- package/dist/providers/mistral/build-request-body.js +69 -0
- package/dist/providers/mistral/build-request-body.js.map +1 -0
- package/dist/providers/mistral/embeddings.d.ts +14 -0
- package/dist/providers/mistral/embeddings.d.ts.map +1 -0
- package/dist/providers/mistral/embeddings.js +41 -0
- package/dist/providers/mistral/embeddings.js.map +1 -0
- package/dist/providers/mistral/fim.d.ts +32 -0
- package/dist/providers/mistral/fim.d.ts.map +1 -0
- package/dist/providers/mistral/fim.js +70 -0
- package/dist/providers/mistral/fim.js.map +1 -0
- package/dist/providers/mistral/maps/finish-reason-map.d.ts +15 -0
- package/dist/providers/mistral/maps/finish-reason-map.d.ts.map +1 -0
- package/dist/providers/mistral/maps/finish-reason-map.js +32 -0
- package/dist/providers/mistral/maps/finish-reason-map.js.map +1 -0
- package/dist/providers/mistral/maps/media-map.d.ts +24 -0
- package/dist/providers/mistral/maps/media-map.d.ts.map +1 -0
- package/dist/providers/mistral/maps/media-map.js +41 -0
- package/dist/providers/mistral/maps/media-map.js.map +1 -0
- package/dist/providers/mistral/maps/message-map.d.ts +20 -0
- package/dist/providers/mistral/maps/message-map.d.ts.map +1 -0
- package/dist/providers/mistral/maps/message-map.js +83 -0
- package/dist/providers/mistral/maps/message-map.js.map +1 -0
- package/dist/providers/mistral/maps/tool-choice-map.d.ts +12 -0
- package/dist/providers/mistral/maps/tool-choice-map.d.ts.map +1 -0
- package/dist/providers/mistral/maps/tool-choice-map.js +25 -0
- package/dist/providers/mistral/maps/tool-choice-map.js.map +1 -0
- package/dist/providers/mistral/maps/tool-map.d.ts +15 -0
- package/dist/providers/mistral/maps/tool-map.d.ts.map +1 -0
- package/dist/providers/mistral/maps/tool-map.js +26 -0
- package/dist/providers/mistral/maps/tool-map.js.map +1 -0
- package/dist/providers/mistral/mistral.d.ts +90 -0
- package/dist/providers/mistral/mistral.d.ts.map +1 -0
- package/dist/providers/mistral/mistral.js +210 -0
- package/dist/providers/mistral/mistral.js.map +1 -0
- package/dist/providers/mistral/parse-response.d.ts +35 -0
- package/dist/providers/mistral/parse-response.d.ts.map +1 -0
- package/dist/providers/mistral/parse-response.js +114 -0
- package/dist/providers/mistral/parse-response.js.map +1 -0
- package/dist/providers/mistral/rate-limits.d.ts +24 -0
- package/dist/providers/mistral/rate-limits.d.ts.map +1 -0
- package/dist/providers/mistral/rate-limits.js +55 -0
- package/dist/providers/mistral/rate-limits.js.map +1 -0
- package/dist/providers/mistral/stream-events.d.ts +29 -0
- package/dist/providers/mistral/stream-events.d.ts.map +1 -0
- package/dist/providers/mistral/stream-events.js +142 -0
- package/dist/providers/mistral/stream-events.js.map +1 -0
- package/dist/providers/openai/audio.d.ts +16 -0
- package/dist/providers/openai/audio.d.ts.map +1 -0
- package/dist/providers/openai/audio.js +105 -0
- package/dist/providers/openai/audio.js.map +1 -0
- package/dist/providers/openai/batch.d.ts +29 -0
- package/dist/providers/openai/batch.d.ts.map +1 -0
- package/dist/providers/openai/batch.js +181 -0
- package/dist/providers/openai/batch.js.map +1 -0
- package/dist/providers/openai/build-request-body.d.ts +25 -0
- package/dist/providers/openai/build-request-body.d.ts.map +1 -0
- package/dist/providers/openai/build-request-body.js +66 -0
- package/dist/providers/openai/build-request-body.js.map +1 -0
- package/dist/providers/openai/build-structured-body.d.ts +16 -0
- package/dist/providers/openai/build-structured-body.d.ts.map +1 -0
- package/dist/providers/openai/build-structured-body.js +47 -0
- package/dist/providers/openai/build-structured-body.js.map +1 -0
- package/dist/providers/openai/embeddings.d.ts +6 -0
- package/dist/providers/openai/embeddings.d.ts.map +1 -0
- package/dist/providers/openai/embeddings.js +61 -0
- package/dist/providers/openai/embeddings.js.map +1 -0
- package/dist/providers/openai/files.d.ts +16 -0
- package/dist/providers/openai/files.d.ts.map +1 -0
- package/dist/providers/openai/files.js +80 -0
- package/dist/providers/openai/files.js.map +1 -0
- package/dist/providers/openai/images.d.ts +6 -0
- package/dist/providers/openai/images.d.ts.map +1 -0
- package/dist/providers/openai/images.js +55 -0
- package/dist/providers/openai/images.js.map +1 -0
- package/dist/providers/openai/maps/finish-reason-map.d.ts +21 -0
- package/dist/providers/openai/maps/finish-reason-map.d.ts.map +1 -0
- package/dist/providers/openai/maps/finish-reason-map.js +56 -0
- package/dist/providers/openai/maps/finish-reason-map.js.map +1 -0
- package/dist/providers/openai/maps/media-map.d.ts +25 -0
- package/dist/providers/openai/maps/media-map.d.ts.map +1 -0
- package/dist/providers/openai/maps/media-map.js +53 -0
- package/dist/providers/openai/maps/media-map.js.map +1 -0
- package/dist/providers/openai/maps/message-map.d.ts +21 -0
- package/dist/providers/openai/maps/message-map.d.ts.map +1 -0
- package/dist/providers/openai/maps/message-map.js +128 -0
- package/dist/providers/openai/maps/message-map.js.map +1 -0
- package/dist/providers/openai/maps/tool-choice-map.d.ts +14 -0
- package/dist/providers/openai/maps/tool-choice-map.d.ts.map +1 -0
- package/dist/providers/openai/maps/tool-choice-map.js +27 -0
- package/dist/providers/openai/maps/tool-choice-map.js.map +1 -0
- package/dist/providers/openai/maps/tool-map.d.ts +16 -0
- package/dist/providers/openai/maps/tool-map.d.ts.map +1 -0
- package/dist/providers/openai/maps/tool-map.js +34 -0
- package/dist/providers/openai/maps/tool-map.js.map +1 -0
- package/dist/providers/openai/moderation.d.ts +6 -0
- package/dist/providers/openai/moderation.d.ts.map +1 -0
- package/dist/providers/openai/moderation.js +26 -0
- package/dist/providers/openai/moderation.js.map +1 -0
- package/dist/providers/openai/openai.d.ts +103 -0
- package/dist/providers/openai/openai.d.ts.map +1 -0
- package/dist/providers/openai/openai.js +385 -0
- package/dist/providers/openai/openai.js.map +1 -0
- package/dist/providers/openai/parse-response.d.ts +21 -0
- package/dist/providers/openai/parse-response.d.ts.map +1 -0
- package/dist/providers/openai/parse-response.js +114 -0
- package/dist/providers/openai/parse-response.js.map +1 -0
- package/dist/providers/openai/rate-limits.d.ts +4 -0
- package/dist/providers/openai/rate-limits.d.ts.map +1 -0
- package/dist/providers/openai/rate-limits.js +47 -0
- package/dist/providers/openai/rate-limits.js.map +1 -0
- package/dist/providers/openai/stream-events.d.ts +13 -0
- package/dist/providers/openai/stream-events.d.ts.map +1 -0
- package/dist/providers/openai/stream-events.js +79 -0
- package/dist/providers/openai/stream-events.js.map +1 -0
- package/dist/providers/openai/structured-mode-resolver.d.ts +3 -0
- package/dist/providers/openai/structured-mode-resolver.d.ts.map +1 -0
- package/dist/providers/openai/structured-mode-resolver.js +41 -0
- package/dist/providers/openai/structured-mode-resolver.js.map +1 -0
- package/dist/providers/provider.d.ts +55 -0
- package/dist/providers/provider.d.ts.map +1 -0
- package/dist/providers/provider.js +73 -0
- package/dist/providers/provider.js.map +1 -0
- package/dist/providers/registry.d.ts +10 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +27 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/support/media.d.ts +16 -0
- package/dist/providers/support/media.d.ts.map +1 -0
- package/dist/providers/support/media.js +26 -0
- package/dist/providers/support/media.js.map +1 -0
- package/dist/schema/index.d.ts +114 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +192 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/streaming/events.d.ts +90 -0
- package/dist/streaming/events.d.ts.map +1 -0
- package/dist/streaming/events.js +152 -0
- package/dist/streaming/events.js.map +1 -0
- package/dist/streaming/sse.d.ts +17 -0
- package/dist/streaming/sse.d.ts.map +1 -0
- package/dist/streaming/sse.js +50 -0
- package/dist/streaming/sse.js.map +1 -0
- package/dist/structured/extract.d.ts +23 -0
- package/dist/structured/extract.d.ts.map +1 -0
- package/dist/structured/extract.js +43 -0
- package/dist/structured/extract.js.map +1 -0
- package/dist/structured/from-text.d.ts +16 -0
- package/dist/structured/from-text.d.ts.map +1 -0
- package/dist/structured/from-text.js +27 -0
- package/dist/structured/from-text.js.map +1 -0
- package/dist/structured/pending-request.d.ts +28 -0
- package/dist/structured/pending-request.d.ts.map +1 -0
- package/dist/structured/pending-request.js +48 -0
- package/dist/structured/pending-request.js.map +1 -0
- package/dist/structured/request.d.ts +28 -0
- package/dist/structured/request.d.ts.map +1 -0
- package/dist/structured/request.js +31 -0
- package/dist/structured/request.js.map +1 -0
- package/dist/structured/response.d.ts +44 -0
- package/dist/structured/response.d.ts.map +1 -0
- package/dist/structured/response.js +49 -0
- package/dist/structured/response.js.map +1 -0
- package/dist/text/pending-request.d.ts +77 -0
- package/dist/text/pending-request.d.ts.map +1 -0
- package/dist/text/pending-request.js +189 -0
- package/dist/text/pending-request.js.map +1 -0
- package/dist/text/request.d.ts +62 -0
- package/dist/text/request.d.ts.map +1 -0
- package/dist/text/request.js +117 -0
- package/dist/text/request.js.map +1 -0
- package/dist/text/response-builder.d.ts +16 -0
- package/dist/text/response-builder.d.ts.map +1 -0
- package/dist/text/response-builder.js +52 -0
- package/dist/text/response-builder.js.map +1 -0
- package/dist/text/response.d.ts +36 -0
- package/dist/text/response.d.ts.map +1 -0
- package/dist/text/response.js +40 -0
- package/dist/text/response.js.map +1 -0
- package/dist/text/step.d.ts +41 -0
- package/dist/text/step.d.ts.map +1 -0
- package/dist/text/step.js +46 -0
- package/dist/text/step.js.map +1 -0
- package/dist/tool.d.ts +34 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +86 -0
- package/dist/tool.js.map +1 -0
- package/dist/value-objects/artifact.d.ts +14 -0
- package/dist/value-objects/artifact.d.ts.map +1 -0
- package/dist/value-objects/artifact.js +32 -0
- package/dist/value-objects/artifact.js.map +1 -0
- package/dist/value-objects/embedding.d.ts +24 -0
- package/dist/value-objects/embedding.d.ts.map +1 -0
- package/dist/value-objects/embedding.js +29 -0
- package/dist/value-objects/embedding.js.map +1 -0
- package/dist/value-objects/embeddings-usage.d.ts +16 -0
- package/dist/value-objects/embeddings-usage.d.ts.map +1 -0
- package/dist/value-objects/embeddings-usage.js +19 -0
- package/dist/value-objects/embeddings-usage.js.map +1 -0
- package/dist/value-objects/generated-audio.d.ts +20 -0
- package/dist/value-objects/generated-audio.d.ts.map +1 -0
- package/dist/value-objects/generated-audio.js +23 -0
- package/dist/value-objects/generated-audio.js.map +1 -0
- package/dist/value-objects/generated-image.d.ts +36 -0
- package/dist/value-objects/generated-image.d.ts.map +1 -0
- package/dist/value-objects/generated-image.js +35 -0
- package/dist/value-objects/generated-image.js.map +1 -0
- package/dist/value-objects/index.d.ts +13 -0
- package/dist/value-objects/index.d.ts.map +1 -0
- package/dist/value-objects/index.js +10 -0
- package/dist/value-objects/index.js.map +1 -0
- package/dist/value-objects/media/audio.d.ts +8 -0
- package/dist/value-objects/media/audio.d.ts.map +1 -0
- package/dist/value-objects/media/audio.js +9 -0
- package/dist/value-objects/media/audio.js.map +1 -0
- package/dist/value-objects/media/document.d.ts +44 -0
- package/dist/value-objects/media/document.d.ts.map +1 -0
- package/dist/value-objects/media/document.js +75 -0
- package/dist/value-objects/media/document.js.map +1 -0
- package/dist/value-objects/media/image.d.ts +13 -0
- package/dist/value-objects/media/image.d.ts.map +1 -0
- package/dist/value-objects/media/image.js +14 -0
- package/dist/value-objects/media/image.js.map +1 -0
- package/dist/value-objects/media/media.d.ts +119 -0
- package/dist/value-objects/media/media.d.ts.map +1 -0
- package/dist/value-objects/media/media.js +267 -0
- package/dist/value-objects/media/media.js.map +1 -0
- package/dist/value-objects/media/part.d.ts +25 -0
- package/dist/value-objects/media/part.d.ts.map +1 -0
- package/dist/value-objects/media/part.js +41 -0
- package/dist/value-objects/media/part.js.map +1 -0
- package/dist/value-objects/media/text.d.ts +24 -0
- package/dist/value-objects/media/text.d.ts.map +1 -0
- package/dist/value-objects/media/text.js +33 -0
- package/dist/value-objects/media/text.js.map +1 -0
- package/dist/value-objects/media/video.d.ts +7 -0
- package/dist/value-objects/media/video.d.ts.map +1 -0
- package/dist/value-objects/media/video.js +8 -0
- package/dist/value-objects/media/video.js.map +1 -0
- package/dist/value-objects/messages/assistant-message.d.ts +26 -0
- package/dist/value-objects/messages/assistant-message.d.ts.map +1 -0
- package/dist/value-objects/messages/assistant-message.js +37 -0
- package/dist/value-objects/messages/assistant-message.js.map +1 -0
- package/dist/value-objects/messages/index.d.ts +27 -0
- package/dist/value-objects/messages/index.d.ts.map +1 -0
- package/dist/value-objects/messages/index.js +32 -0
- package/dist/value-objects/messages/index.js.map +1 -0
- package/dist/value-objects/messages/system-message.d.ts +9 -0
- package/dist/value-objects/messages/system-message.d.ts.map +1 -0
- package/dist/value-objects/messages/system-message.js +17 -0
- package/dist/value-objects/messages/system-message.js.map +1 -0
- package/dist/value-objects/messages/tool-result-message.d.ts +14 -0
- package/dist/value-objects/messages/tool-result-message.d.ts.map +1 -0
- package/dist/value-objects/messages/tool-result-message.js +26 -0
- package/dist/value-objects/messages/tool-result-message.js.map +1 -0
- package/dist/value-objects/messages/user-message.d.ts +47 -0
- package/dist/value-objects/messages/user-message.d.ts.map +1 -0
- package/dist/value-objects/messages/user-message.js +87 -0
- package/dist/value-objects/messages/user-message.js.map +1 -0
- package/dist/value-objects/meta.d.ts +12 -0
- package/dist/value-objects/meta.d.ts.map +1 -0
- package/dist/value-objects/meta.js +28 -0
- package/dist/value-objects/meta.js.map +1 -0
- package/dist/value-objects/moderation-result.d.ts +20 -0
- package/dist/value-objects/moderation-result.d.ts.map +1 -0
- package/dist/value-objects/moderation-result.js +64 -0
- package/dist/value-objects/moderation-result.js.map +1 -0
- package/dist/value-objects/provider-rate-limit.d.ts +11 -0
- package/dist/value-objects/provider-rate-limit.d.ts.map +1 -0
- package/dist/value-objects/provider-rate-limit.js +34 -0
- package/dist/value-objects/provider-rate-limit.js.map +1 -0
- package/dist/value-objects/provider-tool.d.ts +19 -0
- package/dist/value-objects/provider-tool.d.ts.map +1 -0
- package/dist/value-objects/provider-tool.js +31 -0
- package/dist/value-objects/provider-tool.js.map +1 -0
- package/dist/value-objects/tool-call.d.ts +29 -0
- package/dist/value-objects/tool-call.d.ts.map +1 -0
- package/dist/value-objects/tool-call.js +112 -0
- package/dist/value-objects/tool-call.js.map +1 -0
- package/dist/value-objects/tool-result.d.ts +25 -0
- package/dist/value-objects/tool-result.d.ts.map +1 -0
- package/dist/value-objects/tool-result.js +45 -0
- package/dist/value-objects/tool-result.js.map +1 -0
- package/dist/value-objects/usage.d.ts +13 -0
- package/dist/value-objects/usage.d.ts.map +1 -0
- package/dist/value-objects/usage.js +31 -0
- package/dist/value-objects/usage.js.map +1 -0
- package/package.json +46 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream-events.js","sourceRoot":"","sources":["../../../src/providers/anthropic/stream-events.ts"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,CAAC,GAAsB;IACnC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,IAAI,KAAK,CACd,UAAU,CAAC,GAAG,CAAC,YAAY,CAAC,EAC5B,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,EAC7B,kBAAkB,CAAC,GAAG,CAAC,2BAA2B,CAAC,EACnD,kBAAkB,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAC/C,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,eAAe,CAAC,CAC3E,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5C,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JsonObject } from '../../json.js';
|
|
2
|
+
import type { StructuredRequest } from '../../structured/request.js';
|
|
3
|
+
import type { TextRequest } from '../../text/request.js';
|
|
4
|
+
/**
|
|
5
|
+
* Build the Mistral chat-completions request body.
|
|
6
|
+
*
|
|
7
|
+
* `model`, `messages` and `max_tokens` go in UNCONDITIONALLY, matching the
|
|
8
|
+
* reference — so `max_tokens` is present as an explicit null on a request that
|
|
9
|
+
* never set one. Everything else passes a NOT-NULL filter, so `0` and `false`
|
|
10
|
+
* survive and only `null` is dropped: `withTemperature(0)` is a real setting.
|
|
11
|
+
*
|
|
12
|
+
* An empty tool list collapses to null BEFORE the filter, so the key vanishes.
|
|
13
|
+
* An empty array is truthy in JavaScript, so a direct port sends `"tools":[]`,
|
|
14
|
+
* which changes `tool_choice` defaults on some models and is rejected outright
|
|
15
|
+
* by others.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildRequestBody(request: TextRequest): JsonObject;
|
|
18
|
+
/**
|
|
19
|
+
* The same body, plus a schema — and never both a schema and tools.
|
|
20
|
+
*
|
|
21
|
+
* MISTRAL REFUSES `response_format` AND `tools` IN ONE REQUEST. The reference
|
|
22
|
+
* works around it with a two-pass loop: send with tools, let the model call
|
|
23
|
+
* them, then re-send without tools and with the schema to get the final JSON.
|
|
24
|
+
*
|
|
25
|
+
* This port does not run tools (the execution loop is deferred — see the parity
|
|
26
|
+
* manifest), so there is no loop to two-pass. Tools are DROPPED here and the
|
|
27
|
+
* schema is sent, which is the half that matters for `structured`: a caller who
|
|
28
|
+
* declared tools on a structured request would otherwise get an error from the
|
|
29
|
+
* provider naming a conflict they did not create.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildStructuredBody(request: StructuredRequest): JsonObject;
|
|
32
|
+
//# sourceMappingURL=build-request-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-request-body.d.ts","sourceRoot":"","sources":["../../../src/providers/mistral/build-request-body.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAKzD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CAejE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAuB1E"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { whereNotNull } from '../../internal/filters.js';
|
|
2
|
+
import { mapMessages } from './maps/message-map.js';
|
|
3
|
+
import { mapToolChoice } from './maps/tool-choice-map.js';
|
|
4
|
+
import { mapTools } from './maps/tool-map.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build the Mistral chat-completions request body.
|
|
7
|
+
*
|
|
8
|
+
* `model`, `messages` and `max_tokens` go in UNCONDITIONALLY, matching the
|
|
9
|
+
* reference — so `max_tokens` is present as an explicit null on a request that
|
|
10
|
+
* never set one. Everything else passes a NOT-NULL filter, so `0` and `false`
|
|
11
|
+
* survive and only `null` is dropped: `withTemperature(0)` is a real setting.
|
|
12
|
+
*
|
|
13
|
+
* An empty tool list collapses to null BEFORE the filter, so the key vanishes.
|
|
14
|
+
* An empty array is truthy in JavaScript, so a direct port sends `"tools":[]`,
|
|
15
|
+
* which changes `tool_choice` defaults on some models and is rejected outright
|
|
16
|
+
* by others.
|
|
17
|
+
*/
|
|
18
|
+
export function buildRequestBody(request) {
|
|
19
|
+
const tools = mapTools(request.tools());
|
|
20
|
+
return {
|
|
21
|
+
model: request.model(),
|
|
22
|
+
messages: mapMessages(request.messages(), request.systemPrompts()),
|
|
23
|
+
max_tokens: request.maxTokens(),
|
|
24
|
+
...whereNotNull({
|
|
25
|
+
temperature: request.temperature(),
|
|
26
|
+
top_p: request.topP(),
|
|
27
|
+
reasoning_effort: request.providerOptions('reasoning_effort'),
|
|
28
|
+
tools: tools.length > 0 ? tools : null,
|
|
29
|
+
tool_choice: tools.length > 0 ? mapToolChoice(request.toolChoice()) : null,
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The same body, plus a schema — and never both a schema and tools.
|
|
35
|
+
*
|
|
36
|
+
* MISTRAL REFUSES `response_format` AND `tools` IN ONE REQUEST. The reference
|
|
37
|
+
* works around it with a two-pass loop: send with tools, let the model call
|
|
38
|
+
* them, then re-send without tools and with the schema to get the final JSON.
|
|
39
|
+
*
|
|
40
|
+
* This port does not run tools (the execution loop is deferred — see the parity
|
|
41
|
+
* manifest), so there is no loop to two-pass. Tools are DROPPED here and the
|
|
42
|
+
* schema is sent, which is the half that matters for `structured`: a caller who
|
|
43
|
+
* declared tools on a structured request would otherwise get an error from the
|
|
44
|
+
* provider naming a conflict they did not create.
|
|
45
|
+
*/
|
|
46
|
+
export function buildStructuredBody(request) {
|
|
47
|
+
const schema = request.schema();
|
|
48
|
+
return {
|
|
49
|
+
model: request.model(),
|
|
50
|
+
messages: mapMessages(request.messages(), request.systemPrompts()),
|
|
51
|
+
max_tokens: request.maxTokens(),
|
|
52
|
+
response_format: {
|
|
53
|
+
type: 'json_schema',
|
|
54
|
+
json_schema: {
|
|
55
|
+
schema: schema.toObject(),
|
|
56
|
+
name: schema.name,
|
|
57
|
+
// Mistral's own strict mode, so this IS enforced rather than requested
|
|
58
|
+
// — unlike the Anthropic path, which can only ask. See G-08.
|
|
59
|
+
strict: true,
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
...whereNotNull({
|
|
63
|
+
temperature: request.temperature(),
|
|
64
|
+
top_p: request.topP(),
|
|
65
|
+
reasoning_effort: request.providerOptions('reasoning_effort'),
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=build-request-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-request-body.js","sourceRoot":"","sources":["../../../src/providers/mistral/build-request-body.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAoB;IACnD,MAAM,KAAK,GAAG,QA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AC,WAAW,EAAE;YAClC,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE;YACrB,gBAAgB,EAAE,OAAO,CAAC,eAAe,CAAC,kBAAkB,CAAC;SACP,CAAC;KAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type JsonObject } from '../../json.js';
|
|
2
|
+
import type { EmbeddingsRequest } from '../../embeddings/request.js';
|
|
3
|
+
import { EmbeddingsResponse } from '../../embeddings/response.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mistral's embeddings body.
|
|
6
|
+
*
|
|
7
|
+
* Narrower than OpenAI's on purpose: Mistral takes `model` and `input` and
|
|
8
|
+
* nothing else that the reference sends. `dimensions` and `encoding_format` are
|
|
9
|
+
* OpenAI options and are not forwarded — sending an unknown key is rejected
|
|
10
|
+
* outright by this endpoint rather than ignored.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildEmbeddingsBody(request: EmbeddingsRequest): JsonObject;
|
|
13
|
+
export declare function parseEmbeddingsResponse(rawBody: unknown): EmbeddingsResponse;
|
|
14
|
+
//# sourceMappingURL=embeddings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../../src/providers/mistral/embeddings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAOlE;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAO1E;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB,CAkB5E"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { isJsonObject } from '../../json.js';
|
|
2
|
+
import { EmbeddingsResponse } from '../../embeddings/response.js';
|
|
3
|
+
import { readNullableNumber, readNumber, readObject, readString } from '../../internal/filters.js';
|
|
4
|
+
import { Embedding } from '../../value-objects/embedding.js';
|
|
5
|
+
import { EmbeddingsUsage } from '../../value-objects/embeddings-usage.js';
|
|
6
|
+
import { Meta } from '../../value-objects/meta.js';
|
|
7
|
+
import { validateResponse } from './parse-response.js';
|
|
8
|
+
/**
|
|
9
|
+
* Mistral's embeddings body.
|
|
10
|
+
*
|
|
11
|
+
* Narrower than OpenAI's on purpose: Mistral takes `model` and `input` and
|
|
12
|
+
* nothing else that the reference sends. `dimensions` and `encoding_format` are
|
|
13
|
+
* OpenAI options and are not forwarded — sending an unknown key is rejected
|
|
14
|
+
* outright by this endpoint rather than ignored.
|
|
15
|
+
*/
|
|
16
|
+
export function buildEmbeddingsBody(request) {
|
|
17
|
+
return {
|
|
18
|
+
model: request.model(),
|
|
19
|
+
// A LIST even for one input, so a response index maps to an input index
|
|
20
|
+
// without a special case for the single-input call.
|
|
21
|
+
input: [...request.inputs()],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function parseEmbeddingsResponse(rawBody) {
|
|
25
|
+
const data = validateResponse(rawBody);
|
|
26
|
+
const items = Array.isArray(data.data) ? data.data : [];
|
|
27
|
+
// ORDERED BY THE PROVIDER'S OWN INDEX, not by arrival, for the same reason
|
|
28
|
+
// the OpenAI mapping does it: an embeddings caller zips the result against
|
|
29
|
+
// the inputs it sent, so a silent reordering attaches every vector to the
|
|
30
|
+
// wrong text.
|
|
31
|
+
const ordered = [...items].filter(isJsonObject).sort((a, b) => readNumber(a.index, 0) - readNumber(b.index, 0));
|
|
32
|
+
return new EmbeddingsResponse({
|
|
33
|
+
embeddings: ordered.map((item) => Embedding.fromArray(Array.isArray(item.embedding) ? item.embedding : [])),
|
|
34
|
+
// Mistral reports `total_tokens` only. Null rather than 0 when it says
|
|
35
|
+
// nothing, because zero tokens claims the call was free.
|
|
36
|
+
usage: new EmbeddingsUsage(readNullableNumber((readObject(data.usage) ?? {}).total_tokens)),
|
|
37
|
+
meta: new Meta(readString(data.id, ''), readString(data.model, '')),
|
|
38
|
+
raw: data,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=embeddings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embeddings.js","sourceRoot":"","sources":["../../../src/providers/mistral/embeddings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAA0B;IAC5D,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE;QACtB,wEAAwE;QACxE,oDAAoD;QACpD,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;KAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,IAAI,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,2EAA2E;IAC3E,2EAA2E;IAC3E,0EAA0E;IAC1E,cAAc;IACd,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IAEhH,OAAO,IAAI,kBAAkB,CAAC;QAC5B,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC3G,uEAAuE;QACvE,yDAAyD;QACzD,KAAK,EAAE,IAAI,eAAe,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC;QAC3F,IAAI,EAAE,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACnE,GAAG,EAAE,IAAI;KACV,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JsonObject } from '../../json.js';
|
|
2
|
+
import type { FimRequest } from '../../fim/request.js';
|
|
3
|
+
import { FimResponse } from '../../fim/response.js';
|
|
4
|
+
import type { ProviderRateLimit } from '../../value-objects/provider-rate-limit.js';
|
|
5
|
+
/**
|
|
6
|
+
* Build the fill-in-the-middle request body.
|
|
7
|
+
*
|
|
8
|
+
* `model` and `prompt` are unconditional; everything else passes a NOT-NULL
|
|
9
|
+
* filter so `withTemperature(0)` survives.
|
|
10
|
+
*
|
|
11
|
+
* `stop` collapses to null when EMPTY, matching the reference. An empty array
|
|
12
|
+
* is truthy in JavaScript, so a direct port sends `"stop":[]` — which Mistral
|
|
13
|
+
* accepts and which then reads, to anyone inspecting the request, as a caller
|
|
14
|
+
* who asked for no stop sequences rather than one who never set any.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildFimBody(request: FimRequest): JsonObject;
|
|
17
|
+
/**
|
|
18
|
+
* Parse a FIM completion.
|
|
19
|
+
*
|
|
20
|
+
* The finish-reason mapping is DELIBERATELY NARROWER than the chat one, and
|
|
21
|
+
* matches the reference: FIM answers only `stop` or `length`, so `tool_calls`
|
|
22
|
+
* and `content_filter` are not special-cased. Anything unrecognised becomes
|
|
23
|
+
* Unknown rather than Stop — a truncated completion reported as complete is how
|
|
24
|
+
* an editor silently inserts half a function.
|
|
25
|
+
*
|
|
26
|
+
* Unlike `parseTextResponse`, a Length finish does NOT throw. Hitting the token
|
|
27
|
+
* ceiling is an ordinary outcome for a completion: the caller wanted as much of
|
|
28
|
+
* the gap as the budget bought, and the partial text is useful. `finishReason`
|
|
29
|
+
* carries the fact.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseFimResponse(rawBody: unknown, request: FimRequest, rateLimits?: readonly ProviderRateLimit[]): FimResponse;
|
|
32
|
+
//# sourceMappingURL=fim.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fim.d.ts","sourceRoot":"","sources":["../../../src/providers/mistral/fim.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,eAAe,CAAC;AAG3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAIpF;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,CAgB5D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,UAAU,EACnB,UAAU,GAAE,SAAS,iBAAiB,EAAO,GAC5C,WAAW,CAYb"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { FinishReason } from '../../enums.js';
|
|
2
|
+
import { readNumber, readObject, readString, whereNotNull } from '../../internal/filters.js';
|
|
3
|
+
import { FimResponse } from '../../fim/response.js';
|
|
4
|
+
import { Meta } from '../../value-objects/meta.js';
|
|
5
|
+
import { Usage } from '../../value-objects/usage.js';
|
|
6
|
+
import { firstChoiceMessage, validateResponse } from './parse-response.js';
|
|
7
|
+
/**
|
|
8
|
+
* Build the fill-in-the-middle request body.
|
|
9
|
+
*
|
|
10
|
+
* `model` and `prompt` are unconditional; everything else passes a NOT-NULL
|
|
11
|
+
* filter so `withTemperature(0)` survives.
|
|
12
|
+
*
|
|
13
|
+
* `stop` collapses to null when EMPTY, matching the reference. An empty array
|
|
14
|
+
* is truthy in JavaScript, so a direct port sends `"stop":[]` — which Mistral
|
|
15
|
+
* accepts and which then reads, to anyone inspecting the request, as a caller
|
|
16
|
+
* who asked for no stop sequences rather than one who never set any.
|
|
17
|
+
*/
|
|
18
|
+
export function buildFimBody(request) {
|
|
19
|
+
const stop = request.stop();
|
|
20
|
+
return {
|
|
21
|
+
model: request.model(),
|
|
22
|
+
prompt: request.prompt(),
|
|
23
|
+
...whereNotNull({
|
|
24
|
+
// The text AFTER the gap. Omitting it is legal and means "complete to the
|
|
25
|
+
// end", which is a different request rather than a degraded one.
|
|
26
|
+
suffix: request.suffix(),
|
|
27
|
+
max_tokens: request.maxTokens(),
|
|
28
|
+
temperature: request.temperature(),
|
|
29
|
+
top_p: request.topP(),
|
|
30
|
+
stop: stop.length > 0 ? [...stop] : null,
|
|
31
|
+
}),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse a FIM completion.
|
|
36
|
+
*
|
|
37
|
+
* The finish-reason mapping is DELIBERATELY NARROWER than the chat one, and
|
|
38
|
+
* matches the reference: FIM answers only `stop` or `length`, so `tool_calls`
|
|
39
|
+
* and `content_filter` are not special-cased. Anything unrecognised becomes
|
|
40
|
+
* Unknown rather than Stop — a truncated completion reported as complete is how
|
|
41
|
+
* an editor silently inserts half a function.
|
|
42
|
+
*
|
|
43
|
+
* Unlike `parseTextResponse`, a Length finish does NOT throw. Hitting the token
|
|
44
|
+
* ceiling is an ordinary outcome for a completion: the caller wanted as much of
|
|
45
|
+
* the gap as the budget bought, and the partial text is useful. `finishReason`
|
|
46
|
+
* carries the fact.
|
|
47
|
+
*/
|
|
48
|
+
export function parseFimResponse(rawBody, request, rateLimits = []) {
|
|
49
|
+
const data = validateResponse(rawBody);
|
|
50
|
+
const message = firstChoiceMessage(data);
|
|
51
|
+
const usage = readObject(data.usage) ?? {};
|
|
52
|
+
return new FimResponse(readString(message.content, ''), mapFimFinishReason(data), new Usage(readNumber(usage.prompt_tokens, 0), readNumber(usage.completion_tokens, 0)), new Meta(readString(data.id, ''), readString(data.model, '') || request.model(), rateLimits, null), data);
|
|
53
|
+
}
|
|
54
|
+
function mapFimFinishReason(data) {
|
|
55
|
+
const choices = Array.isArray(data.choices) ? data.choices : [];
|
|
56
|
+
const first = choices[0];
|
|
57
|
+
const reason = typeof first === 'object' && first !== null && !Array.isArray(first)
|
|
58
|
+
? readString(first.finish_reason, '')
|
|
59
|
+
: '';
|
|
60
|
+
switch (reason) {
|
|
61
|
+
case 'stop':
|
|
62
|
+
return FinishReason.Stop;
|
|
63
|
+
case 'length':
|
|
64
|
+
case 'model_length':
|
|
65
|
+
return FinishReason.Length;
|
|
66
|
+
default:
|
|
67
|
+
return FinishReason.Unknown;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=fim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fim.js","sourceRoot":"","sources":["../../../src/providers/mistral/fim.ts"],"names":[],"mappings":"AAC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.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map Mistral's `finish_reason` onto the shared enum.
|
|
5
|
+
*
|
|
6
|
+
* It sits on the CHOICE, not the top-level payload, which is where the
|
|
7
|
+
* chat-completions shape differs from both of this package's other providers —
|
|
8
|
+
* reading it off the root returns undefined and every generation reports
|
|
9
|
+
* Unknown.
|
|
10
|
+
*
|
|
11
|
+
* An unrecognised reason becomes Unknown rather than Stop. Guessing Stop would
|
|
12
|
+
* present a truncated or filtered generation as a complete one.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mapFinishReason(data: JsonObject): FinishReason;
|
|
15
|
+
//# sourceMappingURL=finish-reason-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finish-reason-map.d.ts","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/finish-reason-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAIjD;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,YAAY,CAiB9D"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { FinishReason } from '../../../enums.js';
|
|
2
|
+
import { isJsonObject } from '../../../json.js';
|
|
3
|
+
import { readArray, readString } from '../../../internal/filters.js';
|
|
4
|
+
/**
|
|
5
|
+
* Map Mistral's `finish_reason` onto the shared enum.
|
|
6
|
+
*
|
|
7
|
+
* It sits on the CHOICE, not the top-level payload, which is where the
|
|
8
|
+
* chat-completions shape differs from both of this package's other providers —
|
|
9
|
+
* reading it off the root returns undefined and every generation reports
|
|
10
|
+
* Unknown.
|
|
11
|
+
*
|
|
12
|
+
* An unrecognised reason becomes Unknown rather than Stop. Guessing Stop would
|
|
13
|
+
* present a truncated or filtered generation as a complete one.
|
|
14
|
+
*/
|
|
15
|
+
export function mapFinishReason(data) {
|
|
16
|
+
const first = readArray(data.choices)[0];
|
|
17
|
+
const reason = isJsonObject(first) ? readString(first.finish_reason, '') : '';
|
|
18
|
+
switch (reason) {
|
|
19
|
+
case 'stop':
|
|
20
|
+
return FinishReason.Stop;
|
|
21
|
+
case 'tool_calls':
|
|
22
|
+
return FinishReason.ToolCalls;
|
|
23
|
+
case 'length':
|
|
24
|
+
case 'model_length':
|
|
25
|
+
return FinishReason.Length;
|
|
26
|
+
case 'content_filter':
|
|
27
|
+
return FinishReason.ContentFilter;
|
|
28
|
+
default:
|
|
29
|
+
return FinishReason.Unknown;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=finish-reason-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finish-reason-map.js","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/finish-reason-map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAErE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAAC,IAAgB;IAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAE9E,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,MAAM;YACT,OAAO,YAAY,CAAC,IAAI,CAAC;QAC3B,KAAK,YAAY;YACf,OAAO,YAAY,CAAC,SAAS,CAAC;QAChC,KAAK,QAAQ,CAAC;QACd,KAAK,cAAc;YACjB,OAAO,YAAY,CAAC,MAAM,CAAC;QAC7B,KAAK,gBAAgB;YACnB,OAAO,YAAY,CAAC,aAAa,CAAC;QACpC;YACE,OAAO,YAAY,CAAC,OAAO,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JsonObject } from '../../../json.js';
|
|
2
|
+
import type { Document } from '../../../value-objects/media/document.js';
|
|
3
|
+
import type { Image } from '../../../value-objects/media/image.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mistral's image part.
|
|
6
|
+
*
|
|
7
|
+
* `image_url` is an OBJECT wrapping a url string, and the url is either a real
|
|
8
|
+
* one or a `data:` uri carrying the bytes — the chat-completions shape, which
|
|
9
|
+
* is neither of the two the other providers here use. OpenAI's Responses API
|
|
10
|
+
* spells the same thing `input_image` with a bare `image_url` string, and
|
|
11
|
+
* Anthropic spells it a `source` block.
|
|
12
|
+
*/
|
|
13
|
+
export declare function mapImage(image: Image): JsonObject;
|
|
14
|
+
/**
|
|
15
|
+
* Mistral's document part.
|
|
16
|
+
*
|
|
17
|
+
* A URL AND NOTHING ELSE. Mistral fetches the document itself, so unlike every
|
|
18
|
+
* other media part in this package there is no base64 fallback — a document
|
|
19
|
+
* read from disk cannot be sent to Mistral at all, and saying so here is the
|
|
20
|
+
* difference between a clear failure and a 422 naming a field the caller never
|
|
21
|
+
* set.
|
|
22
|
+
*/
|
|
23
|
+
export declare function mapDocument(document: Document): JsonObject;
|
|
24
|
+
//# sourceMappingURL=media-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-map.d.ts","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/media-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0CAA0C,CAAC;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uCAAuC,CAAC;AAGnE;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,UAAU,CASjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAU1D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PrismError } from '../../../errors.js';
|
|
2
|
+
import { whereNotNull } from '../../../internal/filters.js';
|
|
3
|
+
import { dataUri } from '../../support/media.js';
|
|
4
|
+
/**
|
|
5
|
+
* Mistral's image part.
|
|
6
|
+
*
|
|
7
|
+
* `image_url` is an OBJECT wrapping a url string, and the url is either a real
|
|
8
|
+
* one or a `data:` uri carrying the bytes — the chat-completions shape, which
|
|
9
|
+
* is neither of the two the other providers here use. OpenAI's Responses API
|
|
10
|
+
* spells the same thing `input_image` with a bare `image_url` string, and
|
|
11
|
+
* Anthropic spells it a `source` block.
|
|
12
|
+
*/
|
|
13
|
+
export function mapImage(image) {
|
|
14
|
+
if (!image.isUrl() && !image.hasBase64()) {
|
|
15
|
+
throw PrismError.unsupportedMedia('Mistral', 'image', 'a url, or bytes it can send as base64');
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
type: 'image_url',
|
|
19
|
+
image_url: { url: image.isUrl() ? image.url : dataUri(image, 'Mistral', 'image') },
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Mistral's document part.
|
|
24
|
+
*
|
|
25
|
+
* A URL AND NOTHING ELSE. Mistral fetches the document itself, so unlike every
|
|
26
|
+
* other media part in this package there is no base64 fallback — a document
|
|
27
|
+
* read from disk cannot be sent to Mistral at all, and saying so here is the
|
|
28
|
+
* difference between a clear failure and a 422 naming a field the caller never
|
|
29
|
+
* set.
|
|
30
|
+
*/
|
|
31
|
+
export function mapDocument(document) {
|
|
32
|
+
if (!document.isUrl()) {
|
|
33
|
+
throw PrismError.unsupportedMedia('Mistral', 'document', 'a url only — it fetches the document itself');
|
|
34
|
+
}
|
|
35
|
+
return whereNotNull({
|
|
36
|
+
type: 'document_url',
|
|
37
|
+
document_url: document.url,
|
|
38
|
+
document_name: document.documentTitle(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=media-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-map.js","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/media-map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAY;IACnC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,CAAC;QACzC,MAAM,UAAU,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,uCAAuC,CAAC,CAAC;IACjG,CAAC;IAED,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE;KACnF,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,QAAkB;IAC5C,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,UAAU,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,6CAA6C,CAAC,CAAC;IAC1G,CAAC;IAED,OAAO,YAAY,CAAC;QAClB,IAAI,EAAE,cAAc;QACpB,YAAY,EAAE,QAAQ,CAAC,GAAG;QAC1B,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE;KACxC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JsonObject } from '../../../json.js';
|
|
2
|
+
import type { Message, SystemMessage } from '../../../value-objects/messages/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map messages onto Mistral's chat-completions shape.
|
|
5
|
+
*
|
|
6
|
+
* This is the OpenAI CHAT-COMPLETIONS format, not the Responses format the
|
|
7
|
+
* OpenAI provider in this package speaks — roles are `system` / `user` /
|
|
8
|
+
* `assistant` / `tool`, and a tool result is its own message keyed by
|
|
9
|
+
* `tool_call_id`. The two look similar enough that sharing a mapper is tempting
|
|
10
|
+
* and wrong: the Responses API takes `input` with typed content parts, and the
|
|
11
|
+
* fields that differ are the ones that fail silently.
|
|
12
|
+
*
|
|
13
|
+
* System prompts come FIRST, matching the reference: Mistral weights the
|
|
14
|
+
* earliest system turn most heavily, and a caller who set one expects it to
|
|
15
|
+
* lead.
|
|
16
|
+
*
|
|
17
|
+
* @throws PrismError code `unknown_message_type`
|
|
18
|
+
*/
|
|
19
|
+
export declare function mapMessages(messages: readonly Message[], systemPrompts: readonly SystemMessage[]): JsonObject[];
|
|
20
|
+
//# sourceMappingURL=message-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-map.d.ts","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/message-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,kBAAkB,CAAC;AAE9D,OAAO,KAAK,EAAoB,OAAO,EAAE,aAAa,EAAe,MAAM,0CAA0C,CAAC;AAGtH;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,SAAS,OAAO,EAAE,EAC5B,aAAa,EAAE,SAAS,aAAa,EAAE,GACtC,UAAU,EAAE,CAEd"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PrismError } from '../../../errors.js';
|
|
2
|
+
import { mapDocument, mapImage } from './media-map.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map messages onto Mistral's chat-completions shape.
|
|
5
|
+
*
|
|
6
|
+
* This is the OpenAI CHAT-COMPLETIONS format, not the Responses format the
|
|
7
|
+
* OpenAI provider in this package speaks — roles are `system` / `user` /
|
|
8
|
+
* `assistant` / `tool`, and a tool result is its own message keyed by
|
|
9
|
+
* `tool_call_id`. The two look similar enough that sharing a mapper is tempting
|
|
10
|
+
* and wrong: the Responses API takes `input` with typed content parts, and the
|
|
11
|
+
* fields that differ are the ones that fail silently.
|
|
12
|
+
*
|
|
13
|
+
* System prompts come FIRST, matching the reference: Mistral weights the
|
|
14
|
+
* earliest system turn most heavily, and a caller who set one expects it to
|
|
15
|
+
* lead.
|
|
16
|
+
*
|
|
17
|
+
* @throws PrismError code `unknown_message_type`
|
|
18
|
+
*/
|
|
19
|
+
export function mapMessages(messages, systemPrompts) {
|
|
20
|
+
return [...systemPrompts, ...messages].flatMap(mapMessage);
|
|
21
|
+
}
|
|
22
|
+
function mapMessage(message) {
|
|
23
|
+
switch (message.type) {
|
|
24
|
+
case 'system':
|
|
25
|
+
return [{ role: 'system', content: message.content }];
|
|
26
|
+
case 'user':
|
|
27
|
+
return [mapUserMessage(message)];
|
|
28
|
+
case 'assistant':
|
|
29
|
+
return [mapAssistantMessage(message)];
|
|
30
|
+
case 'tool_result':
|
|
31
|
+
// ONE message per result, not one carrying them all. Mistral matches each
|
|
32
|
+
// back by `tool_call_id`, and a combined message has nowhere to put the
|
|
33
|
+
// second id.
|
|
34
|
+
return message.toolResults.map((result) => ({
|
|
35
|
+
role: 'tool',
|
|
36
|
+
content: result.result,
|
|
37
|
+
tool_call_id: result.toolCallId,
|
|
38
|
+
}));
|
|
39
|
+
default:
|
|
40
|
+
throw PrismError.unknownMessageType(String(message.type));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A user turn, always as a content ARRAY.
|
|
45
|
+
*
|
|
46
|
+
* Even for plain text, matching the reference. Mistral accepts a bare string
|
|
47
|
+
* too, but sending the array shape unconditionally means adding an image part
|
|
48
|
+
* later does not change the shape of every other message in a transcript — so a
|
|
49
|
+
* stored conversation stays comparable with itself.
|
|
50
|
+
*
|
|
51
|
+
* Text leads, then images, then documents — the reference's order. Mistral does
|
|
52
|
+
* not document an ordering requirement, but the parts reach the model in the
|
|
53
|
+
* order they are sent, so keeping it identical to the reference means a
|
|
54
|
+
* transcript compared across the two ports and the reference matches byte for
|
|
55
|
+
* byte rather than only semantically.
|
|
56
|
+
*/
|
|
57
|
+
function mapUserMessage(message) {
|
|
58
|
+
const content = [
|
|
59
|
+
{ type: 'text', text: message.text() },
|
|
60
|
+
...message.images().map(mapImage),
|
|
61
|
+
...message.documents().map(mapDocument),
|
|
62
|
+
];
|
|
63
|
+
return { role: 'user', content, ...message.additionalAttributes };
|
|
64
|
+
}
|
|
65
|
+
function mapAssistantMessage(message) {
|
|
66
|
+
const body = { role: 'assistant', content: message.content };
|
|
67
|
+
if (message.toolCalls.length > 0) {
|
|
68
|
+
body.tool_calls = message.toolCalls.map((call) => ({
|
|
69
|
+
id: call.id,
|
|
70
|
+
type: 'function',
|
|
71
|
+
function: {
|
|
72
|
+
name: call.name,
|
|
73
|
+
// A JSON STRING, not an object — the chat-completions shape. An object
|
|
74
|
+
// is accepted by some gateways and rejected by Mistral, which is the
|
|
75
|
+
// worst kind of difference to carry. Already-string arguments are
|
|
76
|
+
// passed through rather than re-encoded into a quoted string.
|
|
77
|
+
arguments: typeof call.arguments === 'string' ? call.arguments : JSON.stringify(call.arguments),
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
return body;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=message-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message-map.js","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/message-map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA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AC,GAAG,CAAC,WAAW,CAAC;KACxC,CAAC;IAEF,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;AACpE,CAAC;AAED,SAAS,mBAAmB,CAAC,OAAyB;IACpD,MAAM,IAAI,GAAe,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;IAEzE,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACjD,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE;gBACR,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,uEAAuE;gBACvE,qEAAqE;gBACrE,kEAAkE;gBAClE,8DAA8D;gBAC9D,SAAS,EAAE,OAAO,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC;aAChG;SACF,CAAC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { JsonObject } from '../../../json.js';
|
|
2
|
+
import { ToolChoice } from '../../../enums.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map the shared tool choice onto Mistral's form.
|
|
5
|
+
*
|
|
6
|
+
* `auto` / `any` / `none` are BARE STRINGS, and a named tool is an object —
|
|
7
|
+
* so the return type is a union rather than one or the other. Mistral spells
|
|
8
|
+
* "the model must call something" as `any`, like Anthropic and unlike OpenAI's
|
|
9
|
+
* `required`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function mapToolChoice(choice: string | ToolChoice | null): string | JsonObject | null;
|
|
12
|
+
//# sourceMappingURL=tool-choice-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-choice-map.d.ts","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/tool-choice-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,GAAG,MAAM,GAAG,UAAU,GAAG,IAAI,CAkB5F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ToolChoice } from '../../../enums.js';
|
|
2
|
+
/**
|
|
3
|
+
* Map the shared tool choice onto Mistral's form.
|
|
4
|
+
*
|
|
5
|
+
* `auto` / `any` / `none` are BARE STRINGS, and a named tool is an object —
|
|
6
|
+
* so the return type is a union rather than one or the other. Mistral spells
|
|
7
|
+
* "the model must call something" as `any`, like Anthropic and unlike OpenAI's
|
|
8
|
+
* `required`.
|
|
9
|
+
*/
|
|
10
|
+
export function mapToolChoice(choice) {
|
|
11
|
+
if (choice === null) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (choice === ToolChoice.Auto) {
|
|
15
|
+
return 'auto';
|
|
16
|
+
}
|
|
17
|
+
if (choice === ToolChoice.Any) {
|
|
18
|
+
return 'any';
|
|
19
|
+
}
|
|
20
|
+
if (choice === ToolChoice.None) {
|
|
21
|
+
return 'none';
|
|
22
|
+
}
|
|
23
|
+
return { type: 'function', function: { name: String(choice) } };
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=tool-choice-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-choice-map.js","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/tool-choice-map.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,MAAkC;IAC9D,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,MAAM,KAAK,UAAU,CAAC,IAAI,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,MAAM,KAAK,UAAU,CAAC,GAAG,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,KAAK,UAAU,CAAC,IAAI,EAAE,CAAC;QAC/B,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { JsonObject } from '../../../json.js';
|
|
2
|
+
import type { Tool } from '../../../tool.js';
|
|
3
|
+
/**
|
|
4
|
+
* Map tools onto Mistral's `tools` array.
|
|
5
|
+
*
|
|
6
|
+
* The chat-completions shape: a `function` object nested under a `type`, where
|
|
7
|
+
* the Responses API flattens the same fields to the top level. `parameters` is
|
|
8
|
+
* always sent, even empty — Mistral rejects a function declaration without one,
|
|
9
|
+
* unlike OpenAI which treats it as optional.
|
|
10
|
+
*
|
|
11
|
+
* Declaration order is preserved. Tool order reaches the model and influences
|
|
12
|
+
* which tool it picks.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mapTools(tools: readonly Tool[]): JsonObject[];
|
|
15
|
+
//# sourceMappingURL=tool-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-map.d.ts","sourceRoot":"","sources":["../../../../src/providers/mistral/maps/tool-map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,SAAS,IAAI,EAAE,GAAG,UAAU,EAAE,CAa7D"}
|