Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update ai Generated schemas #4592

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/flat-shirts-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/platform": patch
---

support nested records in UrlParams module
6 changes: 6 additions & 0 deletions .changeset/light-eels-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@effect/ai-anthropic": patch
"@effect/ai-openai": patch
---

update generated ai clients
2 changes: 1 addition & 1 deletion packages/ai/anthropic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@effect/experimental": "workspace:^",
"@effect/platform": "workspace:^",
"@effect/platform-node": "workspace:^",
"@tim-smart/openapi-gen": "^0.3.6",
"@tim-smart/openapi-gen": "^0.3.11",
"effect": "workspace:^"
},
"dependencies": {
Expand Down
31 changes: 20 additions & 11 deletions packages/ai/anthropic/src/AnthropicCompletions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import type * as Generated from "./Generated.js"
* @since 1.0.0
* @category models
*/
export type Model = typeof Generated.ModelEnum.Encoded
export type Model = typeof Generated.Model.Encoded

// =============================================================================
// Configuration
Expand Down Expand Up @@ -351,7 +351,8 @@ const makeResponse = Effect.fnUntraced(function*(
}
) {
if (structuredTool !== undefined && response.stop_reason === "tool_use") {
const [text, toolUse] = Arr.partition(response.content, (chunk) => chunk.type === "tool_use")
const toolUse = response.content.filter((chunk) => chunk.type === "tool_use")
const text = response.content.filter((chunk) => chunk.type === "text")
if (toolUse.length !== 1) {
return yield* new AiError({
module: "AnthropicCompletions",
Expand All @@ -371,15 +372,23 @@ const makeResponse = Effect.fnUntraced(function*(
parts: Chunk.unsafeFromArray([...textParts, toolCallPart])
})
}
const parts = response.content.map((chunk) =>
chunk.type === "text"
? AiResponse.TextPart.fromContent(chunk.text)
: AiResponse.ToolCallPart.fromUnknown({
id: chunk.id,
name: chunk.name,
params: chunk.input
})
)
const parts = Arr.empty<AiResponse.Part>()
for (const chunk of response.content) {
switch (chunk.type) {
case "text": {
parts.push(AiResponse.TextPart.fromContent(chunk.text))
break
}
case "tool_use": {
parts.push(AiResponse.ToolCallPart.fromUnknown({
id: chunk.id,
name: chunk.name,
params: chunk.input
}))
break
}
}
}
return AiResponse.AiResponse.make({
role: AiRole.model,
parts: Chunk.unsafeFromArray(parts)
Expand Down
Loading