@opencode-ai/ai
Advanced tools
@@ -244,3 +244,3 @@ import { Effect, Schema } from "effect"; | ||
| }); | ||
| const lowerAssistantMessage = Effect.fn("OpenAIChat.lowerAssistantMessage")(function* (message, configuredField, options = {}) { | ||
| const lowerAssistantMessage = Effect.fn("OpenAIChat.lowerAssistantMessage")(function* (message, configuredField, requireReasoning, options) { | ||
| const content = []; | ||
@@ -271,6 +271,6 @@ const reasoning = []; | ||
| const field = (() => { | ||
| if (configuredField !== undefined) | ||
| if (configuredField !== undefined && (requireReasoning || reasoning.length > 0 || nativeReasoning !== undefined)) | ||
| return configuredField; | ||
| if (reasoning.length === 0) | ||
| return undefined; | ||
| return requireReasoning ? "reasoning_content" : undefined; | ||
| if (observedField !== undefined) | ||
@@ -280,3 +280,3 @@ return observedField; | ||
| return "reasoning_content"; | ||
| if (!fullyStructured) | ||
| if (!fullyStructured || requireReasoning) | ||
| return "reasoning_content"; | ||
@@ -286,5 +286,5 @@ })(); | ||
| if (configuredField !== undefined) | ||
| return reasoning.length === 0 ? (nativeReasoning ?? "") : text; | ||
| return reasoning.length === 0 ? (nativeReasoning ?? (requireReasoning ? "" : undefined)) : text; | ||
| if (reasoning.length === 0) | ||
| return nativeReasoning; | ||
| return nativeReasoning ?? (requireReasoning ? "" : undefined); | ||
| return text; | ||
@@ -333,7 +333,7 @@ })(); | ||
| }); | ||
| const lowerMessage = Effect.fn("OpenAIChat.lowerMessage")(function* (message, reasoningField, options = {}) { | ||
| const lowerMessage = Effect.fn("OpenAIChat.lowerMessage")(function* (message, reasoningField, requireReasoning, options) { | ||
| if (message.role === "user") | ||
| return [yield* lowerUserMessage(message, options)]; | ||
| if (message.role === "assistant") | ||
| return [yield* lowerAssistantMessage(message, reasoningField, options)]; | ||
| return [yield* lowerAssistantMessage(message, reasoningField, requireReasoning, options)]; | ||
| return (yield* lowerToolMessages(message, options)).messages; | ||
@@ -358,2 +358,8 @@ }); | ||
| const modelID = request.model.id.toLowerCase(); | ||
| const requireReasoning = request.model.compatibility?.requireReasoning ?? | ||
| (request.model.compatibility?.reasoningField !== undefined || | ||
| request.model.provider === "deepseek" || | ||
| request.model.route.endpoint.baseURL?.toLowerCase().includes("deepseek.com") || | ||
| modelID.includes("deepseek")); | ||
| const reasoningField = request.model.compatibility?.reasoningField; | ||
| const mistral = ["mistral", "devstral", "codestral", "pixtral", "mixtral"].some((family) => modelID.includes(family)); | ||
@@ -436,3 +442,3 @@ const lowering = { | ||
| flushImages(); | ||
| messages.push(...(yield* lowerMessage(message, request.model.compatibility?.reasoningField, lowering))); | ||
| messages.push(...(yield* lowerMessage(message, reasoningField, requireReasoning, lowering))); | ||
| } | ||
@@ -439,0 +445,0 @@ flushImages(); |
@@ -75,2 +75,4 @@ import { Schema } from "effect"; | ||
| readonly reasoningField: Schema.optional<Schema.String>; | ||
| /** Require every assistant message to include its reasoning field, even when empty. */ | ||
| readonly requireReasoning: Schema.optional<Schema.Boolean>; | ||
| readonly maxTokensField: Schema.optional<Schema.Literals<readonly ["max_completion_tokens", "max_tokens"]>>; | ||
@@ -77,0 +79,0 @@ readonly requireFinishReason: Schema.optional<Schema.Boolean>; |
@@ -102,2 +102,4 @@ import { Schema } from "effect"; | ||
| reasoningField: Schema.optional(Schema.String), | ||
| /** Require every assistant message to include its reasoning field, even when empty. */ | ||
| requireReasoning: Schema.optional(Schema.Boolean), | ||
| maxTokensField: Schema.optional(LanguageModelMaxTokensFieldCompatibility), | ||
@@ -104,0 +106,0 @@ requireFinishReason: Schema.optional(Schema.Boolean), |
+3
-3
| { | ||
| "$schema": "https://json.schemastore.org/package.json", | ||
| "version": "0.0.0-dev-18234", | ||
| "version": "0.0.0-dev-18235", | ||
| "name": "@opencode-ai/ai", | ||
@@ -33,3 +33,3 @@ "type": "module", | ||
| "@effect/platform-node": "4.0.0-rc.111", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-18234", | ||
| "@opencode-ai/http-recorder": "0.0.0-dev-18235", | ||
| "@tsconfig/bun": "1.0.9", | ||
@@ -43,3 +43,3 @@ "@types/bun": "1.3.13", | ||
| "@smithy/util-utf8": "4.2.2", | ||
| "@opencode-ai/schema": "0.0.0-dev-18234", | ||
| "@opencode-ai/schema": "0.0.0-dev-18235", | ||
| "aws4fetch": "1.0.20", | ||
@@ -46,0 +46,0 @@ "effect": "4.0.0-rc.111", |
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
1314486
0.07%30159
0.03%+ Added
- Removed