Skip to content

Commit

Permalink
use OpenApiJsonSchema
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed Sep 24, 2024
1 parent 80a6fc7 commit 31f882b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/ai/ai/src/Completions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @since 1.0.0
*/
import * as JsonSchema from "@effect/platform/OpenApiJsonSchema"
import * as AST from "@effect/schema/AST"
import * as JSONSchema from "@effect/schema/JSONSchema"
import * as Schema from "@effect/schema/Schema"
import * as Chunk from "effect/Chunk"
import * as Context from "effect/Context"
Expand Down Expand Up @@ -89,7 +89,7 @@ export interface CompletionOptions {
readonly tools: Array<{
readonly name: string
readonly description: string
readonly parameters: JSONSchema.JsonSchema7
readonly parameters: JsonSchema.JsonSchema
}>
readonly required: boolean | string
}
Expand All @@ -105,7 +105,7 @@ export const make = (options: {
readonly tools: Array<{
readonly name: string
readonly description: string
readonly parameters: JSONSchema.JsonSchema7
readonly parameters: JsonSchema.JsonSchema
}>
readonly required: boolean | string
}) => Effect.Effect<AiResponse, AiError>
Expand All @@ -115,7 +115,7 @@ export const make = (options: {
readonly tools: Array<{
readonly name: string
readonly description: string
readonly parameters: JSONSchema.JsonSchema7
readonly parameters: JsonSchema.JsonSchema
}>
readonly required: boolean | string
}) => Stream.Stream<AiResponse, AiError>
Expand Down Expand Up @@ -192,7 +192,7 @@ export const make = (options: {
)
},
toolkit({ concurrency, required = false, tools }) {
const toolArr: Array<{ name: string; description: string; parameters: JSONSchema.JsonSchema7 }> = []
const toolArr: Array<{ name: string; description: string; parameters: JsonSchema.JsonSchema }> = []
for (const [, tool] of tools.toolkit.tools) {
toolArr.push(convertTool(tool as any))
}
Expand All @@ -215,7 +215,7 @@ export const make = (options: {
) as any
},
toolkitStream({ concurrency, required = false, tools }) {
const toolArr: Array<{ name: string; description: string; parameters: JSONSchema.JsonSchema7 }> = []
const toolArr: Array<{ name: string; description: string; parameters: JsonSchema.JsonSchema }> = []
for (const [, tool] of tools.toolkit.tools) {
toolArr.push(convertTool(tool as any))
}
Expand Down Expand Up @@ -247,7 +247,7 @@ export const make = (options: {
const convertTool = <A, I, R>(tool: Completions.StructuredSchema<A, I, R>) => ({
name: tool._tag ?? tool.identifier,
description: getDescription(tool.ast),
parameters: JSONSchema.make(tool)
parameters: JsonSchema.make(tool)
})

const getDescription = (ast: AST.AST): string => {
Expand Down

0 comments on commit 31f882b

Please sign in to comment.