From f7589594915aaebe1d88bf3e45c0cfa7a3414de5 Mon Sep 17 00:00:00 2001 From: Chris Watts Date: Thu, 30 Jan 2025 14:00:41 -0800 Subject: [PATCH] feat: generate client --- integ-tests/baml_src/generators.baml | 10 +- integ-tests/openapi/baml_client/openapi.yaml | 3032 ++++++++++++++--- integ-tests/python/baml_client/__init__.py | 32 + .../python/baml_client/async_client.py | 53 + integ-tests/python/baml_client/globals.py | 41 + integ-tests/python/baml_client/inlinedbaml.py | 3 +- .../python/baml_client/partial_types.py | 432 +++ integ-tests/python/baml_client/sync_client.py | 53 + integ-tests/python/baml_client/tracing.py | 25 + .../python/baml_client/type_builder.py | 2 +- integ-tests/python/baml_client/types.py | 568 +++ integ-tests/react/baml_client/async_client.ts | 60 +- integ-tests/react/baml_client/globals.ts | 37 + integ-tests/react/baml_client/index.ts | 24 + integ-tests/react/baml_client/inlinedbaml.ts | 3 +- .../react/baml_client/partial_types.ts | 24 + .../react/baml_client/react/client.tsx | 134 +- integ-tests/react/baml_client/react/server.ts | 31 +- integ-tests/react/baml_client/sync_client.ts | 27 +- integ-tests/react/baml_client/tracing.ts | 33 + integ-tests/react/baml_client/type_builder.ts | 2 +- integ-tests/react/baml_client/types.ts | 28 + integ-tests/ruby/baml_client/client.rb | 67 + integ-tests/ruby/baml_client/inlined.rb | 3 +- integ-tests/ruby/baml_client/partial-types.rb | 1421 ++++++++ integ-tests/ruby/baml_client/type-registry.rb | 2 +- integ-tests/ruby/baml_client/types.rb | 1547 +++++++++ .../typescript/baml_client/async_client.ts | 127 +- integ-tests/typescript/baml_client/globals.ts | 37 + integ-tests/typescript/baml_client/index.ts | 24 + .../typescript/baml_client/inlinedbaml.ts | 3 +- .../typescript/baml_client/partial_types.ts | 24 + .../typescript/baml_client/sync_client.ts | 65 +- integ-tests/typescript/baml_client/tracing.ts | 33 + .../typescript/baml_client/type_builder.ts | 9 +- integ-tests/typescript/baml_client/types.ts | 28 + 36 files changed, 7369 insertions(+), 675 deletions(-) create mode 100644 integ-tests/python/baml_client/__init__.py create mode 100644 integ-tests/python/baml_client/globals.py create mode 100644 integ-tests/python/baml_client/partial_types.py create mode 100644 integ-tests/python/baml_client/tracing.py create mode 100644 integ-tests/python/baml_client/types.py create mode 100644 integ-tests/react/baml_client/globals.ts create mode 100644 integ-tests/react/baml_client/index.ts create mode 100644 integ-tests/react/baml_client/tracing.ts create mode 100644 integ-tests/ruby/baml_client/partial-types.rb create mode 100644 integ-tests/ruby/baml_client/types.rb create mode 100644 integ-tests/typescript/baml_client/globals.ts create mode 100644 integ-tests/typescript/baml_client/index.ts create mode 100644 integ-tests/typescript/baml_client/tracing.ts diff --git a/integ-tests/baml_src/generators.baml b/integ-tests/baml_src/generators.baml index 85830c51c..cc4651eb9 100644 --- a/integ-tests/baml_src/generators.baml +++ b/integ-tests/baml_src/generators.baml @@ -11,7 +11,9 @@ generator lang_typescript { } generator lang_typescript_react { - version "0.72.1" + output_type typescript/react + output_dir "../react" + version "0.74.0" } generator lang_ruby { @@ -20,12 +22,6 @@ generator lang_ruby { version "0.74.0" } -generator lang_typescript_react { - output_type typescript/react - output_dir "../react" - version "0.74.0" -} - generator openapi { output_type rest/openapi output_dir "../openapi" diff --git a/integ-tests/openapi/baml_client/openapi.yaml b/integ-tests/openapi/baml_client/openapi.yaml index 526fda7e3..049c81d7f 100644 --- a/integ-tests/openapi/baml_client/openapi.yaml +++ b/integ-tests/openapi/baml_client/openapi.yaml @@ -32,6 +32,47 @@ paths: title: AaaSamOutputFormatResponse $ref: '#/components/schemas/Recipe' operationId: AaaSamOutputFormat + /call/AliasThatPointsToRecursiveType: + post: + requestBody: + $ref: '#/components/requestBodies/AliasThatPointsToRecursiveType' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: AliasThatPointsToRecursiveTypeResponse + $ref: '#/components/schemas/LinkedListAliasNode' + operationId: AliasThatPointsToRecursiveType + /call/AliasWithMultipleAttrs: + post: + requestBody: + $ref: '#/components/requestBodies/AliasWithMultipleAttrs' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: AliasWithMultipleAttrsResponse + type: object + properties: + value: + type: integer + checks: + type: object + properties: + gt_ten: + $ref: '#components/schemas/Check' + required: + - gt_ten + additionalProperties: false + required: + - value + - checks + additionalProperties: false + operationId: AliasWithMultipleAttrs /call/AliasedInputClass: post: requestBody: @@ -97,6 +138,32 @@ paths: title: AliasedInputListResponse type: string operationId: AliasedInputList + /call/AllowedOptionals: + post: + requestBody: + $ref: '#/components/requestBodies/AllowedOptionals' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: AllowedOptionalsResponse + $ref: '#/components/schemas/OptionalListAndMap' + operationId: AllowedOptionals + /call/AssertFn: + post: + requestBody: + $ref: '#/components/requestBodies/AssertFn' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: AssertFnResponse + type: integer + operationId: AssertFn /call/AudioInput: post: requestBody: @@ -110,6 +177,45 @@ paths: title: AudioInputResponse type: string operationId: AudioInput + /call/BuildLinkedList: + post: + requestBody: + $ref: '#/components/requestBodies/BuildLinkedList' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: BuildLinkedListResponse + $ref: '#/components/schemas/LinkedList' + operationId: BuildLinkedList + /call/BuildTree: + post: + requestBody: + $ref: '#/components/requestBodies/BuildTree' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: BuildTreeResponse + $ref: '#/components/schemas/Tree' + operationId: BuildTree + /call/ClassThatPointsToRecursiveClassThroughAlias: + post: + requestBody: + $ref: '#/components/requestBodies/ClassThatPointsToRecursiveClassThroughAlias' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: ClassThatPointsToRecursiveClassThroughAliasResponse + $ref: '#/components/schemas/ClassToRecAlias' + operationId: ClassThatPointsToRecursiveClassThroughAlias /call/ClassifyDynEnumTwo: post: requestBody: @@ -162,6 +268,19 @@ paths: title: ClassifyMessage3Response $ref: '#/components/schemas/Category' operationId: ClassifyMessage3 + /call/Completion: + post: + requestBody: + $ref: '#/components/requestBodies/Completion' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: CompletionResponse + type: string + operationId: Completion /call/CustomTask: post: requestBody: @@ -325,6 +444,21 @@ paths: title: ExtractContactInfoResponse $ref: '#/components/schemas/ContactInfo' operationId: ExtractContactInfo + /call/ExtractHobby: + post: + requestBody: + $ref: '#/components/requestBodies/ExtractHobby' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: ExtractHobbyResponse + type: array + items: + $ref: '#/components/schemas/Hobby' + operationId: ExtractHobby /call/ExtractNames: post: requestBody: @@ -448,6 +582,34 @@ paths: title: FnEnumOutputResponse $ref: '#/components/schemas/EnumOutput' operationId: FnEnumOutput + /call/FnLiteralClassInputOutput: + post: + requestBody: + $ref: '#/components/requestBodies/FnLiteralClassInputOutput' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: FnLiteralClassInputOutputResponse + $ref: '#/components/schemas/LiteralClassHello' + operationId: FnLiteralClassInputOutput + /call/FnLiteralUnionClassInputOutput: + post: + requestBody: + $ref: '#/components/requestBodies/FnLiteralUnionClassInputOutput' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: FnLiteralUnionClassInputOutputResponse + oneOf: + - $ref: '#/components/schemas/LiteralClassOne' + - $ref: '#/components/schemas/LiteralClassTwo' + operationId: FnLiteralUnionClassInputOutput /call/FnNamedArgsSingleStringOptional: post: requestBody: @@ -528,6 +690,58 @@ paths: title: FnOutputClassWithEnumResponse $ref: '#/components/schemas/TestClassWithEnum' operationId: FnOutputClassWithEnum + /call/FnOutputInt: + post: + requestBody: + $ref: '#/components/requestBodies/FnOutputInt' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: FnOutputIntResponse + type: integer + operationId: FnOutputInt + /call/FnOutputLiteralBool: + post: + requestBody: + $ref: '#/components/requestBodies/FnOutputLiteralBool' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: FnOutputLiteralBoolResponse + type: boolean + operationId: FnOutputLiteralBool + /call/FnOutputLiteralInt: + post: + requestBody: + $ref: '#/components/requestBodies/FnOutputLiteralInt' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: FnOutputLiteralIntResponse + type: integer + operationId: FnOutputLiteralInt + /call/FnOutputLiteralString: + post: + requestBody: + $ref: '#/components/requestBodies/FnOutputLiteralString' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: FnOutputLiteralStringResponse + type: string + operationId: FnOutputLiteralString /call/FnOutputStringList: post: requestBody: @@ -621,820 +835,1837 @@ paths: title: GetQueryResponse $ref: '#/components/schemas/SearchParams' operationId: GetQuery - /call/MyFunc: + /call/InOutEnumMapKey: post: requestBody: - $ref: '#/components/requestBodies/MyFunc' + $ref: '#/components/requestBodies/InOutEnumMapKey' responses: '200': description: Successful operation content: application/json: schema: - title: MyFuncResponse - $ref: '#/components/schemas/DynamicOutput' - operationId: MyFunc - /call/OptionalTest_Function: + title: InOutEnumMapKeyResponse + type: object + additionalProperties: + type: string + operationId: InOutEnumMapKey + /call/InOutLiteralStringUnionMapKey: post: requestBody: - $ref: '#/components/requestBodies/OptionalTest_Function' + $ref: '#/components/requestBodies/InOutLiteralStringUnionMapKey' responses: '200': description: Successful operation content: application/json: schema: - title: OptionalTest_FunctionResponse - type: array - items: - $ref: '#/components/schemas/OptionalTest_ReturnType' - operationId: OptionalTest_Function - /call/PredictAge: + title: InOutLiteralStringUnionMapKeyResponse + type: object + additionalProperties: + type: string + operationId: InOutLiteralStringUnionMapKey + /call/InOutSingleLiteralStringMapKey: post: requestBody: - $ref: '#/components/requestBodies/PredictAge' + $ref: '#/components/requestBodies/InOutSingleLiteralStringMapKey' responses: '200': description: Successful operation content: application/json: schema: - title: PredictAgeResponse - $ref: '#/components/schemas/FooAny' - operationId: PredictAge - /call/PredictAgeBare: + title: InOutSingleLiteralStringMapKeyResponse + type: object + additionalProperties: + type: string + operationId: InOutSingleLiteralStringMapKey + /call/JsonTypeAliasCycle: post: requestBody: - $ref: '#/components/requestBodies/PredictAgeBare' + $ref: '#/components/requestBodies/JsonTypeAliasCycle' responses: '200': description: Successful operation content: application/json: schema: - title: PredictAgeBareResponse + title: JsonTypeAliasCycleResponse + anyOf: [] + operationId: JsonTypeAliasCycle + /call/LiteralUnionsTest: + post: + requestBody: + $ref: '#/components/requestBodies/LiteralUnionsTest' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: LiteralUnionsTestResponse + oneOf: + - type: integer + - type: boolean + - type: string + operationId: LiteralUnionsTest + /call/MakeBlockConstraint: + post: + requestBody: + $ref: '#/components/requestBodies/MakeBlockConstraint' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: MakeBlockConstraintResponse type: object properties: value: - type: integer + $ref: '#/components/schemas/BlockConstraint' checks: type: object properties: - too_big: + cross_field: $ref: '#components/schemas/Check' required: - - too_big + - cross_field additionalProperties: false required: - value - checks additionalProperties: false - operationId: PredictAgeBare - /call/PromptTestClaude: + operationId: MakeBlockConstraint + /call/MakeNestedBlockConstraint: post: requestBody: - $ref: '#/components/requestBodies/PromptTestClaude' + $ref: '#/components/requestBodies/MakeNestedBlockConstraint' responses: '200': description: Successful operation content: application/json: schema: - title: PromptTestClaudeResponse - type: string - operationId: PromptTestClaude - /call/PromptTestClaudeChat: + title: MakeNestedBlockConstraintResponse + $ref: '#/components/schemas/NestedBlockConstraint' + operationId: MakeNestedBlockConstraint + /call/MakeSemanticContainer: post: requestBody: - $ref: '#/components/requestBodies/PromptTestClaudeChat' + $ref: '#/components/requestBodies/MakeSemanticContainer' responses: '200': description: Successful operation content: application/json: schema: - title: PromptTestClaudeChatResponse - type: string - operationId: PromptTestClaudeChat - /call/PromptTestClaudeChatNoSystem: + title: MakeSemanticContainerResponse + $ref: '#/components/schemas/SemanticContainer' + operationId: MakeSemanticContainer + /call/MapAlias: post: requestBody: - $ref: '#/components/requestBodies/PromptTestClaudeChatNoSystem' + $ref: '#/components/requestBodies/MapAlias' responses: '200': description: Successful operation content: application/json: schema: - title: PromptTestClaudeChatNoSystemResponse - type: string - operationId: PromptTestClaudeChatNoSystem - /call/PromptTestOpenAI: + title: MapAliasResponse + type: object + additionalProperties: + type: array + items: + type: string + operationId: MapAlias + /call/MergeAliasAttributes: post: requestBody: - $ref: '#/components/requestBodies/PromptTestOpenAI' + $ref: '#/components/requestBodies/MergeAliasAttributes' responses: '200': description: Successful operation content: application/json: schema: - title: PromptTestOpenAIResponse - type: string - operationId: PromptTestOpenAI - /call/PromptTestOpenAIChat: + title: MergeAliasAttributesResponse + $ref: '#/components/schemas/MergeAttrs' + operationId: MergeAliasAttributes + /call/MyFunc: post: requestBody: - $ref: '#/components/requestBodies/PromptTestOpenAIChat' + $ref: '#/components/requestBodies/MyFunc' responses: '200': description: Successful operation content: application/json: schema: - title: PromptTestOpenAIChatResponse - type: string - operationId: PromptTestOpenAIChat - /call/PromptTestOpenAIChatNoSystem: + title: MyFuncResponse + $ref: '#/components/schemas/DynamicOutput' + operationId: MyFunc + /call/NestedAlias: post: requestBody: - $ref: '#/components/requestBodies/PromptTestOpenAIChatNoSystem' + $ref: '#/components/requestBodies/NestedAlias' responses: '200': description: Successful operation content: application/json: schema: - title: PromptTestOpenAIChatNoSystemResponse - type: string - operationId: PromptTestOpenAIChatNoSystem - /call/PromptTestStreaming: + title: NestedAliasResponse + oneOf: + - oneOf: + - type: integer + - type: string + - type: boolean + - type: number + - type: array + items: + type: string + - type: object + additionalProperties: + type: array + items: + type: string + operationId: NestedAlias + /call/NullLiteralClassHello: post: requestBody: - $ref: '#/components/requestBodies/PromptTestStreaming' + $ref: '#/components/requestBodies/NullLiteralClassHello' responses: '200': description: Successful operation content: application/json: schema: - title: PromptTestStreamingResponse - type: string - operationId: PromptTestStreaming - /call/ReturnFailingAssert: + title: NullLiteralClassHelloResponse + $ref: '#/components/schemas/ClassForNullLiteral' + operationId: NullLiteralClassHello + /call/OptionalTest_Function: post: requestBody: - $ref: '#/components/requestBodies/ReturnFailingAssert' + $ref: '#/components/requestBodies/OptionalTest_Function' responses: '200': description: Successful operation content: application/json: schema: - title: ReturnFailingAssertResponse - type: integer - operationId: ReturnFailingAssert - /call/ReturnMalformedConstraints: - post: - requestBody: - $ref: '#/components/requestBodies/ReturnMalformedConstraints' - responses: - '200': - description: Successful operation - content: - application/json: - schema: - title: ReturnMalformedConstraintsResponse - $ref: '#/components/schemas/MalformedConstraints' - operationId: ReturnMalformedConstraints - /call/SchemaDescriptions: + title: OptionalTest_FunctionResponse + type: array + items: + $ref: '#/components/schemas/OptionalTest_ReturnType' + operationId: OptionalTest_Function + /call/PredictAge: post: requestBody: - $ref: '#/components/requestBodies/SchemaDescriptions' + $ref: '#/components/requestBodies/PredictAge' responses: '200': description: Successful operation content: application/json: schema: - title: SchemaDescriptionsResponse - $ref: '#/components/schemas/Schema' - operationId: SchemaDescriptions - /call/StreamBigNumbers: + title: PredictAgeResponse + $ref: '#/components/schemas/FooAny' + operationId: PredictAge + /call/PredictAgeBare: post: requestBody: - $ref: '#/components/requestBodies/StreamBigNumbers' + $ref: '#/components/requestBodies/PredictAgeBare' responses: '200': description: Successful operation content: application/json: schema: - title: StreamBigNumbersResponse - $ref: '#/components/schemas/BigNumbers' - operationId: StreamBigNumbers - /call/StreamFailingAssertion: + title: PredictAgeBareResponse + type: object + properties: + value: + type: integer + checks: + type: object + properties: + too_big: + $ref: '#components/schemas/Check' + required: + - too_big + additionalProperties: false + required: + - value + - checks + additionalProperties: false + operationId: PredictAgeBare + /call/PrimitiveAlias: post: requestBody: - $ref: '#/components/requestBodies/StreamFailingAssertion' + $ref: '#/components/requestBodies/PrimitiveAlias' responses: '200': description: Successful operation content: application/json: schema: - title: StreamFailingAssertionResponse - $ref: '#/components/schemas/TwoStoriesOneTitle' - operationId: StreamFailingAssertion - /call/StreamOneBigNumber: + title: PrimitiveAliasResponse + oneOf: + - type: integer + - type: string + - type: boolean + - type: number + operationId: PrimitiveAlias + /call/PromptTestClaude: post: requestBody: - $ref: '#/components/requestBodies/StreamOneBigNumber' + $ref: '#/components/requestBodies/PromptTestClaude' responses: '200': description: Successful operation content: application/json: schema: - title: StreamOneBigNumberResponse - type: integer - operationId: StreamOneBigNumber - /call/StreamUnionIntegers: + title: PromptTestClaudeResponse + type: string + operationId: PromptTestClaude + /call/PromptTestClaudeChat: post: requestBody: - $ref: '#/components/requestBodies/StreamUnionIntegers' + $ref: '#/components/requestBodies/PromptTestClaudeChat' responses: '200': description: Successful operation content: application/json: schema: - title: StreamUnionIntegersResponse - type: array - items: - oneOf: - - type: integer - - type: string - operationId: StreamUnionIntegers - /call/StreamingCompoundNumbers: + title: PromptTestClaudeChatResponse + type: string + operationId: PromptTestClaudeChat + /call/PromptTestClaudeChatNoSystem: post: requestBody: - $ref: '#/components/requestBodies/StreamingCompoundNumbers' + $ref: '#/components/requestBodies/PromptTestClaudeChatNoSystem' responses: '200': description: Successful operation content: application/json: schema: - title: StreamingCompoundNumbersResponse - $ref: '#/components/schemas/CompoundBigNumbers' - operationId: StreamingCompoundNumbers - /call/TestAnthropic: + title: PromptTestClaudeChatNoSystemResponse + type: string + operationId: PromptTestClaudeChatNoSystem + /call/PromptTestOpenAI: post: requestBody: - $ref: '#/components/requestBodies/TestAnthropic' + $ref: '#/components/requestBodies/PromptTestOpenAI' responses: '200': description: Successful operation content: application/json: schema: - title: TestAnthropicResponse + title: PromptTestOpenAIResponse type: string - operationId: TestAnthropic - /call/TestAnthropicShorthand: + operationId: PromptTestOpenAI + /call/PromptTestOpenAIChat: post: requestBody: - $ref: '#/components/requestBodies/TestAnthropicShorthand' + $ref: '#/components/requestBodies/PromptTestOpenAIChat' responses: '200': description: Successful operation content: application/json: schema: - title: TestAnthropicShorthandResponse + title: PromptTestOpenAIChatResponse type: string - operationId: TestAnthropicShorthand - /call/TestAws: + operationId: PromptTestOpenAIChat + /call/PromptTestOpenAIChatNoSystem: post: requestBody: - $ref: '#/components/requestBodies/TestAws' + $ref: '#/components/requestBodies/PromptTestOpenAIChatNoSystem' responses: '200': description: Successful operation content: application/json: schema: - title: TestAwsResponse + title: PromptTestOpenAIChatNoSystemResponse type: string - operationId: TestAws - /call/TestAzure: + operationId: PromptTestOpenAIChatNoSystem + /call/PromptTestStreaming: post: requestBody: - $ref: '#/components/requestBodies/TestAzure' + $ref: '#/components/requestBodies/PromptTestStreaming' responses: '200': description: Successful operation content: application/json: schema: - title: TestAzureResponse + title: PromptTestStreamingResponse type: string - operationId: TestAzure - /call/TestCaching: + operationId: PromptTestStreaming + /call/RecursiveAliasCycle: post: requestBody: - $ref: '#/components/requestBodies/TestCaching' + $ref: '#/components/requestBodies/RecursiveAliasCycle' responses: '200': description: Successful operation content: application/json: schema: - title: TestCachingResponse - type: string - operationId: TestCaching - /call/TestFallbackClient: + title: RecursiveAliasCycleResponse + anyOf: [] + operationId: RecursiveAliasCycle + /call/RecursiveClassWithAliasIndirection: post: requestBody: - $ref: '#/components/requestBodies/TestFallbackClient' + $ref: '#/components/requestBodies/RecursiveClassWithAliasIndirection' responses: '200': description: Successful operation content: application/json: schema: - title: TestFallbackClientResponse - type: string - operationId: TestFallbackClient - /call/TestFallbackToShorthand: + title: RecursiveClassWithAliasIndirectionResponse + $ref: '#/components/schemas/NodeWithAliasIndirection' + operationId: RecursiveClassWithAliasIndirection + /call/ReturnAliasWithMergedAttributes: post: requestBody: - $ref: '#/components/requestBodies/TestFallbackToShorthand' + $ref: '#/components/requestBodies/ReturnAliasWithMergedAttributes' responses: '200': description: Successful operation content: application/json: schema: - title: TestFallbackToShorthandResponse - type: string - operationId: TestFallbackToShorthand - /call/TestFnNamedArgsSingleBool: + title: ReturnAliasWithMergedAttributesResponse + type: object + properties: + value: + type: integer + checks: + type: object + properties: + gt_ten: + $ref: '#components/schemas/Check' + required: + - gt_ten + additionalProperties: false + required: + - value + - checks + additionalProperties: false + operationId: ReturnAliasWithMergedAttributes + /call/ReturnFailingAssert: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleBool' + $ref: '#/components/requestBodies/ReturnFailingAssert' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleBoolResponse - type: string - operationId: TestFnNamedArgsSingleBool - /call/TestFnNamedArgsSingleClass: + title: ReturnFailingAssertResponse + type: integer + operationId: ReturnFailingAssert + /call/ReturnMalformedConstraints: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleClass' + $ref: '#/components/requestBodies/ReturnMalformedConstraints' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleClassResponse - type: string - operationId: TestFnNamedArgsSingleClass - /call/TestFnNamedArgsSingleEnumList: + title: ReturnMalformedConstraintsResponse + $ref: '#/components/schemas/MalformedConstraints' + operationId: ReturnMalformedConstraints + /call/SchemaDescriptions: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleEnumList' + $ref: '#/components/requestBodies/SchemaDescriptions' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleEnumListResponse - type: string - operationId: TestFnNamedArgsSingleEnumList - /call/TestFnNamedArgsSingleFloat: + title: SchemaDescriptionsResponse + $ref: '#/components/schemas/Schema' + operationId: SchemaDescriptions + /call/SimpleRecursiveListAlias: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleFloat' + $ref: '#/components/requestBodies/SimpleRecursiveListAlias' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleFloatResponse - type: string - operationId: TestFnNamedArgsSingleFloat - /call/TestFnNamedArgsSingleInt: + title: SimpleRecursiveListAliasResponse + anyOf: [] + operationId: SimpleRecursiveListAlias + /call/SimpleRecursiveMapAlias: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleInt' + $ref: '#/components/requestBodies/SimpleRecursiveMapAlias' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleIntResponse - type: string - operationId: TestFnNamedArgsSingleInt - /call/TestFnNamedArgsSingleMapStringToClass: + title: SimpleRecursiveMapAliasResponse + anyOf: [] + operationId: SimpleRecursiveMapAlias + /call/StreamBigNumbers: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleMapStringToClass' + $ref: '#/components/requestBodies/StreamBigNumbers' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleMapStringToClassResponse - type: object - additionalProperties: - $ref: '#/components/schemas/StringToClassEntry' - operationId: TestFnNamedArgsSingleMapStringToClass - /call/TestFnNamedArgsSingleMapStringToMap: + title: StreamBigNumbersResponse + $ref: '#/components/schemas/BigNumbers' + operationId: StreamBigNumbers + /call/StreamFailingAssertion: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleMapStringToMap' + $ref: '#/components/requestBodies/StreamFailingAssertion' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleMapStringToMapResponse - type: object - additionalProperties: - type: object - additionalProperties: - type: string - operationId: TestFnNamedArgsSingleMapStringToMap - /call/TestFnNamedArgsSingleMapStringToString: + title: StreamFailingAssertionResponse + $ref: '#/components/schemas/TwoStoriesOneTitle' + operationId: StreamFailingAssertion + /call/StreamOneBigNumber: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleMapStringToString' + $ref: '#/components/requestBodies/StreamOneBigNumber' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleMapStringToStringResponse - type: object - additionalProperties: - type: string - operationId: TestFnNamedArgsSingleMapStringToString - /call/TestFnNamedArgsSingleString: + title: StreamOneBigNumberResponse + type: integer + operationId: StreamOneBigNumber + /call/StreamUnionIntegers: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleString' + $ref: '#/components/requestBodies/StreamUnionIntegers' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleStringResponse - type: string - operationId: TestFnNamedArgsSingleString - /call/TestFnNamedArgsSingleStringArray: + title: StreamUnionIntegersResponse + type: array + items: + oneOf: + - type: integer + - type: string + operationId: StreamUnionIntegers + /call/StreamingCompoundNumbers: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleStringArray' + $ref: '#/components/requestBodies/StreamingCompoundNumbers' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleStringArrayResponse - type: string - operationId: TestFnNamedArgsSingleStringArray - /call/TestFnNamedArgsSingleStringList: + title: StreamingCompoundNumbersResponse + $ref: '#/components/schemas/CompoundBigNumbers' + operationId: StreamingCompoundNumbers + /call/TestAnthropic: post: requestBody: - $ref: '#/components/requestBodies/TestFnNamedArgsSingleStringList' + $ref: '#/components/requestBodies/TestAnthropic' responses: '200': description: Successful operation content: application/json: schema: - title: TestFnNamedArgsSingleStringListResponse + title: TestAnthropicResponse type: string - operationId: TestFnNamedArgsSingleStringList - /call/TestGemini: + operationId: TestAnthropic + /call/TestAnthropicShorthand: post: requestBody: - $ref: '#/components/requestBodies/TestGemini' + $ref: '#/components/requestBodies/TestAnthropicShorthand' responses: '200': description: Successful operation content: application/json: schema: - title: TestGeminiResponse + title: TestAnthropicShorthandResponse type: string - operationId: TestGemini - /call/TestImageInput: + operationId: TestAnthropicShorthand + /call/TestAws: post: requestBody: - $ref: '#/components/requestBodies/TestImageInput' + $ref: '#/components/requestBodies/TestAws' responses: '200': description: Successful operation content: application/json: schema: - title: TestImageInputResponse + title: TestAwsResponse type: string - operationId: TestImageInput - /call/TestImageInputAnthropic: + operationId: TestAws + /call/TestAwsInvalidAccessKey: post: requestBody: - $ref: '#/components/requestBodies/TestImageInputAnthropic' + $ref: '#/components/requestBodies/TestAwsInvalidAccessKey' responses: '200': description: Successful operation content: application/json: schema: - title: TestImageInputAnthropicResponse + title: TestAwsInvalidAccessKeyResponse type: string - operationId: TestImageInputAnthropic - /call/TestImageListInput: + operationId: TestAwsInvalidAccessKey + /call/TestAwsInvalidProfile: post: requestBody: - $ref: '#/components/requestBodies/TestImageListInput' + $ref: '#/components/requestBodies/TestAwsInvalidProfile' responses: '200': description: Successful operation content: application/json: schema: - title: TestImageListInputResponse + title: TestAwsInvalidProfileResponse type: string - operationId: TestImageListInput - /call/TestMulticlassNamedArgs: + operationId: TestAwsInvalidProfile + /call/TestAwsInvalidRegion: post: requestBody: - $ref: '#/components/requestBodies/TestMulticlassNamedArgs' + $ref: '#/components/requestBodies/TestAwsInvalidRegion' responses: '200': description: Successful operation content: application/json: schema: - title: TestMulticlassNamedArgsResponse + title: TestAwsInvalidRegionResponse type: string - operationId: TestMulticlassNamedArgs - /call/TestOllama: + operationId: TestAwsInvalidRegion + /call/TestAwsInvalidSessionToken: post: requestBody: - $ref: '#/components/requestBodies/TestOllama' + $ref: '#/components/requestBodies/TestAwsInvalidSessionToken' responses: '200': description: Successful operation content: application/json: schema: - title: TestOllamaResponse + title: TestAwsInvalidSessionTokenResponse type: string - operationId: TestOllama - /call/TestOpenAILegacyProvider: + operationId: TestAwsInvalidSessionToken + /call/TestAzure: post: requestBody: - $ref: '#/components/requestBodies/TestOpenAILegacyProvider' + $ref: '#/components/requestBodies/TestAzure' responses: '200': description: Successful operation content: application/json: schema: - title: TestOpenAILegacyProviderResponse + title: TestAzureResponse type: string - operationId: TestOpenAILegacyProvider - /call/TestOpenAIShorthand: + operationId: TestAzure + /call/TestAzureFailure: post: requestBody: - $ref: '#/components/requestBodies/TestOpenAIShorthand' + $ref: '#/components/requestBodies/TestAzureFailure' responses: '200': description: Successful operation content: application/json: schema: - title: TestOpenAIShorthandResponse + title: TestAzureFailureResponse type: string - operationId: TestOpenAIShorthand - /call/TestRetryConstant: + operationId: TestAzureFailure + /call/TestCaching: post: requestBody: - $ref: '#/components/requestBodies/TestRetryConstant' + $ref: '#/components/requestBodies/TestCaching' responses: '200': description: Successful operation content: application/json: schema: - title: TestRetryConstantResponse + title: TestCachingResponse type: string - operationId: TestRetryConstant - /call/TestRetryExponential: + operationId: TestCaching + /call/TestFallbackClient: post: requestBody: - $ref: '#/components/requestBodies/TestRetryExponential' + $ref: '#/components/requestBodies/TestFallbackClient' responses: '200': description: Successful operation content: application/json: schema: - title: TestRetryExponentialResponse + title: TestFallbackClientResponse type: string - operationId: TestRetryExponential - /call/TestSingleFallbackClient: + operationId: TestFallbackClient + /call/TestFallbackToShorthand: post: requestBody: - $ref: '#/components/requestBodies/TestSingleFallbackClient' + $ref: '#/components/requestBodies/TestFallbackToShorthand' responses: '200': description: Successful operation content: application/json: schema: - title: TestSingleFallbackClientResponse + title: TestFallbackToShorthandResponse type: string - operationId: TestSingleFallbackClient - /call/TestVertex: + operationId: TestFallbackToShorthand + /call/TestFnNamedArgsSingleBool: post: requestBody: - $ref: '#/components/requestBodies/TestVertex' + $ref: '#/components/requestBodies/TestFnNamedArgsSingleBool' responses: '200': description: Successful operation content: application/json: schema: - title: TestVertexResponse + title: TestFnNamedArgsSingleBoolResponse type: string - operationId: TestVertex - /call/UnionTest_Function: + operationId: TestFnNamedArgsSingleBool + /call/TestFnNamedArgsSingleClass: post: requestBody: - $ref: '#/components/requestBodies/UnionTest_Function' + $ref: '#/components/requestBodies/TestFnNamedArgsSingleClass' responses: '200': description: Successful operation content: application/json: schema: - title: UnionTest_FunctionResponse - $ref: '#/components/schemas/UnionTest_ReturnType' - operationId: UnionTest_Function - /call/UseMalformedConstraints: + title: TestFnNamedArgsSingleClassResponse + type: string + operationId: TestFnNamedArgsSingleClass + /call/TestFnNamedArgsSingleEnumList: post: requestBody: - $ref: '#/components/requestBodies/UseMalformedConstraints' + $ref: '#/components/requestBodies/TestFnNamedArgsSingleEnumList' responses: '200': description: Successful operation content: application/json: schema: - title: UseMalformedConstraintsResponse - type: integer - operationId: UseMalformedConstraints -components: - requestBodies: - AaaSamOutputFormat: + title: TestFnNamedArgsSingleEnumListResponse + type: string + operationId: TestFnNamedArgsSingleEnumList + /call/TestFnNamedArgsSingleFloat: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleFloat' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleFloatResponse + type: string + operationId: TestFnNamedArgsSingleFloat + /call/TestFnNamedArgsSingleInt: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleInt' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleIntResponse + type: string + operationId: TestFnNamedArgsSingleInt + /call/TestFnNamedArgsSingleMapStringToClass: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleMapStringToClass' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleMapStringToClassResponse + type: object + additionalProperties: + $ref: '#/components/schemas/StringToClassEntry' + operationId: TestFnNamedArgsSingleMapStringToClass + /call/TestFnNamedArgsSingleMapStringToMap: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleMapStringToMap' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleMapStringToMapResponse + type: object + additionalProperties: + type: object + additionalProperties: + type: string + operationId: TestFnNamedArgsSingleMapStringToMap + /call/TestFnNamedArgsSingleMapStringToString: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleMapStringToString' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleMapStringToStringResponse + type: object + additionalProperties: + type: string + operationId: TestFnNamedArgsSingleMapStringToString + /call/TestFnNamedArgsSingleString: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleString' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleStringResponse + type: string + operationId: TestFnNamedArgsSingleString + /call/TestFnNamedArgsSingleStringArray: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleStringArray' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleStringArrayResponse + type: string + operationId: TestFnNamedArgsSingleStringArray + /call/TestFnNamedArgsSingleStringList: + post: + requestBody: + $ref: '#/components/requestBodies/TestFnNamedArgsSingleStringList' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestFnNamedArgsSingleStringListResponse + type: string + operationId: TestFnNamedArgsSingleStringList + /call/TestGemini: + post: + requestBody: + $ref: '#/components/requestBodies/TestGemini' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestGeminiResponse + type: string + operationId: TestGemini + /call/TestGeminiOpenAiGeneric: + post: + requestBody: + $ref: '#/components/requestBodies/TestGeminiOpenAiGeneric' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestGeminiOpenAiGenericResponse + type: string + operationId: TestGeminiOpenAiGeneric + /call/TestGeminiSystem: + post: + requestBody: + $ref: '#/components/requestBodies/TestGeminiSystem' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestGeminiSystemResponse + type: string + operationId: TestGeminiSystem + /call/TestGeminiSystemAsChat: + post: + requestBody: + $ref: '#/components/requestBodies/TestGeminiSystemAsChat' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestGeminiSystemAsChatResponse + type: string + operationId: TestGeminiSystemAsChat + /call/TestImageInput: + post: + requestBody: + $ref: '#/components/requestBodies/TestImageInput' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestImageInputResponse + type: string + operationId: TestImageInput + /call/TestImageInputAnthropic: + post: + requestBody: + $ref: '#/components/requestBodies/TestImageInputAnthropic' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestImageInputAnthropicResponse + type: string + operationId: TestImageInputAnthropic + /call/TestImageListInput: + post: + requestBody: + $ref: '#/components/requestBodies/TestImageListInput' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestImageListInputResponse + type: string + operationId: TestImageListInput + /call/TestMemory: + post: + requestBody: + $ref: '#/components/requestBodies/TestMemory' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestMemoryResponse + $ref: '#/components/schemas/TestMemoryOutput' + operationId: TestMemory + /call/TestMulticlassNamedArgs: + post: + requestBody: + $ref: '#/components/requestBodies/TestMulticlassNamedArgs' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestMulticlassNamedArgsResponse + type: string + operationId: TestMulticlassNamedArgs + /call/TestNamedArgsLiteralBool: + post: + requestBody: + $ref: '#/components/requestBodies/TestNamedArgsLiteralBool' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestNamedArgsLiteralBoolResponse + type: string + operationId: TestNamedArgsLiteralBool + /call/TestNamedArgsLiteralInt: + post: + requestBody: + $ref: '#/components/requestBodies/TestNamedArgsLiteralInt' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestNamedArgsLiteralIntResponse + type: string + operationId: TestNamedArgsLiteralInt + /call/TestNamedArgsLiteralString: + post: + requestBody: + $ref: '#/components/requestBodies/TestNamedArgsLiteralString' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestNamedArgsLiteralStringResponse + type: string + operationId: TestNamedArgsLiteralString + /call/TestOllama: + post: + requestBody: + $ref: '#/components/requestBodies/TestOllama' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestOllamaResponse + type: string + operationId: TestOllama + /call/TestOpenAILegacyProvider: + post: + requestBody: + $ref: '#/components/requestBodies/TestOpenAILegacyProvider' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestOpenAILegacyProviderResponse + type: string + operationId: TestOpenAILegacyProvider + /call/TestOpenAIShorthand: + post: + requestBody: + $ref: '#/components/requestBodies/TestOpenAIShorthand' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestOpenAIShorthandResponse + type: string + operationId: TestOpenAIShorthand + /call/TestRetryConstant: + post: + requestBody: + $ref: '#/components/requestBodies/TestRetryConstant' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestRetryConstantResponse + type: string + operationId: TestRetryConstant + /call/TestRetryExponential: + post: + requestBody: + $ref: '#/components/requestBodies/TestRetryExponential' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestRetryExponentialResponse + type: string + operationId: TestRetryExponential + /call/TestSingleFallbackClient: + post: + requestBody: + $ref: '#/components/requestBodies/TestSingleFallbackClient' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestSingleFallbackClientResponse + type: string + operationId: TestSingleFallbackClient + /call/TestUniverseQuestion: + post: + requestBody: + $ref: '#/components/requestBodies/TestUniverseQuestion' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestUniverseQuestionResponse + $ref: '#/components/schemas/UniverseQuestion' + operationId: TestUniverseQuestion + /call/TestVertex: + post: + requestBody: + $ref: '#/components/requestBodies/TestVertex' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestVertexResponse + type: string + operationId: TestVertex + /call/TestVertexWithSystemInstructions: + post: + requestBody: + $ref: '#/components/requestBodies/TestVertexWithSystemInstructions' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: TestVertexWithSystemInstructionsResponse + type: string + operationId: TestVertexWithSystemInstructions + /call/UnionTest_Function: + post: + requestBody: + $ref: '#/components/requestBodies/UnionTest_Function' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: UnionTest_FunctionResponse + $ref: '#/components/schemas/UnionTest_ReturnType' + operationId: UnionTest_Function + /call/UseBlockConstraint: + post: + requestBody: + $ref: '#/components/requestBodies/UseBlockConstraint' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: UseBlockConstraintResponse + type: integer + operationId: UseBlockConstraint + /call/UseMalformedConstraints: + post: + requestBody: + $ref: '#/components/requestBodies/UseMalformedConstraints' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: UseMalformedConstraintsResponse + type: integer + operationId: UseMalformedConstraints + /call/UseNestedBlockConstraint: + post: + requestBody: + $ref: '#/components/requestBodies/UseNestedBlockConstraint' + responses: + '200': + description: Successful operation + content: + application/json: + schema: + title: UseNestedBlockConstraintResponse + type: integer + operationId: UseNestedBlockConstraint +components: + requestBodies: + AaaSamOutputFormat: + required: true + content: + application/json: + schema: + title: AaaSamOutputFormatRequest + type: object + properties: + recipe: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - recipe + additionalProperties: false + AliasThatPointsToRecursiveType: + required: true + content: + application/json: + schema: + title: AliasThatPointsToRecursiveTypeRequest + type: object + properties: + list: + $ref: '#/components/schemas/LinkedListAliasNode' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - list + additionalProperties: false + AliasWithMultipleAttrs: + required: true + content: + application/json: + schema: + title: AliasWithMultipleAttrsRequest + type: object + properties: + money: + type: object + properties: + value: + type: integer + checks: + type: object + properties: + gt_ten: + $ref: '#components/schemas/Check' + required: + - gt_ten + additionalProperties: false + required: + - value + - checks + additionalProperties: false + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - money + additionalProperties: false + AliasedInputClass: + required: true + content: + application/json: + schema: + title: AliasedInputClassRequest + type: object + properties: + input: + $ref: '#/components/schemas/InputClass' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + AliasedInputClass2: + required: true + content: + application/json: + schema: + title: AliasedInputClass2Request + type: object + properties: + input: + $ref: '#/components/schemas/InputClass' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + AliasedInputClassNested: + required: true + content: + application/json: + schema: + title: AliasedInputClassNestedRequest + type: object + properties: + input: + $ref: '#/components/schemas/InputClassNested' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + AliasedInputEnum: + required: true + content: + application/json: + schema: + title: AliasedInputEnumRequest + type: object + properties: + input: + $ref: '#/components/schemas/AliasedEnum' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + AliasedInputList: + required: true + content: + application/json: + schema: + title: AliasedInputListRequest + type: object + properties: + input: + type: array + items: + $ref: '#/components/schemas/AliasedEnum' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + AllowedOptionals: + required: true + content: + application/json: + schema: + title: AllowedOptionalsRequest + type: object + properties: + optionals: + $ref: '#/components/schemas/OptionalListAndMap' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - optionals + additionalProperties: false + AssertFn: + required: true + content: + application/json: + schema: + title: AssertFnRequest + type: object + properties: + a: + type: integer + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - a + additionalProperties: false + AudioInput: + required: true + content: + application/json: + schema: + title: AudioInputRequest + type: object + properties: + aud: + $ref: '#/components/schemas/BamlAudio' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - aud + additionalProperties: false + BuildLinkedList: + required: true + content: + application/json: + schema: + title: BuildLinkedListRequest + type: object + properties: + input: + type: array + items: + type: integer + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + BuildTree: + required: true + content: + application/json: + schema: + title: BuildTreeRequest + type: object + properties: + input: + $ref: '#/components/schemas/BinaryNode' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + ClassThatPointsToRecursiveClassThroughAlias: + required: true + content: + application/json: + schema: + title: ClassThatPointsToRecursiveClassThroughAliasRequest + type: object + properties: + cls: + $ref: '#/components/schemas/ClassToRecAlias' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - cls + additionalProperties: false + ClassifyDynEnumTwo: + required: true + content: + application/json: + schema: + title: ClassifyDynEnumTwoRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + ClassifyMessage: + required: true + content: + application/json: + schema: + title: ClassifyMessageRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + ClassifyMessage2: + required: true + content: + application/json: + schema: + title: ClassifyMessage2Request + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + ClassifyMessage3: + required: true + content: + application/json: + schema: + title: ClassifyMessage3Request + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + Completion: + required: true + content: + application/json: + schema: + title: CompletionRequest + type: object + properties: + prefix: + type: string + suffix: + type: string + language: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - prefix + - suffix + - language + additionalProperties: false + CustomTask: + required: true + content: + application/json: + schema: + title: CustomTaskRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + DescribeImage: + required: true + content: + application/json: + schema: + title: DescribeImageRequest + type: object + properties: + img: + $ref: '#/components/schemas/BamlImage' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - img + additionalProperties: false + DescribeImage2: + required: true + content: + application/json: + schema: + title: DescribeImage2Request + type: object + properties: + classWithImage: + $ref: '#/components/schemas/ClassWithImage' + img2: + $ref: '#/components/schemas/BamlImage' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - classWithImage + - img2 + additionalProperties: false + DescribeImage3: + required: true + content: + application/json: + schema: + title: DescribeImage3Request + type: object + properties: + classWithImage: + $ref: '#/components/schemas/ClassWithImage' + img2: + $ref: '#/components/schemas/BamlImage' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - classWithImage + - img2 + additionalProperties: false + DescribeImage4: + required: true + content: + application/json: + schema: + title: DescribeImage4Request + type: object + properties: + classWithImage: + $ref: '#/components/schemas/ClassWithImage' + img2: + $ref: '#/components/schemas/BamlImage' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - classWithImage + - img2 + additionalProperties: false + DifferentiateUnions: + required: true + content: + application/json: + schema: + title: DifferentiateUnionsRequest + type: object + properties: + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: [] + additionalProperties: false + DummyOutputFunction: + required: true + content: + application/json: + schema: + title: DummyOutputFunctionRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + DynamicFunc: + required: true + content: + application/json: + schema: + title: DynamicFuncRequest + type: object + properties: + input: + $ref: '#/components/schemas/DynamicClassOne' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + DynamicInputOutput: required: true content: application/json: schema: - title: AaaSamOutputFormatRequest + title: DynamicInputOutputRequest type: object properties: - recipe: - type: string + input: + $ref: '#/components/schemas/DynInputOutput' __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - recipe + - input additionalProperties: false - AliasedInputClass: + DynamicListInputOutput: required: true content: application/json: schema: - title: AliasedInputClassRequest + title: DynamicListInputOutputRequest type: object properties: input: - $ref: '#/components/schemas/InputClass' + type: array + items: + $ref: '#/components/schemas/DynInputOutput' __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - input additionalProperties: false - AliasedInputClass2: + ExpectFailure: required: true content: application/json: schema: - title: AliasedInputClass2Request + title: ExpectFailureRequest type: object properties: - input: - $ref: '#/components/schemas/InputClass' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: [] + additionalProperties: false + ExtractContactInfo: + required: true + content: + application/json: + schema: + title: ExtractContactInfoRequest + type: object + properties: + document: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - document additionalProperties: false - AliasedInputClassNested: + ExtractHobby: required: true content: application/json: schema: - title: AliasedInputClassNestedRequest + title: ExtractHobbyRequest type: object properties: - input: - $ref: '#/components/schemas/InputClassNested' + text: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - text additionalProperties: false - AliasedInputEnum: + ExtractNames: required: true content: application/json: schema: - title: AliasedInputEnumRequest + title: ExtractNamesRequest type: object properties: input: - $ref: '#/components/schemas/AliasedEnum' + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - input additionalProperties: false - AliasedInputList: + ExtractPeople: required: true content: application/json: schema: - title: AliasedInputListRequest + title: ExtractPeopleRequest type: object properties: - input: - type: array - items: - $ref: '#/components/schemas/AliasedEnum' + text: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - text additionalProperties: false - AudioInput: + ExtractReceiptInfo: required: true content: application/json: schema: - title: AudioInputRequest + title: ExtractReceiptInfoRequest type: object properties: - aud: - $ref: '#/components/schemas/BamlAudio' + email: + type: string + reason: + oneOf: + - type: string + - type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - aud + - email + - reason additionalProperties: false - ClassifyDynEnumTwo: + ExtractResume: required: true content: application/json: schema: - title: ClassifyDynEnumTwoRequest + title: ExtractResumeRequest + type: object + properties: + resume: + type: string + img: + $ref: '#/components/schemas/BamlImage' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - resume + additionalProperties: false + ExtractResume2: + required: true + content: + application/json: + schema: + title: ExtractResume2Request + type: object + properties: + resume: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - resume + additionalProperties: false + FnClassOptionalOutput: + required: true + content: + application/json: + schema: + title: FnClassOptionalOutputRequest type: object properties: input: @@ -1445,12 +2676,12 @@ components: required: - input additionalProperties: false - ClassifyMessage: + FnClassOptionalOutput2: required: true content: application/json: schema: - title: ClassifyMessageRequest + title: FnClassOptionalOutput2Request type: object properties: input: @@ -1461,12 +2692,12 @@ components: required: - input additionalProperties: false - ClassifyMessage2: + FnEnumListOutput: required: true content: application/json: schema: - title: ClassifyMessage2Request + title: FnEnumListOutputRequest type: object properties: input: @@ -1477,12 +2708,12 @@ components: required: - input additionalProperties: false - ClassifyMessage3: + FnEnumOutput: required: true content: application/json: schema: - title: ClassifyMessage3Request + title: FnEnumOutputRequest type: object properties: input: @@ -1493,12 +2724,61 @@ components: required: - input additionalProperties: false - CustomTask: + FnLiteralClassInputOutput: required: true content: application/json: schema: - title: CustomTaskRequest + title: FnLiteralClassInputOutputRequest + type: object + properties: + input: + $ref: '#/components/schemas/LiteralClassHello' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + FnLiteralUnionClassInputOutput: + required: true + content: + application/json: + schema: + title: FnLiteralUnionClassInputOutputRequest + type: object + properties: + input: + oneOf: + - $ref: '#/components/schemas/LiteralClassOne' + - $ref: '#/components/schemas/LiteralClassTwo' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + FnNamedArgsSingleStringOptional: + required: true + content: + application/json: + schema: + title: FnNamedArgsSingleStringOptionalRequest + type: object + properties: + myString: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: [] + additionalProperties: false + FnOutputBool: + required: true + content: + application/json: + schema: + title: FnOutputBoolRequest type: object properties: input: @@ -1509,98 +2789,92 @@ components: required: - input additionalProperties: false - DescribeImage: + FnOutputClass: required: true content: application/json: schema: - title: DescribeImageRequest + title: FnOutputClassRequest type: object properties: - img: - $ref: '#/components/schemas/BamlImage' + input: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - img + - input additionalProperties: false - DescribeImage2: + FnOutputClassList: required: true content: application/json: schema: - title: DescribeImage2Request + title: FnOutputClassListRequest type: object properties: - classWithImage: - $ref: '#/components/schemas/ClassWithImage' - img2: - $ref: '#/components/schemas/BamlImage' + input: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - classWithImage - - img2 + - input additionalProperties: false - DescribeImage3: + FnOutputClassNested: required: true content: application/json: schema: - title: DescribeImage3Request + title: FnOutputClassNestedRequest type: object properties: - classWithImage: - $ref: '#/components/schemas/ClassWithImage' - img2: - $ref: '#/components/schemas/BamlImage' + input: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - classWithImage - - img2 + - input additionalProperties: false - DescribeImage4: + FnOutputClassWithEnum: required: true content: application/json: schema: - title: DescribeImage4Request + title: FnOutputClassWithEnumRequest type: object properties: - classWithImage: - $ref: '#/components/schemas/ClassWithImage' - img2: - $ref: '#/components/schemas/BamlImage' + input: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - classWithImage - - img2 + - input additionalProperties: false - DifferentiateUnions: + FnOutputInt: required: true content: application/json: schema: - title: DifferentiateUnionsRequest + title: FnOutputIntRequest type: object properties: + input: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' - required: [] + required: + - input additionalProperties: false - DummyOutputFunction: + FnOutputLiteralBool: required: true content: application/json: schema: - title: DummyOutputFunctionRequest + title: FnOutputLiteralBoolRequest type: object properties: input: @@ -1611,107 +2885,108 @@ components: required: - input additionalProperties: false - DynamicFunc: + FnOutputLiteralInt: required: true content: application/json: schema: - title: DynamicFuncRequest + title: FnOutputLiteralIntRequest type: object properties: input: - $ref: '#/components/schemas/DynamicClassOne' + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - input additionalProperties: false - DynamicInputOutput: + FnOutputLiteralString: required: true content: application/json: schema: - title: DynamicInputOutputRequest + title: FnOutputLiteralStringRequest type: object properties: input: - $ref: '#/components/schemas/DynInputOutput' + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - input additionalProperties: false - DynamicListInputOutput: + FnOutputStringList: required: true content: application/json: schema: - title: DynamicListInputOutputRequest + title: FnOutputStringListRequest type: object properties: input: - type: array - items: - $ref: '#/components/schemas/DynInputOutput' + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - input additionalProperties: false - ExpectFailure: + FnTestAliasedEnumOutput: required: true content: application/json: schema: - title: ExpectFailureRequest + title: FnTestAliasedEnumOutputRequest type: object properties: + input: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' - required: [] + required: + - input additionalProperties: false - ExtractContactInfo: + FnTestClassAlias: required: true content: application/json: schema: - title: ExtractContactInfoRequest + title: FnTestClassAliasRequest type: object properties: - document: + input: type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - document + - input additionalProperties: false - ExtractNames: + FnTestNamedArgsSingleEnum: required: true content: application/json: schema: - title: ExtractNamesRequest + title: FnTestNamedArgsSingleEnumRequest type: object properties: - input: - type: string + myArg: + $ref: '#/components/schemas/NamedArgsSingleEnum' __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - myArg additionalProperties: false - ExtractPeople: + GetDataType: required: true content: application/json: schema: - title: ExtractPeopleRequest + title: GetDataTypeRequest type: object properties: text: @@ -1722,115 +2997,124 @@ components: required: - text additionalProperties: false - ExtractReceiptInfo: + GetOrderInfo: required: true content: application/json: schema: - title: ExtractReceiptInfoRequest + title: GetOrderInfoRequest type: object properties: email: - type: string - reason: - oneOf: - - type: string - - type: string + $ref: '#/components/schemas/Email' __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - email - - reason additionalProperties: false - ExtractResume: + GetQuery: required: true content: application/json: schema: - title: ExtractResumeRequest + title: GetQueryRequest type: object properties: - resume: + query: type: string - img: - $ref: '#/components/schemas/BamlImage' __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - resume + - query additionalProperties: false - ExtractResume2: + InOutEnumMapKey: required: true content: application/json: schema: - title: ExtractResume2Request + title: InOutEnumMapKeyRequest type: object properties: - resume: - type: string + i1: + type: object + additionalProperties: + type: string + i2: + type: object + additionalProperties: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - resume + - i1 + - i2 additionalProperties: false - FnClassOptionalOutput: + InOutLiteralStringUnionMapKey: required: true content: application/json: schema: - title: FnClassOptionalOutputRequest + title: InOutLiteralStringUnionMapKeyRequest type: object properties: - input: - type: string + i1: + type: object + additionalProperties: + type: string + i2: + type: object + additionalProperties: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - i1 + - i2 additionalProperties: false - FnClassOptionalOutput2: + InOutSingleLiteralStringMapKey: required: true content: application/json: schema: - title: FnClassOptionalOutput2Request + title: InOutSingleLiteralStringMapKeyRequest type: object properties: - input: - type: string + m: + type: object + additionalProperties: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - m additionalProperties: false - FnEnumListOutput: + JsonTypeAliasCycle: required: true content: application/json: schema: - title: FnEnumListOutputRequest + title: JsonTypeAliasCycleRequest type: object properties: input: - type: string + anyOf: [] __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - input additionalProperties: false - FnEnumOutput: + LiteralUnionsTest: required: true content: application/json: schema: - title: FnEnumOutputRequest + title: LiteralUnionsTestRequest type: object properties: input: @@ -1841,91 +3125,87 @@ components: required: - input additionalProperties: false - FnNamedArgsSingleStringOptional: + MakeBlockConstraint: required: true content: application/json: schema: - title: FnNamedArgsSingleStringOptionalRequest + title: MakeBlockConstraintRequest type: object properties: - myString: - type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: [] additionalProperties: false - FnOutputBool: + MakeNestedBlockConstraint: required: true content: application/json: schema: - title: FnOutputBoolRequest + title: MakeNestedBlockConstraintRequest type: object properties: - input: - type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' - required: - - input + required: [] additionalProperties: false - FnOutputClass: + MakeSemanticContainer: required: true content: application/json: schema: - title: FnOutputClassRequest + title: MakeSemanticContainerRequest type: object properties: - input: - type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' - required: - - input + required: [] additionalProperties: false - FnOutputClassList: + MapAlias: required: true content: application/json: schema: - title: FnOutputClassListRequest + title: MapAliasRequest type: object properties: - input: - type: string + m: + type: object + additionalProperties: + type: array + items: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - m additionalProperties: false - FnOutputClassNested: + MergeAliasAttributes: required: true content: application/json: schema: - title: FnOutputClassNestedRequest + title: MergeAliasAttributesRequest type: object properties: - input: - type: string + money: + type: integer __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - money additionalProperties: false - FnOutputClassWithEnum: + MyFunc: required: true content: application/json: schema: - title: FnOutputClassWithEnumRequest + title: MyFuncRequest type: object properties: input: @@ -1936,44 +3216,57 @@ components: required: - input additionalProperties: false - FnOutputStringList: + NestedAlias: required: true content: application/json: schema: - title: FnOutputStringListRequest + title: NestedAliasRequest type: object properties: - input: - type: string + c: + oneOf: + - oneOf: + - type: integer + - type: string + - type: boolean + - type: number + - type: array + items: + type: string + - type: object + additionalProperties: + type: array + items: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - c additionalProperties: false - FnTestAliasedEnumOutput: + NullLiteralClassHello: required: true content: application/json: schema: - title: FnTestAliasedEnumOutputRequest + title: NullLiteralClassHelloRequest type: object properties: - input: + s: type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - s additionalProperties: false - FnTestClassAlias: + OptionalTest_Function: required: true content: application/json: schema: - title: FnTestClassAliasRequest + title: OptionalTest_FunctionRequest type: object properties: input: @@ -1984,76 +3277,80 @@ components: required: - input additionalProperties: false - FnTestNamedArgsSingleEnum: + PredictAge: required: true content: application/json: schema: - title: FnTestNamedArgsSingleEnumRequest + title: PredictAgeRequest type: object properties: - myArg: - $ref: '#/components/schemas/NamedArgsSingleEnum' + name: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - myArg + - name additionalProperties: false - GetDataType: + PredictAgeBare: required: true content: application/json: schema: - title: GetDataTypeRequest + title: PredictAgeBareRequest type: object properties: - text: + inp: type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - text + - inp additionalProperties: false - GetOrderInfo: + PrimitiveAlias: required: true content: application/json: schema: - title: GetOrderInfoRequest + title: PrimitiveAliasRequest type: object properties: - email: - $ref: '#/components/schemas/Email' + p: + oneOf: + - type: integer + - type: string + - type: boolean + - type: number __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - email + - p additionalProperties: false - GetQuery: + PromptTestClaude: required: true content: application/json: schema: - title: GetQueryRequest + title: PromptTestClaudeRequest type: object properties: - query: + input: type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - query + - input additionalProperties: false - MyFunc: + PromptTestClaudeChat: required: true content: application/json: schema: - title: MyFuncRequest + title: PromptTestClaudeChatRequest type: object properties: input: @@ -2064,12 +3361,12 @@ components: required: - input additionalProperties: false - OptionalTest_Function: + PromptTestClaudeChatNoSystem: required: true content: application/json: schema: - title: OptionalTest_FunctionRequest + title: PromptTestClaudeChatNoSystemRequest type: object properties: input: @@ -2080,44 +3377,44 @@ components: required: - input additionalProperties: false - PredictAge: + PromptTestOpenAI: required: true content: application/json: schema: - title: PredictAgeRequest + title: PromptTestOpenAIRequest type: object properties: - name: + input: type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - name + - input additionalProperties: false - PredictAgeBare: + PromptTestOpenAIChat: required: true content: application/json: schema: - title: PredictAgeBareRequest + title: PromptTestOpenAIChatRequest type: object properties: - inp: + input: type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - inp + - input additionalProperties: false - PromptTestClaude: + PromptTestOpenAIChatNoSystem: required: true content: application/json: schema: - title: PromptTestClaudeRequest + title: PromptTestOpenAIChatNoSystemRequest type: object properties: input: @@ -2128,12 +3425,12 @@ components: required: - input additionalProperties: false - PromptTestClaudeChat: + PromptTestStreaming: required: true content: application/json: schema: - title: PromptTestClaudeChatRequest + title: PromptTestStreamingRequest type: object properties: input: @@ -2144,128 +3441,143 @@ components: required: - input additionalProperties: false - PromptTestClaudeChatNoSystem: + RecursiveAliasCycle: required: true content: application/json: schema: - title: PromptTestClaudeChatNoSystemRequest + title: RecursiveAliasCycleRequest type: object properties: input: - type: string + anyOf: [] __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - input additionalProperties: false - PromptTestOpenAI: + RecursiveClassWithAliasIndirection: required: true content: application/json: schema: - title: PromptTestOpenAIRequest + title: RecursiveClassWithAliasIndirectionRequest type: object properties: - input: - type: string + cls: + $ref: '#/components/schemas/NodeWithAliasIndirection' __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - cls additionalProperties: false - PromptTestOpenAIChat: + ReturnAliasWithMergedAttributes: required: true content: application/json: schema: - title: PromptTestOpenAIChatRequest + title: ReturnAliasWithMergedAttributesRequest type: object properties: - input: - type: string + money: + type: object + properties: + value: + type: integer + checks: + type: object + properties: + gt_ten: + $ref: '#components/schemas/Check' + required: + - gt_ten + additionalProperties: false + required: + - value + - checks + additionalProperties: false __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - money additionalProperties: false - PromptTestOpenAIChatNoSystem: + ReturnFailingAssert: required: true content: application/json: schema: - title: PromptTestOpenAIChatNoSystemRequest + title: ReturnFailingAssertRequest type: object properties: - input: - type: string + inp: + type: integer __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - inp additionalProperties: false - PromptTestStreaming: + ReturnMalformedConstraints: required: true content: application/json: schema: - title: PromptTestStreamingRequest + title: ReturnMalformedConstraintsRequest type: object properties: - input: - type: string + a: + type: integer __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - input + - a additionalProperties: false - ReturnFailingAssert: + SchemaDescriptions: required: true content: application/json: schema: - title: ReturnFailingAssertRequest + title: SchemaDescriptionsRequest type: object properties: - inp: - type: integer + input: + type: string __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - inp + - input additionalProperties: false - ReturnMalformedConstraints: + SimpleRecursiveListAlias: required: true content: application/json: schema: - title: ReturnMalformedConstraintsRequest + title: SimpleRecursiveListAliasRequest type: object properties: - a: - type: integer + input: + anyOf: [] __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' required: - - a + - input additionalProperties: false - SchemaDescriptions: + SimpleRecursiveMapAlias: required: true content: application/json: schema: - title: SchemaDescriptionsRequest + title: SimpleRecursiveMapAliasRequest type: object properties: input: - type: string + anyOf: [] __baml_options__: nullable: true $ref: '#/components/schemas/BamlOptions' @@ -2406,6 +3718,70 @@ components: required: - input additionalProperties: false + TestAwsInvalidAccessKey: + required: true + content: + application/json: + schema: + title: TestAwsInvalidAccessKeyRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + TestAwsInvalidProfile: + required: true + content: + application/json: + schema: + title: TestAwsInvalidProfileRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + TestAwsInvalidRegion: + required: true + content: + application/json: + schema: + title: TestAwsInvalidRegionRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + TestAwsInvalidSessionToken: + required: true + content: + application/json: + schema: + title: TestAwsInvalidSessionTokenRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false TestAzure: required: true content: @@ -2422,6 +3798,22 @@ components: required: - input additionalProperties: false + TestAzureFailure: + required: true + content: + application/json: + schema: + title: TestAzureFailureRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false TestCaching: required: true content: @@ -2676,6 +4068,51 @@ components: required: - input additionalProperties: false + TestGeminiOpenAiGeneric: + required: true + content: + application/json: + schema: + title: TestGeminiOpenAiGenericRequest + type: object + properties: + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: [] + additionalProperties: false + TestGeminiSystem: + required: true + content: + application/json: + schema: + title: TestGeminiSystemRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false + TestGeminiSystemAsChat: + required: true + content: + application/json: + schema: + title: TestGeminiSystemAsChatRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false TestImageInput: required: true content: @@ -2726,6 +4163,22 @@ components: required: - imgs additionalProperties: false + TestMemory: + required: true + content: + application/json: + schema: + title: TestMemoryRequest + type: object + properties: + input: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - input + additionalProperties: false TestMulticlassNamedArgs: required: true content: @@ -2745,6 +4198,54 @@ components: - myArg - myArg2 additionalProperties: false + TestNamedArgsLiteralBool: + required: true + content: + application/json: + schema: + title: TestNamedArgsLiteralBoolRequest + type: object + properties: + myBool: + type: boolean + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - myBool + additionalProperties: false + TestNamedArgsLiteralInt: + required: true + content: + application/json: + schema: + title: TestNamedArgsLiteralIntRequest + type: object + properties: + myInt: + type: integer + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - myInt + additionalProperties: false + TestNamedArgsLiteralString: + required: true + content: + application/json: + schema: + title: TestNamedArgsLiteralStringRequest + type: object + properties: + myString: + type: string + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - myString + additionalProperties: false TestOllama: required: true content: @@ -2832,6 +4333,22 @@ components: $ref: '#/components/schemas/BamlOptions' required: [] additionalProperties: false + TestUniverseQuestion: + required: true + content: + application/json: + schema: + title: TestUniverseQuestionRequest + type: object + properties: + question: + $ref: '#/components/schemas/UniverseQuestionInput' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - question + additionalProperties: false TestVertex: required: true content: @@ -2848,6 +4365,19 @@ components: required: - input additionalProperties: false + TestVertexWithSystemInstructions: + required: true + content: + application/json: + schema: + title: TestVertexWithSystemInstructionsRequest + type: object + properties: + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: [] + additionalProperties: false UnionTest_Function: required: true content: @@ -2866,6 +4396,22 @@ components: required: - input additionalProperties: false + UseBlockConstraint: + required: true + content: + application/json: + schema: + title: UseBlockConstraintRequest + type: object + properties: + inp: + $ref: '#/components/schemas/BlockConstraintForParam' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - inp + additionalProperties: false UseMalformedConstraints: required: true content: @@ -2882,6 +4428,22 @@ components: required: - a additionalProperties: false + UseNestedBlockConstraint: + required: true + content: + application/json: + schema: + title: UseNestedBlockConstraintRequest + type: object + properties: + inp: + $ref: '#/components/schemas/NestedBlockConstraintForParam' + __baml_options__: + nullable: true + $ref: '#/components/schemas/BamlOptions' + required: + - inp + additionalProperties: false schemas: BamlImage: oneOf: @@ -3032,6 +4594,12 @@ components: - MUSIC - READING type: string + MapKey: + enum: + - A + - B + - C + type: string NamedArgsSingleEnum: enum: - ONE @@ -3071,6 +4639,20 @@ components: - F - G type: string + AnotherObject: + type: object + properties: + id: + type: string + thingy2: + type: string + thingy3: + type: string + required: + - id + - thingy2 + - thingy3 + additionalProperties: false BigNumbers: type: object properties: @@ -3082,12 +4664,46 @@ components: - a - b additionalProperties: false - Blah: + BinaryNode: + type: object + properties: + data: + type: integer + left: + $ref: '#/components/schemas/BinaryNode' + right: + $ref: '#/components/schemas/BinaryNode' + required: + - data + additionalProperties: false + Blah: + type: object + properties: + prop4: + type: string + required: [] + additionalProperties: false + BlockConstraint: + type: object + properties: + foo: + type: integer + bar: + type: string + required: + - foo + - bar + additionalProperties: false + BlockConstraintForParam: type: object properties: - prop4: + bcfp: + type: integer + bcfp2: type: string - required: [] + required: + - bcfp + - bcfp2 additionalProperties: false BookOrder: type: object @@ -3106,6 +4722,14 @@ components: - quantity - price additionalProperties: false + ClassForNullLiteral: + type: object + properties: + a: + type: string + required: + - a + additionalProperties: false ClassOptionalOutput: type: object properties: @@ -3128,6 +4752,25 @@ components: $ref: '#/components/schemas/Blah' required: [] additionalProperties: false + ClassToRecAlias: + type: object + properties: + list: + $ref: '#/components/schemas/LinkedListAliasNode' + required: + - list + additionalProperties: false + ClassWithBlockDone: + type: object + properties: + i_16_digits: + type: integer + s_20_words: + type: string + required: + - i_16_digits + - s_20_words + additionalProperties: false ClassWithImage: type: object properties: @@ -3142,6 +4785,39 @@ components: - param2 - fake_image additionalProperties: false + ClassWithoutDone: + type: object + properties: + i_16_digits: + type: integer + s_20_words: + type: string + required: + - i_16_digits + - s_20_words + additionalProperties: false + ComplexMemoryObject: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + metadata: + type: array + items: + oneOf: + - type: string + - type: integer + - type: number + required: + - id + - name + - description + - metadata + additionalProperties: false CompoundBigNumbers: type: object properties: @@ -3294,22 +4970,7 @@ components: type: object properties: value: - type: object - properties: - value: - type: string - checks: - type: object - properties: - valid_email: - $ref: '#components/schemas/Check' - required: - - valid_email - additionalProperties: false - required: - - value - - checks - additionalProperties: false + type: string required: - value additionalProperties: false @@ -3390,16 +5051,16 @@ components: checks: type: object properties: + regex_good: + $ref: '#components/schemas/Check' regex_bad: $ref: '#components/schemas/Check' trivial: $ref: '#components/schemas/Check' - regex_good: - $ref: '#components/schemas/Check' required: + - regex_good - regex_bad - trivial - - regex_good additionalProperties: false required: - value @@ -3410,6 +5071,60 @@ components: - certainty - species additionalProperties: false + Forest: + type: object + properties: + trees: + type: array + items: + $ref: '#/components/schemas/Tree' + required: + - trees + additionalProperties: false + FormatterTest0: + type: object + properties: + lorem: + type: string + ipsum: + type: string + required: + - lorem + - ipsum + additionalProperties: false + FormatterTest1: + type: object + properties: + lorem: + type: string + ipsum: + type: string + required: + - lorem + - ipsum + additionalProperties: false + FormatterTest2: + type: object + properties: + lorem: + type: string + ipsum: + type: string + required: + - lorem + - ipsum + additionalProperties: false + FormatterTest3: + type: object + properties: + lorem: + type: string + ipsum: + type: string + required: + - lorem + - ipsum + additionalProperties: false GroceryReceipt: type: object properties: @@ -3479,6 +5194,50 @@ components: - key - nested additionalProperties: false + LinkedList: + type: object + properties: + head: + $ref: '#/components/schemas/Node' + len: + type: integer + required: + - len + additionalProperties: false + LinkedListAliasNode: + type: object + properties: + value: + type: integer + next: + $ref: '#/components/schemas/LinkedListAliasNode' + required: + - value + additionalProperties: false + LiteralClassHello: + type: object + properties: + prop: + type: string + required: + - prop + additionalProperties: false + LiteralClassOne: + type: object + properties: + prop: + type: string + required: + - prop + additionalProperties: false + LiteralClassTwo: + type: object + properties: + prop: + type: string + required: + - prop + additionalProperties: false MalformedConstraints: type: object properties: @@ -3533,6 +5292,43 @@ components: required: - age additionalProperties: false + MemoryObject: + type: object + properties: + id: + type: string + name: + type: string + description: + type: string + required: + - id + - name + - description + additionalProperties: false + MergeAttrs: + type: object + properties: + amount: + type: object + properties: + value: + type: integer + checks: + type: object + properties: + gt_ten: + $ref: '#components/schemas/Check' + required: + - gt_ten + additionalProperties: false + required: + - value + - checks + additionalProperties: false + required: + - amount + additionalProperties: false NamedArgsSingleClass: type: object properties: @@ -3572,6 +5368,70 @@ components: - type: string required: [] additionalProperties: false + NestedBlockConstraint: + type: object + properties: + nbc: + type: object + properties: + value: + $ref: '#/components/schemas/BlockConstraint' + checks: + type: object + properties: + cross_field: + $ref: '#components/schemas/Check' + required: + - cross_field + additionalProperties: false + required: + - value + - checks + additionalProperties: false + required: + - nbc + additionalProperties: false + NestedBlockConstraintForParam: + type: object + properties: + nbcfp: + $ref: '#/components/schemas/BlockConstraintForParam' + required: + - nbcfp + additionalProperties: false + Node: + type: object + properties: + data: + type: integer + next: + $ref: '#/components/schemas/Node' + required: + - data + additionalProperties: false + NodeWithAliasIndirection: + type: object + properties: + value: + type: integer + next: + $ref: '#/components/schemas/NodeWithAliasIndirection' + required: + - value + additionalProperties: false + OptionalListAndMap: + type: object + properties: + p: + type: array + items: + type: string + q: + type: object + additionalProperties: + type: string + required: [] + additionalProperties: false OptionalTest_Prop1: type: object properties: @@ -3638,22 +5498,7 @@ components: type: object properties: value: - type: object - properties: - value: - type: string - checks: - type: object - properties: - valid_phone_number: - $ref: '#components/schemas/Check' - required: - - valid_phone_number - additionalProperties: false - required: - - value - - checks - additionalProperties: false + type: string required: - value additionalProperties: false @@ -3830,6 +5675,48 @@ components: - description - tags additionalProperties: false + SemanticContainer: + type: object + properties: + sixteen_digit_number: + type: integer + string_with_twenty_words: + type: string + class_1: + $ref: '#/components/schemas/ClassWithoutDone' + class_2: + $ref: '#/components/schemas/ClassWithBlockDone' + class_done_needed: + $ref: '#/components/schemas/ClassWithBlockDone' + class_needed: + $ref: '#/components/schemas/ClassWithoutDone' + three_small_things: + type: array + items: + $ref: '#/components/schemas/SmallThing' + final_string: + type: string + required: + - sixteen_digit_number + - string_with_twenty_words + - class_1 + - class_2 + - class_done_needed + - class_needed + - three_small_things + - final_string + additionalProperties: false + SmallThing: + type: object + properties: + i_16_digits: + type: integer + i_8_digits: + type: integer + required: + - i_16_digits + - i_8_digits + additionalProperties: false SomeClassNestedDynamic: type: object properties: @@ -3888,6 +5775,27 @@ components: - prop1 - prop2 additionalProperties: false + TestMemoryOutput: + type: object + properties: + items: + type: array + items: + oneOf: + - $ref: '#/components/schemas/MemoryObject' + - $ref: '#/components/schemas/ComplexMemoryObject' + - $ref: '#/components/schemas/AnotherObject' + more_items: + type: array + items: + oneOf: + - $ref: '#/components/schemas/MemoryObject' + - $ref: '#/components/schemas/ComplexMemoryObject' + - $ref: '#/components/schemas/AnotherObject' + required: + - items + - more_items + additionalProperties: false TestOutputClass: type: object properties: @@ -3899,6 +5807,17 @@ components: - prop1 - prop2 additionalProperties: false + Tree: + type: object + properties: + data: + type: integer + children: + $ref: '#/components/schemas/Forest' + required: + - data + - children + additionalProperties: false TwoStoriesOneTitle: type: object properties: @@ -3939,6 +5858,25 @@ components: - prop2 - prop3 additionalProperties: false + UniverseQuestion: + type: object + properties: + question: + type: string + answer: + type: string + required: + - question + - answer + additionalProperties: false + UniverseQuestionInput: + type: object + properties: + question: + type: string + required: + - question + additionalProperties: false WithReasoning: type: object properties: diff --git a/integ-tests/python/baml_client/__init__.py b/integ-tests/python/baml_client/__init__.py new file mode 100644 index 000000000..bca77fa35 --- /dev/null +++ b/integ-tests/python/baml_client/__init__.py @@ -0,0 +1,32 @@ +############################################################################### +# +# Welcome to Baml! To use this generated code, please run the following: +# +# $ pip install baml +# +############################################################################### + +# This file was generated by BAML: please do not edit it. Instead, edit the +# BAML files and re-generate this code. +# +# ruff: noqa: E501,F401 +# flake8: noqa: E501,F401 +# pylint: disable=unused-import,line-too-long +# fmt: off +from . import types +from . import tracing +from . import partial_types +from .globals import reset_baml_env_vars + + +from .async_client import b + + + +__all__ = [ + "b", + "partial_types", + "tracing", + "types", + "reset_baml_env_vars", +] \ No newline at end of file diff --git a/integ-tests/python/baml_client/async_client.py b/integ-tests/python/baml_client/async_client.py index a9a82a5a2..88b4c668c 100644 --- a/integ-tests/python/baml_client/async_client.py +++ b/integ-tests/python/baml_client/async_client.py @@ -2971,6 +2971,29 @@ async def TestImageListInput( ) return cast(str, raw.cast_to(types, types, partial_types, False)) + async def TestMemory( + self, + input: str, + baml_options: BamlCallOptions = {}, + ) -> types.TestMemoryOutput: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = await self.__runtime.call_function( + "TestMemory", + { + "input": input, + }, + self.__ctx_manager.get(), + tb, + __cr__, + ) + return cast(types.TestMemoryOutput, raw.cast_to(types, types, partial_types, False)) + async def TestMulticlassNamedArgs( self, myArg: types.NamedArgsSingleClass,myArg2: types.NamedArgsSingleClass, @@ -7188,6 +7211,36 @@ def TestImageListInput( self.__ctx_manager.get(), ) + def TestMemory( + self, + input: str, + baml_options: BamlCallOptions = {}, + ) -> baml_py.BamlStream[partial_types.TestMemoryOutput, types.TestMemoryOutput]: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = self.__runtime.stream_function( + "TestMemory", + { + "input": input, + }, + None, + self.__ctx_manager.get(), + tb, + __cr__, + ) + + return baml_py.BamlStream[partial_types.TestMemoryOutput, types.TestMemoryOutput]( + raw, + lambda x: cast(partial_types.TestMemoryOutput, x.cast_to(types, types, partial_types, True)), + lambda x: cast(types.TestMemoryOutput, x.cast_to(types, types, partial_types, False)), + self.__ctx_manager.get(), + ) + def TestMulticlassNamedArgs( self, myArg: types.NamedArgsSingleClass,myArg2: types.NamedArgsSingleClass, diff --git a/integ-tests/python/baml_client/globals.py b/integ-tests/python/baml_client/globals.py new file mode 100644 index 000000000..8cc8cb652 --- /dev/null +++ b/integ-tests/python/baml_client/globals.py @@ -0,0 +1,41 @@ +############################################################################### +# +# Welcome to Baml! To use this generated code, please run the following: +# +# $ pip install baml +# +############################################################################### + +# This file was generated by BAML: please do not edit it. Instead, edit the +# BAML files and re-generate this code. +# +# ruff: noqa: E501,F401 +# flake8: noqa: E501,F401 +# pylint: disable=unused-import,line-too-long +# fmt: off +import os + +from baml_py import BamlCtxManager, BamlRuntime +from baml_py.baml_py import BamlError +from .inlinedbaml import get_baml_files +from typing import Dict + +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME = BamlRuntime.from_files( + "baml_src", + get_baml_files(), + os.environ.copy() +) +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX = BamlCtxManager(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME) + +def reset_baml_env_vars(env_vars: Dict[str, str]): + if DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.allow_reset(): + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME.reset( + "baml_src", + get_baml_files(), + env_vars + ) + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.reset() + else: + raise BamlError("Cannot reset BAML environment variables while there are active BAML contexts.") + +__all__ = [] \ No newline at end of file diff --git a/integ-tests/python/baml_client/inlinedbaml.py b/integ-tests/python/baml_client/inlinedbaml.py index e4cd0766b..1073051a2 100644 --- a/integ-tests/python/baml_client/inlinedbaml.py +++ b/integ-tests/python/baml_client/inlinedbaml.py @@ -26,7 +26,7 @@ "fiddle-examples/images/image.baml": "function DescribeImage(img: image) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\") }}\n\n\n Describe the image below in 20 words:\n {{ img }}\n \"#\n\n}\n\nclass FakeImage {\n url string\n}\n\nclass ClassWithImage {\n myImage image\n param2 string\n fake_image FakeImage\n}\n\n// chat role user present\nfunction DescribeImage2(classWithImage: ClassWithImage, img2: image) -> string { \n client GPT4Turbo\n prompt #\"\n {{ _.role(\"user\") }}\n You should return 2 answers that answer the following commands.\n\n 1. Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n 2. Also tell me what's happening here in one sentence:\n {{ img2 }}\n \"#\n}\n\n// no chat role\nfunction DescribeImage3(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\n\n// system prompt and chat prompt\nfunction DescribeImage4(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n {{ _.role(\"system\")}}\n\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\ntest TestName {\n functions [DescribeImage]\n args {\n img { url \"https://imgs.xkcd.com/comics/standards.png\"}\n }\n}\n", "fiddle-examples/symbol-tuning.baml": "enum Category3 {\n Refund @alias(\"k1\")\n @description(\"Customer wants to refund a product\")\n\n CancelOrder @alias(\"k2\")\n @description(\"Customer wants to cancel an order\")\n\n TechnicalSupport @alias(\"k3\")\n @description(\"Customer needs help with a technical issue unrelated to account creation or login\")\n\n AccountIssue @alias(\"k4\")\n @description(\"Specifically relates to account-login or account-creation\")\n\n Question @alias(\"k5\")\n @description(\"Customer has a question\")\n}\n\nfunction ClassifyMessage3(input: string) -> Category {\n client GPT4\n\n prompt #\"\n Classify the following INPUT into ONE\n of the following categories:\n\n INPUT: {{ input }}\n\n {{ ctx.output_format }}\n\n Response:\n \"#\n}", "formatter/test-comments.baml": "class FormatterTest0 {\n lorem string // trailing comments should be preserved\n ipsum string\n}\n\nclass FormatterTest1 {\n lorem string\n ipsum string\n // dolor string\n}\n\nclass FormatterTest2 {\n // \"lorem\" is a latin word\n lorem string\n // \"ipsum\" is a latin word\n ipsum string\n}\n\nclass FormatterTest3 {\n lorem string\n ipsum string\n // Lorem ipsum dolor sit amet\n // Consectetur adipiscing elit\n // Sed do eiusmod tempor incididunt\n // Ut labore et dolore magna aliqua\n // Ut enim ad minim veniam\n}", - "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.73.5\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.73.5\"\n}\n", + "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.74.0\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.74.0\"\n}\n\ngenerator openapi {\n output_type rest/openapi\n output_dir \"../openapi\"\n version \"0.74.0\"\n on_generate \"rm .gitignore\"\n}", "test-files/aliases/aliased-inputs.baml": "\nclass InputClass {\n key string @alias(\"color\")\n key2 string\n}\n\n\nclass InputClassNested {\n key string\n nested InputClass @alias(\"interesting-key\")\n}\n \n\nfunction AliasedInputClass(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {{input}}\n\n This is a test. What's the name of the first json key above? Remember, tell me the key, not value.\n \"#\n}\n \nfunction AliasedInputClass2(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {# making sure we can still access the original key #}\n {%if input.key == \"tiger\"%}\n Repeat this value back to me, and nothing else: {{input.key}}\n {%endif%}\n \"#\n}\n \n function AliasedInputClassNested(input: InputClassNested) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n\n {{input}}\n\n This is a test. What's the name of the second json key above? Remember, tell me the key, not value.\n \"#\n }\n\n\nenum AliasedEnum {\n KEY_ONE @alias(\"tiger\")\n KEY_TWO\n}\n\nfunction AliasedInputEnum(input: AliasedEnum) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\")}}\n\n\n Write out this word only in your response, in lowercase:\n ---\n {{input}}\n ---\n Answer:\n \"#\n}\n\n\nfunction AliasedInputList(input: AliasedEnum[]) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n Given this array:\n ---\n {{input}}\n ---\n\n Return the first element in the array:\n \"#\n}\n\n", "test-files/aliases/classes.baml": "class TestClassAlias {\n key string @alias(\"key-dash\") @description(#\"\n This is a description for key\n af asdf\n \"#)\n key2 string @alias(\"key21\")\n key3 string @alias(\"key with space\")\n key4 string //unaliased\n key5 string @alias(\"key.with.punctuation/123\")\n}\n\nfunction FnTestClassAlias(input: string) -> TestClassAlias {\n client GPT35\n prompt #\"\n {{ctx.output_format}}\n \"#\n}\n\ntest FnTestClassAlias {\n functions [FnTestClassAlias]\n args {\n input \"example input\"\n }\n}\n", "test-files/aliases/enums.baml": "enum TestEnum {\n A @alias(\"k1\") @description(#\"\n User is angry\n \"#)\n B @alias(\"k22\") @description(#\"\n User is happy\n \"#)\n // tests whether k1 doesnt incorrectly get matched with k11\n C @alias(\"k11\") @description(#\"\n User is sad\n \"#)\n D @alias(\"k44\") @description(\n User is confused\n )\n E @description(\n User is excited\n )\n F @alias(\"k5\") // only alias\n \n G @alias(\"k6\") @description(#\"\n User is bored\n With a long description\n \"#)\n \n @@alias(\"Category\")\n}\n\nfunction FnTestAliasedEnumOutput(input: string) -> TestEnum {\n client GPT35\n prompt #\"\n Classify the user input into the following category\n \n {{ ctx.output_format }}\n\n {{ _.role('user') }}\n {{input}}\n\n {{ _.role('assistant') }}\n Category ID:\n \"#\n}\n\ntest FnTestAliasedEnumOutput {\n functions [FnTestAliasedEnumOutput]\n args {\n input \"mehhhhh\"\n }\n}", @@ -91,6 +91,7 @@ "test-files/functions/prompts/no-chat-messages.baml": "\n\nfunction PromptTestClaude(input: string) -> string {\n client Sonnet\n prompt #\"\n Tell me a haiku about {{ input }}\n \"#\n}\n\n\nfunction PromptTestStreaming(input: string) -> string {\n client GPT35\n prompt #\"\n Tell me a short story about {{ input }}\n \"#\n}\n\ntest TestName {\n functions [PromptTestStreaming]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/functions/prompts/with-chat-messages.baml": "\nfunction PromptTestOpenAIChat(input: string) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestOpenAIChatNoSystem(input: string) -> string {\n client GPT35\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChat(input: string) -> string {\n client Claude\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChatNoSystem(input: string) -> string {\n client Claude\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\ntest TestSystemAndNonSystemChat1 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"cats\"\n }\n}\n\ntest TestSystemAndNonSystemChat2 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"lion\"\n }\n}", "test-files/functions/v2/basic.baml": "\n\nfunction ExtractResume2(resume: string) -> Resume {\n client GPT4\n prompt #\"\n {{ _.role('system') }}\n\n Extract the following information from the resume:\n\n Resume:\n <<<<\n {{ resume }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}\n\n\nclass WithReasoning {\n value string\n reasoning string @description(#\"\n Why the value is a good fit.\n \"#)\n}\n\n\nclass SearchParams {\n dateRange int? @description(#\"\n In ISO duration format, e.g. P1Y2M10D.\n \"#)\n location string[]\n jobTitle WithReasoning? @description(#\"\n An exact job title, not a general category.\n \"#)\n company WithReasoning? @description(#\"\n The exact name of the company, not a product or service.\n \"#)\n description WithReasoning[] @description(#\"\n Any specific projects or features the user is looking for.\n \"#)\n tags (Tag | string)[]\n}\n\nenum Tag {\n Security\n AI\n Blockchain\n}\n\nfunction GetQuery(query: string) -> SearchParams {\n client GPT4\n prompt #\"\n Extract the following information from the query:\n\n Query:\n <<<<\n {{ query }}\n <<<<\n\n OUTPUT_JSON_SCHEMA:\n {{ ctx.output_format }}\n\n Before OUTPUT_JSON_SCHEMA, list 5 intentions the user may have.\n --- EXAMPLES ---\n 1. \n 2. \n 3. \n 4. \n 5. \n\n {\n ... // OUTPUT_JSON_SCHEMA\n }\n \"#\n}\n\nclass RaysData {\n dataType DataType\n value Resume | Event\n}\n\nenum DataType {\n Resume\n Event\n}\n\nclass Event {\n title string\n date string\n location string\n description string\n}\n\nfunction GetDataType(text: string) -> RaysData {\n client GPT4\n prompt #\"\n Extract the relevant info.\n\n Text:\n <<<<\n {{ text }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}", + "test-files/load-test/memory.baml": "\n\nclass MemoryObject {\n id string\n name string\n description string\n}\n\nclass ComplexMemoryObject {\n id string\n name string\n description string\n metadata (string | int | float)[] @description(#\"\n Additional metadata about the memory object, which can be a mix of types.\n \"#)\n}\n\nclass AnotherObject {\n id string\n thingy2 string\n thingy3 string\n}\n\nclass TestMemoryOutput {\n items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 10 items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n more_items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 3 more items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n}\n\n\nfunction TestMemory(input: string) -> TestMemoryOutput {\n client GPT35\n prompt #\"\n Return a json blob that matches the schema:\n {{ ctx.output_format }}\n \"#\n}\n\ntest TestName {\n functions [TestMemory]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/providers/anthropic.baml": "function TestAnthropic(input: string) -> string {\n client Claude\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestAnthropicShorthand(input: string) -> string {\n client \"anthropic/claude-3-haiku-20240307\"\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestCaching(input: string, not_cached: string) -> string {\n client ClaudeWithCaching\n prompt #\"\n {{ _.role('system', cache_control={\"type\": \"ephemeral\"}) }}\n Generate the following story\n {{ input }}\n\n {# Haiku require 2048 tokens to cache -#}\n {{ input }}\n\n {{ _.role('user') }}\n {{ not_cached }}\n \"#\n}", "test-files/providers/aws.baml": "function TestAws(input: string) -> string {\n client AwsBedrock\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nclass UniverseQuestion {\n question string\n answer string\n}\n\nclass UniverseQuestionInput {\n question string\n}\n\nfunction TestUniverseQuestion(question: UniverseQuestionInput) -> UniverseQuestion {\n client AwsBedrock\n prompt #\"\n You are a helpful assistant that answers questions about the universe.\n\n {{ ctx.output_format }}\n\n {{ _.role(\"user\")}}\n\n Question: {{ question }}\n\n Answer:\n \"#\n}\n\n\nfunction TestAwsInvalidRegion(input: string) -> string {\n client AwsBedrockInvalidRegion\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidAccessKey(input: string) -> string {\n client AwsBedrockInvalidAccessKey\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidProfile(input: string) -> string {\n client AwsBedrockInvalidProfile\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidSessionToken(input: string) -> string {\n client AwsBedrockInvalidSessionToken\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}", "test-files/providers/azure.baml": "function TestAzure(input: string) -> string {\n client GPT35Azure\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nclient GPT35AzureFailed {\n provider azure-openai\n options {\n resource_name \"west-us-azure-baml-incorrect-suffix\"\n deployment_id \"gpt-35-turbo-default\"\n api_key env.AZURE_OPENAI_API_KEY\n }\n}\n\nfunction TestAzureFailure(input: string) -> string {\n client GPT35AzureFailed\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}", diff --git a/integ-tests/python/baml_client/partial_types.py b/integ-tests/python/baml_client/partial_types.py new file mode 100644 index 000000000..ddd8235ff --- /dev/null +++ b/integ-tests/python/baml_client/partial_types.py @@ -0,0 +1,432 @@ +############################################################################### +# +# Welcome to Baml! To use this generated code, please run the following: +# +# $ pip install baml +# +############################################################################### + +# This file was generated by BAML: please do not edit it. Instead, edit the +# BAML files and re-generate this code. +# +# ruff: noqa: E501,F401 +# flake8: noqa: E501,F401 +# pylint: disable=unused-import,line-too-long +# fmt: off +import baml_py +from enum import Enum +from pydantic import BaseModel, ConfigDict +from typing import Dict, Generic, List, Optional, TypeVar, Union, Literal + +from . import types +from .types import Checked, Check + +############################################################################### +# +# These types are used for streaming, for when an instance of a type +# is still being built up and any of its fields is not yet fully available. +# +############################################################################### + +T = TypeVar('T') +class StreamState(BaseModel, Generic[T]): + value: T + state: Literal["Pending", "Incomplete", "Complete"] + + +class AnotherObject(BaseModel): + id: Optional[str] = None + thingy2: Optional[str] = None + thingy3: Optional[str] = None + +class BigNumbers(BaseModel): + a: Optional[int] = None + b: Optional[float] = None + +class BinaryNode(BaseModel): + data: Optional[int] = None + left: Optional["BinaryNode"] = None + right: Optional["BinaryNode"] = None + +class Blah(BaseModel): + prop4: Optional[str] = None + +class BlockConstraint(BaseModel): + foo: Optional[int] = None + bar: Optional[str] = None + +class BlockConstraintForParam(BaseModel): + bcfp: Optional[int] = None + bcfp2: Optional[str] = None + +class BookOrder(BaseModel): + orderId: Optional[str] = None + title: Optional[str] = None + quantity: Optional[int] = None + price: Optional[float] = None + +class ClassForNullLiteral(BaseModel): + a: Optional[Literal["hi"]] = None + +class ClassOptionalOutput(BaseModel): + prop1: Optional[str] = None + prop2: Optional[str] = None + +class ClassOptionalOutput2(BaseModel): + prop1: Optional[str] = None + prop2: Optional[str] = None + prop3: Optional["Blah"] = None + +class ClassToRecAlias(BaseModel): + list: Optional["LinkedListAliasNode"] = None + +class ClassWithBlockDone(BaseModel): + i_16_digits: Optional[int] = None + s_20_words: Optional[str] = None + +class ClassWithImage(BaseModel): + myImage: Optional[baml_py.Image] = None + param2: Optional[str] = None + fake_image: Optional["FakeImage"] = None + +class ClassWithoutDone(BaseModel): + i_16_digits: Optional[int] = None + s_20_words: StreamState[Optional[str]] + +class ComplexMemoryObject(BaseModel): + id: Optional[str] = None + name: Optional[str] = None + description: Optional[str] = None + metadata: List[Optional[Union[Optional[str], Optional[int], Optional[float]]]] + +class CompoundBigNumbers(BaseModel): + big: Optional["BigNumbers"] = None + big_nums: List["BigNumbers"] + another: Optional["BigNumbers"] = None + +class ContactInfo(BaseModel): + primary: Optional[Union["PhoneNumber", "EmailAddress"]] = None + secondary: Optional[Union["PhoneNumber", "EmailAddress", Optional[None]]] = None + +class CustomTaskResult(BaseModel): + bookOrder: Optional[Union["BookOrder", Optional[None]]] = None + flightConfirmation: Optional[Union["FlightConfirmation", Optional[None]]] = None + groceryReceipt: Optional[Union["GroceryReceipt", Optional[None]]] = None + +class DummyOutput(BaseModel): + model_config = ConfigDict(extra='allow') + nonce: Optional[str] = None + nonce2: Optional[str] = None + +class DynInputOutput(BaseModel): + model_config = ConfigDict(extra='allow') + testKey: Optional[str] = None + +class DynamicClassOne(BaseModel): + model_config = ConfigDict(extra='allow') + +class DynamicClassTwo(BaseModel): + model_config = ConfigDict(extra='allow') + hi: Optional[str] = None + some_class: Optional["SomeClassNestedDynamic"] = None + status: Optional[Union[types.DynEnumOne, str]] = None + +class DynamicOutput(BaseModel): + model_config = ConfigDict(extra='allow') + +class Earthling(BaseModel): + age: Checked[Optional[int],Literal["earth_aged", "no_infants"]] + +class Education(BaseModel): + institution: Optional[str] = None + location: Optional[str] = None + degree: Optional[str] = None + major: List[Optional[str]] + graduation_date: Optional[str] = None + +class Email(BaseModel): + subject: Optional[str] = None + body: Optional[str] = None + from_address: Optional[str] = None + +class EmailAddress(BaseModel): + value: Optional[str] = None + +class Event(BaseModel): + title: Optional[str] = None + date: Optional[str] = None + location: Optional[str] = None + description: Optional[str] = None + +class FakeImage(BaseModel): + url: Optional[str] = None + +class FlightConfirmation(BaseModel): + confirmationNumber: Optional[str] = None + flightNumber: Optional[str] = None + departureTime: Optional[str] = None + arrivalTime: Optional[str] = None + seatNumber: Optional[str] = None + +class FooAny(BaseModel): + planetary_age: Optional[Union["Martian", "Earthling"]] = None + certainty: Checked[Optional[int],Literal["unreasonably_certain"]] + species: Checked[Optional[str],Literal["regex_bad", "regex_good", "trivial"]] + +class Forest(BaseModel): + trees: List["Tree"] + +class FormatterTest0(BaseModel): + lorem: Optional[str] = None + ipsum: Optional[str] = None + +class FormatterTest1(BaseModel): + lorem: Optional[str] = None + ipsum: Optional[str] = None + +class FormatterTest2(BaseModel): + lorem: Optional[str] = None + ipsum: Optional[str] = None + +class FormatterTest3(BaseModel): + lorem: Optional[str] = None + ipsum: Optional[str] = None + +class GroceryReceipt(BaseModel): + receiptId: Optional[str] = None + storeName: Optional[str] = None + items: List[Optional[Union[Optional[str], Optional[int], Optional[float]]]] + totalAmount: Optional[float] = None + +class InnerClass(BaseModel): + prop1: Optional[str] = None + prop2: Optional[str] = None + inner: Optional["InnerClass2"] = None + +class InnerClass2(BaseModel): + prop2: Optional[int] = None + prop3: Optional[float] = None + +class InputClass(BaseModel): + key: Optional[str] = None + key2: Optional[str] = None + +class InputClassNested(BaseModel): + key: Optional[str] = None + nested: Optional["InputClass"] = None + +class LinkedList(BaseModel): + head: Optional["Node"] = None + len: Optional[int] = None + +class LinkedListAliasNode(BaseModel): + value: Optional[int] = None + next: Optional["LinkedListAliasNode"] = None + +class LiteralClassHello(BaseModel): + prop: Optional[Literal["hello"]] = None + +class LiteralClassOne(BaseModel): + prop: Optional[Literal["one"]] = None + +class LiteralClassTwo(BaseModel): + prop: Optional[Literal["two"]] = None + +class MalformedConstraints(BaseModel): + foo: Checked[Optional[int],Literal["foo_check"]] + +class MalformedConstraints2(BaseModel): + foo: Optional[int] = None + +class Martian(BaseModel): + """A Martian organism with an age. + Such a nice type.""" + age: Checked[Optional[int],Literal["young_enough"]] + """The age of the Martian in Mars years. + So many Mars years.""" + +class MemoryObject(BaseModel): + id: Optional[str] = None + name: Optional[str] = None + description: Optional[str] = None + +class MergeAttrs(BaseModel): + amount: Checked[Optional[int],Literal["gt_ten"]] + +class NamedArgsSingleClass(BaseModel): + key: Optional[str] = None + key_two: Optional[bool] = None + key_three: Optional[int] = None + +class Nested(BaseModel): + prop3: Optional[Union[Optional[str], Optional[None]]] = None + prop4: Optional[Union[Optional[str], Optional[None]]] = None + prop20: Optional["Nested2"] = None + +class Nested2(BaseModel): + prop11: Optional[Union[Optional[str], Optional[None]]] = None + prop12: Optional[Union[Optional[str], Optional[None]]] = None + +class NestedBlockConstraint(BaseModel): + nbc: Checked[Optional["BlockConstraint"],Literal["cross_field"]] + +class NestedBlockConstraintForParam(BaseModel): + nbcfp: Optional["BlockConstraintForParam"] = None + +class Node(BaseModel): + data: Optional[int] = None + next: Optional["Node"] = None + +class NodeWithAliasIndirection(BaseModel): + value: Optional[int] = None + next: Optional["NodeWithAliasIndirection"] = None + +class OptionalListAndMap(BaseModel): + p: List[Optional[str]] + q: Dict[str, Optional[str]] + +class OptionalTest_Prop1(BaseModel): + omega_a: Optional[str] = None + omega_b: Optional[int] = None + +class OptionalTest_ReturnType(BaseModel): + omega_1: Optional["OptionalTest_Prop1"] = None + omega_2: Optional[str] = None + omega_3: List[Optional[types.OptionalTest_CategoryType]] + +class OrderInfo(BaseModel): + order_status: Optional[types.OrderStatus] = None + tracking_number: Optional[str] = None + estimated_arrival_date: Optional[str] = None + +class OriginalA(BaseModel): + value: Optional[int] = None + +class OriginalB(BaseModel): + model_config = ConfigDict(extra='allow') + value: Optional[int] = None + +class Person(BaseModel): + model_config = ConfigDict(extra='allow') + name: Optional[str] = None + hair_color: Optional[Union[types.Color, str]] = None + +class PhoneNumber(BaseModel): + value: Optional[str] = None + +class Quantity(BaseModel): + amount: Optional[Union[Optional[int], Optional[float]]] = None + unit: Optional[str] = None + +class RaysData(BaseModel): + dataType: Optional[types.DataType] = None + value: Optional[Union["Resume", "Event"]] = None + +class ReceiptInfo(BaseModel): + items: List["ReceiptItem"] + total_cost: Optional[float] = None + venue: Optional[Union[Optional[Literal["barisa"]], Optional[Literal["ox_burger"]]]] = None + +class ReceiptItem(BaseModel): + name: Optional[str] = None + description: Optional[str] = None + quantity: Optional[int] = None + price: Optional[float] = None + +class Recipe(BaseModel): + ingredients: Dict[str, Optional["Quantity"]] + recipe_type: Optional[Union[Optional[Literal["breakfast"]], Optional[Literal["dinner"]]]] = None + +class Resume(BaseModel): + name: Optional[str] = None + email: Optional[str] = None + phone: Optional[str] = None + experience: List["Education"] + education: List[Optional[str]] + skills: List[Optional[str]] + +class Schema(BaseModel): + prop1: Optional[Union[Optional[str], Optional[None]]] = None + prop2: Optional[Union["Nested", Optional[str]]] = None + prop5: List[Optional[Union[Optional[str], Optional[None]]]] + prop6: Optional[Union[Optional[str], List["Nested"]]] = None + nested_attrs: List[Optional[Union[Optional[str], Optional[None], "Nested"]]] + parens: Optional[Union[Optional[str], Optional[None]]] = None + other_group: Optional[Union[Optional[str], Optional[Union[Optional[int], Optional[str]]]]] = None + +class SearchParams(BaseModel): + dateRange: Optional[int] = None + location: List[Optional[str]] + jobTitle: Optional["WithReasoning"] = None + company: Optional["WithReasoning"] = None + description: List["WithReasoning"] + tags: List[Optional[Union[Optional[types.Tag], Optional[str]]]] + +class SemanticContainer(BaseModel): + sixteen_digit_number: Optional[int] = None + string_with_twenty_words: Optional[str] = None + class_1: Optional["ClassWithoutDone"] = None + class_2: Optional["types.ClassWithBlockDone"] = None + class_done_needed: "types.ClassWithBlockDone" + class_needed: "ClassWithoutDone" + three_small_things: List["SmallThing"] + final_string: Optional[str] = None + +class SmallThing(BaseModel): + i_16_digits: int + i_8_digits: Optional[int] = None + +class SomeClassNestedDynamic(BaseModel): + model_config = ConfigDict(extra='allow') + hi: Optional[str] = None + +class StringToClassEntry(BaseModel): + word: Optional[str] = None + +class TestClassAlias(BaseModel): + key: Optional[str] = None + key2: Optional[str] = None + key3: Optional[str] = None + key4: Optional[str] = None + key5: Optional[str] = None + +class TestClassNested(BaseModel): + prop1: Optional[str] = None + prop2: Optional["InnerClass"] = None + +class TestClassWithEnum(BaseModel): + prop1: Optional[str] = None + prop2: Optional[types.EnumInClass] = None + +class TestMemoryOutput(BaseModel): + items: List[Optional[Union["MemoryObject", "ComplexMemoryObject", "AnotherObject"]]] + more_items: List[Optional[Union["MemoryObject", "ComplexMemoryObject", "AnotherObject"]]] + +class TestOutputClass(BaseModel): + prop1: Optional[str] = None + prop2: Optional[int] = None + +class Tree(BaseModel): + data: Optional[int] = None + children: Optional["Forest"] = None + +class TwoStoriesOneTitle(BaseModel): + title: Optional[str] = None + story_a: Optional[str] = None + story_b: Optional[str] = None + +class UnionTest_ReturnType(BaseModel): + prop1: Optional[Union[Optional[str], Optional[bool]]] = None + prop2: List[Optional[Union[Optional[float], Optional[bool]]]] + prop3: Optional[Union[List[Optional[bool]], List[Optional[int]]]] = None + +class UniverseQuestion(BaseModel): + question: Optional[str] = None + answer: Optional[str] = None + +class UniverseQuestionInput(BaseModel): + question: Optional[str] = None + +class WithReasoning(BaseModel): + value: Optional[str] = None + reasoning: Optional[str] = None diff --git a/integ-tests/python/baml_client/sync_client.py b/integ-tests/python/baml_client/sync_client.py index f496927e2..3639a662f 100644 --- a/integ-tests/python/baml_client/sync_client.py +++ b/integ-tests/python/baml_client/sync_client.py @@ -2968,6 +2968,29 @@ def TestImageListInput( ) return cast(str, raw.cast_to(types, types, partial_types, False)) + def TestMemory( + self, + input: str, + baml_options: BamlCallOptions = {}, + ) -> types.TestMemoryOutput: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = self.__runtime.call_function_sync( + "TestMemory", + { + "input": input, + }, + self.__ctx_manager.get(), + tb, + __cr__, + ) + return cast(types.TestMemoryOutput, raw.cast_to(types, types, partial_types, False)) + def TestMulticlassNamedArgs( self, myArg: types.NamedArgsSingleClass,myArg2: types.NamedArgsSingleClass, @@ -7186,6 +7209,36 @@ def TestImageListInput( self.__ctx_manager.get(), ) + def TestMemory( + self, + input: str, + baml_options: BamlCallOptions = {}, + ) -> baml_py.BamlSyncStream[partial_types.TestMemoryOutput, types.TestMemoryOutput]: + __tb__ = baml_options.get("tb", None) + if __tb__ is not None: + tb = __tb__._tb # type: ignore (we know how to use this private attribute) + else: + tb = None + __cr__ = baml_options.get("client_registry", None) + + raw = self.__runtime.stream_function_sync( + "TestMemory", + { + "input": input, + }, + None, + self.__ctx_manager.get(), + tb, + __cr__, + ) + + return baml_py.BamlSyncStream[partial_types.TestMemoryOutput, types.TestMemoryOutput]( + raw, + lambda x: cast(partial_types.TestMemoryOutput, x.cast_to(types, types, partial_types, True)), + lambda x: cast(types.TestMemoryOutput, x.cast_to(types, types, partial_types, False)), + self.__ctx_manager.get(), + ) + def TestMulticlassNamedArgs( self, myArg: types.NamedArgsSingleClass,myArg2: types.NamedArgsSingleClass, diff --git a/integ-tests/python/baml_client/tracing.py b/integ-tests/python/baml_client/tracing.py new file mode 100644 index 000000000..7c2bff4d4 --- /dev/null +++ b/integ-tests/python/baml_client/tracing.py @@ -0,0 +1,25 @@ +############################################################################### +# +# Welcome to Baml! To use this generated code, please run the following: +# +# $ pip install baml +# +############################################################################### + +# This file was generated by BAML: please do not edit it. Instead, edit the +# BAML files and re-generate this code. +# +# ruff: noqa: E501,F401 +# flake8: noqa: E501,F401 +# pylint: disable=unused-import,line-too-long +# fmt: off +from .globals import DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX + +trace = DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.trace_fn +set_tags = DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.upsert_tags +def flush(): + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.flush() +on_log_event = DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.on_log_event + + +__all__ = ['trace', 'set_tags', "flush", "on_log_event"] \ No newline at end of file diff --git a/integ-tests/python/baml_client/type_builder.py b/integ-tests/python/baml_client/type_builder.py index 299466f33..cf155e7be 100644 --- a/integ-tests/python/baml_client/type_builder.py +++ b/integ-tests/python/baml_client/type_builder.py @@ -20,7 +20,7 @@ class TypeBuilder(_TypeBuilder): def __init__(self): super().__init__(classes=set( - ["BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithBlockDone","ClassWithImage","ClassWithoutDone","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SemanticContainer","SmallThing","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning",] + ["AnotherObject","BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithBlockDone","ClassWithImage","ClassWithoutDone","ComplexMemoryObject","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MemoryObject","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SemanticContainer","SmallThing","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestMemoryOutput","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","WithReasoning",] ), enums=set( ["AliasedEnum","Category","Category2","Category3","Color","DataType","DynEnumOne","DynEnumTwo","EnumInClass","EnumOutput","Hobby","MapKey","NamedArgsSingleEnum","NamedArgsSingleEnumList","OptionalTest_CategoryType","OrderStatus","Tag","TestEnum",] )) diff --git a/integ-tests/python/baml_client/types.py b/integ-tests/python/baml_client/types.py new file mode 100644 index 000000000..7d2b50c6d --- /dev/null +++ b/integ-tests/python/baml_client/types.py @@ -0,0 +1,568 @@ +############################################################################### +# +# Welcome to Baml! To use this generated code, please run the following: +# +# $ pip install baml +# +############################################################################### + +# This file was generated by BAML: please do not edit it. Instead, edit the +# BAML files and re-generate this code. +# +# ruff: noqa: E501,F401 +# flake8: noqa: E501,F401 +# pylint: disable=unused-import,line-too-long +# fmt: off +import baml_py +from enum import Enum +from pydantic import BaseModel, ConfigDict +from typing import Dict, Generic, List, Literal, Optional, TypeVar, Union, TypeAlias + + +T = TypeVar('T') +CheckName = TypeVar('CheckName', bound=str) + +class Check(BaseModel): + name: str + expression: str + status: str + +class Checked(BaseModel, Generic[T,CheckName]): + value: T + checks: Dict[CheckName, Check] + +def get_checks(checks: Dict[CheckName, Check]) -> List[Check]: + return list(checks.values()) + +def all_succeeded(checks: Dict[CheckName, Check]) -> bool: + return all(check.status == "succeeded" for check in get_checks(checks)) + + + +class AliasedEnum(str, Enum): + + KEY_ONE = "KEY_ONE" + KEY_TWO = "KEY_TWO" + +class Category(str, Enum): + + Refund = "Refund" + CancelOrder = "CancelOrder" + TechnicalSupport = "TechnicalSupport" + AccountIssue = "AccountIssue" + Question = "Question" + +class Category2(str, Enum): + + Refund = "Refund" + CancelOrder = "CancelOrder" + TechnicalSupport = "TechnicalSupport" + AccountIssue = "AccountIssue" + Question = "Question" + +class Category3(str, Enum): + + Refund = "Refund" + CancelOrder = "CancelOrder" + TechnicalSupport = "TechnicalSupport" + AccountIssue = "AccountIssue" + Question = "Question" + +class Color(str, Enum): + + RED = "RED" + BLUE = "BLUE" + GREEN = "GREEN" + YELLOW = "YELLOW" + BLACK = "BLACK" + WHITE = "WHITE" + +class DataType(str, Enum): + + Resume = "Resume" + Event = "Event" + +class DynEnumOne(str, Enum): + pass + +class DynEnumTwo(str, Enum): + pass + +class EnumInClass(str, Enum): + + ONE = "ONE" + TWO = "TWO" + +class EnumOutput(str, Enum): + """An enum with three values, + ONE, TWO and THREE.""" + + ONE = "ONE" + """The first enum.""" + TWO = "TWO" + """The second enum.""" + THREE = "THREE" + +class Hobby(str, Enum): + + SPORTS = "SPORTS" + MUSIC = "MUSIC" + READING = "READING" + +class MapKey(str, Enum): + + A = "A" + B = "B" + C = "C" + +class NamedArgsSingleEnum(str, Enum): + + ONE = "ONE" + TWO = "TWO" + +class NamedArgsSingleEnumList(str, Enum): + + ONE = "ONE" + TWO = "TWO" + +class OptionalTest_CategoryType(str, Enum): + + Aleph = "Aleph" + Beta = "Beta" + Gamma = "Gamma" + +class OrderStatus(str, Enum): + + ORDERED = "ORDERED" + SHIPPED = "SHIPPED" + DELIVERED = "DELIVERED" + CANCELLED = "CANCELLED" + +class Tag(str, Enum): + + Security = "Security" + AI = "AI" + Blockchain = "Blockchain" + +class TestEnum(str, Enum): + + A = "A" + B = "B" + C = "C" + D = "D" + E = "E" + F = "F" + G = "G" + +class AnotherObject(BaseModel): + id: str + thingy2: str + thingy3: str + +class BigNumbers(BaseModel): + a: int + b: float + +class BinaryNode(BaseModel): + data: int + left: Optional["BinaryNode"] = None + right: Optional["BinaryNode"] = None + +class Blah(BaseModel): + prop4: Optional[str] = None + +class BlockConstraint(BaseModel): + foo: int + bar: str + +class BlockConstraintForParam(BaseModel): + bcfp: int + bcfp2: str + +class BookOrder(BaseModel): + orderId: str + title: str + quantity: int + price: float + +class ClassForNullLiteral(BaseModel): + a: Literal["hi"] + +class ClassOptionalOutput(BaseModel): + prop1: str + prop2: str + +class ClassOptionalOutput2(BaseModel): + prop1: Optional[str] = None + prop2: Optional[str] = None + prop3: Optional["Blah"] = None + +class ClassToRecAlias(BaseModel): + list: "LinkedListAliasNode" + +class ClassWithBlockDone(BaseModel): + i_16_digits: int + s_20_words: str + +class ClassWithImage(BaseModel): + myImage: baml_py.Image + param2: str + fake_image: "FakeImage" + +class ClassWithoutDone(BaseModel): + i_16_digits: int + s_20_words: str + +class ComplexMemoryObject(BaseModel): + id: str + name: str + description: str + metadata: List[Union[str, int, float]] + +class CompoundBigNumbers(BaseModel): + big: "BigNumbers" + big_nums: List["BigNumbers"] + another: "BigNumbers" + +class ContactInfo(BaseModel): + primary: Union["PhoneNumber", "EmailAddress"] + secondary: Union["PhoneNumber", "EmailAddress", None] + +class CustomTaskResult(BaseModel): + bookOrder: Union["BookOrder", Optional[None]] + flightConfirmation: Union["FlightConfirmation", Optional[None]] + groceryReceipt: Union["GroceryReceipt", Optional[None]] + +class DummyOutput(BaseModel): + model_config = ConfigDict(extra='allow') + nonce: str + nonce2: str + +class DynInputOutput(BaseModel): + model_config = ConfigDict(extra='allow') + testKey: str + +class DynamicClassOne(BaseModel): + model_config = ConfigDict(extra='allow') + +class DynamicClassTwo(BaseModel): + model_config = ConfigDict(extra='allow') + hi: str + some_class: "SomeClassNestedDynamic" + status: Union["DynEnumOne", str] + +class DynamicOutput(BaseModel): + model_config = ConfigDict(extra='allow') + +class Earthling(BaseModel): + age: Checked[int,Literal["earth_aged", "no_infants"]] + +class Education(BaseModel): + institution: str + location: str + degree: str + major: List[str] + graduation_date: Optional[str] = None + +class Email(BaseModel): + subject: str + body: str + from_address: str + +class EmailAddress(BaseModel): + value: str + +class Event(BaseModel): + title: str + date: str + location: str + description: str + +class FakeImage(BaseModel): + url: str + +class FlightConfirmation(BaseModel): + confirmationNumber: str + flightNumber: str + departureTime: str + arrivalTime: str + seatNumber: str + +class FooAny(BaseModel): + planetary_age: Union["Martian", "Earthling"] + certainty: Checked[int,Literal["unreasonably_certain"]] + species: Checked[str,Literal["regex_bad", "regex_good", "trivial"]] + +class Forest(BaseModel): + trees: List["Tree"] + +class FormatterTest0(BaseModel): + lorem: str + ipsum: str + +class FormatterTest1(BaseModel): + lorem: str + ipsum: str + +class FormatterTest2(BaseModel): + lorem: str + ipsum: str + +class FormatterTest3(BaseModel): + lorem: str + ipsum: str + +class GroceryReceipt(BaseModel): + receiptId: str + storeName: str + items: List[Union[str, int, float]] + totalAmount: float + +class InnerClass(BaseModel): + prop1: str + prop2: str + inner: "InnerClass2" + +class InnerClass2(BaseModel): + prop2: int + prop3: float + +class InputClass(BaseModel): + key: str + key2: str + +class InputClassNested(BaseModel): + key: str + nested: "InputClass" + +class LinkedList(BaseModel): + head: Optional["Node"] = None + len: int + +class LinkedListAliasNode(BaseModel): + value: int + next: Optional["LinkedListAliasNode"] = None + +class LiteralClassHello(BaseModel): + prop: Literal["hello"] + +class LiteralClassOne(BaseModel): + prop: Literal["one"] + +class LiteralClassTwo(BaseModel): + prop: Literal["two"] + +class MalformedConstraints(BaseModel): + foo: Checked[int,Literal["foo_check"]] + +class MalformedConstraints2(BaseModel): + foo: int + +class Martian(BaseModel): + """A Martian organism with an age. + Such a nice type.""" + age: Checked[int,Literal["young_enough"]] + """The age of the Martian in Mars years. + So many Mars years.""" + +class MemoryObject(BaseModel): + id: str + name: str + description: str + +class MergeAttrs(BaseModel): + amount: Checked[int,Literal["gt_ten"]] + +class NamedArgsSingleClass(BaseModel): + key: str + key_two: bool + key_three: int + +class Nested(BaseModel): + prop3: Union[str, Optional[None]] + prop4: Union[str, Optional[None]] + prop20: "Nested2" + +class Nested2(BaseModel): + prop11: Union[str, Optional[None]] + prop12: Union[str, Optional[None]] + +class NestedBlockConstraint(BaseModel): + nbc: Checked["BlockConstraint",Literal["cross_field"]] + +class NestedBlockConstraintForParam(BaseModel): + nbcfp: "BlockConstraintForParam" + +class Node(BaseModel): + data: int + next: Optional["Node"] = None + +class NodeWithAliasIndirection(BaseModel): + value: int + next: Optional["NodeWithAliasIndirection"] = None + +class OptionalListAndMap(BaseModel): + p: Optional[List[str]] = None + q: Optional[Dict[str, str]] = None + +class OptionalTest_Prop1(BaseModel): + omega_a: str + omega_b: int + +class OptionalTest_ReturnType(BaseModel): + omega_1: Optional["OptionalTest_Prop1"] = None + omega_2: Optional[str] = None + omega_3: List[Optional["OptionalTest_CategoryType"]] + +class OrderInfo(BaseModel): + order_status: "OrderStatus" + tracking_number: Optional[str] = None + estimated_arrival_date: Optional[str] = None + +class OriginalA(BaseModel): + value: int + +class OriginalB(BaseModel): + model_config = ConfigDict(extra='allow') + value: int + +class Person(BaseModel): + model_config = ConfigDict(extra='allow') + name: Optional[str] = None + hair_color: Optional[Union["Color", str]] = None + +class PhoneNumber(BaseModel): + value: str + +class Quantity(BaseModel): + amount: Union[int, float] + unit: Optional[str] = None + +class RaysData(BaseModel): + dataType: "DataType" + value: Union["Resume", "Event"] + +class ReceiptInfo(BaseModel): + items: List["ReceiptItem"] + total_cost: Optional[float] = None + venue: Union[Literal["barisa"], Literal["ox_burger"]] + +class ReceiptItem(BaseModel): + name: str + description: Optional[str] = None + quantity: int + price: float + +class Recipe(BaseModel): + ingredients: Dict[str, "Quantity"] + recipe_type: Union[Literal["breakfast"], Literal["dinner"]] + +class Resume(BaseModel): + name: str + email: str + phone: str + experience: List["Education"] + education: List[str] + skills: List[str] + +class Schema(BaseModel): + prop1: Union[str, Optional[None]] + prop2: Union["Nested", str] + prop5: List[Union[str, Optional[None]]] + prop6: Union[str, List["Nested"]] + nested_attrs: List[Union[str, Optional[None], "Nested"]] + parens: Union[str, Optional[None]] + other_group: Union[str, Union[int, str]] + +class SearchParams(BaseModel): + dateRange: Optional[int] = None + location: List[str] + jobTitle: Optional["WithReasoning"] = None + company: Optional["WithReasoning"] = None + description: List["WithReasoning"] + tags: List[Union["Tag", str]] + +class SemanticContainer(BaseModel): + sixteen_digit_number: int + string_with_twenty_words: str + class_1: "ClassWithoutDone" + class_2: "ClassWithBlockDone" + class_done_needed: "ClassWithBlockDone" + class_needed: "ClassWithoutDone" + three_small_things: List["SmallThing"] + final_string: str + +class SmallThing(BaseModel): + i_16_digits: int + i_8_digits: int + +class SomeClassNestedDynamic(BaseModel): + model_config = ConfigDict(extra='allow') + hi: str + +class StringToClassEntry(BaseModel): + word: str + +class TestClassAlias(BaseModel): + key: str + key2: str + key3: str + key4: str + key5: str + +class TestClassNested(BaseModel): + prop1: str + prop2: "InnerClass" + +class TestClassWithEnum(BaseModel): + prop1: str + prop2: "EnumInClass" + +class TestMemoryOutput(BaseModel): + items: List[Union["MemoryObject", "ComplexMemoryObject", "AnotherObject"]] + more_items: List[Union["MemoryObject", "ComplexMemoryObject", "AnotherObject"]] + +class TestOutputClass(BaseModel): + prop1: str + prop2: int + +class Tree(BaseModel): + data: int + children: "Forest" + +class TwoStoriesOneTitle(BaseModel): + title: str + story_a: str + story_b: str + +class UnionTest_ReturnType(BaseModel): + prop1: Union[str, bool] + prop2: List[Union[float, bool]] + prop3: Union[List[bool], List[int]] + +class UniverseQuestion(BaseModel): + question: str + answer: str + +class UniverseQuestionInput(BaseModel): + question: str + +class WithReasoning(BaseModel): + value: str + reasoning: str + +RecursiveMapAlias: TypeAlias = Dict[str, "RecursiveMapAlias"] + +RecursiveListAlias: TypeAlias = List["RecursiveListAlias"] + +RecAliasOne: TypeAlias = "RecAliasTwo" + +RecAliasTwo: TypeAlias = "RecAliasThree" + +RecAliasThree: TypeAlias = List["RecAliasOne"] + +JsonValue: TypeAlias = Union[int, str, bool, float, "JsonObject", "JsonArray"] + +JsonObject: TypeAlias = Dict[str, "JsonValue"] + +JsonArray: TypeAlias = List["JsonValue"] diff --git a/integ-tests/react/baml_client/async_client.ts b/integ-tests/react/baml_client/async_client.ts index 8f49a32d0..440f8f1f0 100644 --- a/integ-tests/react/baml_client/async_client.ts +++ b/integ-tests/react/baml_client/async_client.ts @@ -18,7 +18,7 @@ $ pnpm add @boundaryml/baml import { BamlRuntime, FunctionResult, BamlCtxManager, BamlStream, Image, ClientRegistry, BamlValidationError, createBamlValidationError } from "@boundaryml/baml" import { Checked, Check } from "./types" import "./partial_types" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" +import {AnotherObject, BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, ComplexMemoryObject, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MemoryObject, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestMemoryOutput, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" import TypeBuilder from "./type_builder" import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME } from "./globals" @@ -3222,6 +3222,31 @@ export class BamlAsyncClient { } } + async TestMemory( + input: string, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): Promise { + try { + const raw = await this.runtime.callFunction( + "TestMemory", + { + "input": input + }, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return raw.parsed(false) as TestMemoryOutput + } catch (error: any) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } else { + throw error; + } + } + } + async TestMulticlassNamedArgs( myArg: NamedArgsSingleClass,myArg2: NamedArgsSingleClass, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } @@ -7844,6 +7869,39 @@ class BamlStreamClient { } } + TestMemory( + input: string, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): BamlStream { + try { + const raw = this.runtime.streamFunction( + "TestMemory", + { + "input": input + }, + undefined, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return new BamlStream( + raw, + (a): a is partial_types.TestMemoryOutput => a, + (a): a is TestMemoryOutput => a, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + ) + } catch (error) { + if (error instanceof Error) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } + } + throw error; + } + } + TestMulticlassNamedArgs( myArg: NamedArgsSingleClass,myArg2: NamedArgsSingleClass, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } diff --git a/integ-tests/react/baml_client/globals.ts b/integ-tests/react/baml_client/globals.ts new file mode 100644 index 000000000..00b093019 --- /dev/null +++ b/integ-tests/react/baml_client/globals.ts @@ -0,0 +1,37 @@ +/************************************************************************************************* + +Welcome to Baml! To use this generated code, please run one of the following: + +$ npm install @boundaryml/baml +$ yarn add @boundaryml/baml +$ pnpm add @boundaryml/baml + +*************************************************************************************************/ + +// This file was generated by BAML: do not edit it. Instead, edit the BAML +// files and re-generate this code. +// +/* eslint-disable */ +// tslint:disable +// @ts-nocheck +// biome-ignore format: autogenerated code +import { BamlCtxManager, BamlRuntime } from '@boundaryml/baml' +import { getBamlFiles } from './inlinedbaml' + + +export const DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME = BamlRuntime.fromFiles( + 'baml_src', + getBamlFiles(), + process.env +) +export const DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX = new BamlCtxManager(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME) + + +export function resetBamlEnvVars(envVars: Record) { + if (DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.allowResets()) { + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME.reset('baml_src', getBamlFiles(), envVars) + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.reset() + } else { + throw new Error('BamlError: Cannot reset BAML environment variables while there are active BAML contexts.') + } +} \ No newline at end of file diff --git a/integ-tests/react/baml_client/index.ts b/integ-tests/react/baml_client/index.ts new file mode 100644 index 000000000..6fc0cb7ab --- /dev/null +++ b/integ-tests/react/baml_client/index.ts @@ -0,0 +1,24 @@ +/************************************************************************************************* + +Welcome to Baml! To use this generated code, please run one of the following: + +$ npm install @boundaryml/baml +$ yarn add @boundaryml/baml +$ pnpm add @boundaryml/baml + +*************************************************************************************************/ + +// This file was generated by BAML: do not edit it. Instead, edit the BAML +// files and re-generate this code. +// +/* eslint-disable */ +// tslint:disable +// @ts-nocheck +// biome-ignore format: autogenerated code + +export { b } from "./async_client" + +export * from "./types" +export * from "./tracing" +export { resetBamlEnvVars } from "./globals" +export { BamlValidationError } from "@boundaryml/baml" \ No newline at end of file diff --git a/integ-tests/react/baml_client/inlinedbaml.ts b/integ-tests/react/baml_client/inlinedbaml.ts index af238d609..0cdddaf8b 100644 --- a/integ-tests/react/baml_client/inlinedbaml.ts +++ b/integ-tests/react/baml_client/inlinedbaml.ts @@ -27,7 +27,7 @@ const fileMap = { "fiddle-examples/images/image.baml": "function DescribeImage(img: image) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\") }}\n\n\n Describe the image below in 20 words:\n {{ img }}\n \"#\n\n}\n\nclass FakeImage {\n url string\n}\n\nclass ClassWithImage {\n myImage image\n param2 string\n fake_image FakeImage\n}\n\n// chat role user present\nfunction DescribeImage2(classWithImage: ClassWithImage, img2: image) -> string { \n client GPT4Turbo\n prompt #\"\n {{ _.role(\"user\") }}\n You should return 2 answers that answer the following commands.\n\n 1. Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n 2. Also tell me what's happening here in one sentence:\n {{ img2 }}\n \"#\n}\n\n// no chat role\nfunction DescribeImage3(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\n\n// system prompt and chat prompt\nfunction DescribeImage4(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n {{ _.role(\"system\")}}\n\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\ntest TestName {\n functions [DescribeImage]\n args {\n img { url \"https://imgs.xkcd.com/comics/standards.png\"}\n }\n}\n", "fiddle-examples/symbol-tuning.baml": "enum Category3 {\n Refund @alias(\"k1\")\n @description(\"Customer wants to refund a product\")\n\n CancelOrder @alias(\"k2\")\n @description(\"Customer wants to cancel an order\")\n\n TechnicalSupport @alias(\"k3\")\n @description(\"Customer needs help with a technical issue unrelated to account creation or login\")\n\n AccountIssue @alias(\"k4\")\n @description(\"Specifically relates to account-login or account-creation\")\n\n Question @alias(\"k5\")\n @description(\"Customer has a question\")\n}\n\nfunction ClassifyMessage3(input: string) -> Category {\n client GPT4\n\n prompt #\"\n Classify the following INPUT into ONE\n of the following categories:\n\n INPUT: {{ input }}\n\n {{ ctx.output_format }}\n\n Response:\n \"#\n}", "formatter/test-comments.baml": "class FormatterTest0 {\n lorem string // trailing comments should be preserved\n ipsum string\n}\n\nclass FormatterTest1 {\n lorem string\n ipsum string\n // dolor string\n}\n\nclass FormatterTest2 {\n // \"lorem\" is a latin word\n lorem string\n // \"ipsum\" is a latin word\n ipsum string\n}\n\nclass FormatterTest3 {\n lorem string\n ipsum string\n // Lorem ipsum dolor sit amet\n // Consectetur adipiscing elit\n // Sed do eiusmod tempor incididunt\n // Ut labore et dolore magna aliqua\n // Ut enim ad minim veniam\n}", - "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.73.5\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.73.5\"\n}\n", + "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.74.0\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.74.0\"\n}\n\ngenerator openapi {\n output_type rest/openapi\n output_dir \"../openapi\"\n version \"0.74.0\"\n on_generate \"rm .gitignore\"\n}", "test-files/aliases/aliased-inputs.baml": "\nclass InputClass {\n key string @alias(\"color\")\n key2 string\n}\n\n\nclass InputClassNested {\n key string\n nested InputClass @alias(\"interesting-key\")\n}\n \n\nfunction AliasedInputClass(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {{input}}\n\n This is a test. What's the name of the first json key above? Remember, tell me the key, not value.\n \"#\n}\n \nfunction AliasedInputClass2(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {# making sure we can still access the original key #}\n {%if input.key == \"tiger\"%}\n Repeat this value back to me, and nothing else: {{input.key}}\n {%endif%}\n \"#\n}\n \n function AliasedInputClassNested(input: InputClassNested) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n\n {{input}}\n\n This is a test. What's the name of the second json key above? Remember, tell me the key, not value.\n \"#\n }\n\n\nenum AliasedEnum {\n KEY_ONE @alias(\"tiger\")\n KEY_TWO\n}\n\nfunction AliasedInputEnum(input: AliasedEnum) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\")}}\n\n\n Write out this word only in your response, in lowercase:\n ---\n {{input}}\n ---\n Answer:\n \"#\n}\n\n\nfunction AliasedInputList(input: AliasedEnum[]) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n Given this array:\n ---\n {{input}}\n ---\n\n Return the first element in the array:\n \"#\n}\n\n", "test-files/aliases/classes.baml": "class TestClassAlias {\n key string @alias(\"key-dash\") @description(#\"\n This is a description for key\n af asdf\n \"#)\n key2 string @alias(\"key21\")\n key3 string @alias(\"key with space\")\n key4 string //unaliased\n key5 string @alias(\"key.with.punctuation/123\")\n}\n\nfunction FnTestClassAlias(input: string) -> TestClassAlias {\n client GPT35\n prompt #\"\n {{ctx.output_format}}\n \"#\n}\n\ntest FnTestClassAlias {\n functions [FnTestClassAlias]\n args {\n input \"example input\"\n }\n}\n", "test-files/aliases/enums.baml": "enum TestEnum {\n A @alias(\"k1\") @description(#\"\n User is angry\n \"#)\n B @alias(\"k22\") @description(#\"\n User is happy\n \"#)\n // tests whether k1 doesnt incorrectly get matched with k11\n C @alias(\"k11\") @description(#\"\n User is sad\n \"#)\n D @alias(\"k44\") @description(\n User is confused\n )\n E @description(\n User is excited\n )\n F @alias(\"k5\") // only alias\n \n G @alias(\"k6\") @description(#\"\n User is bored\n With a long description\n \"#)\n \n @@alias(\"Category\")\n}\n\nfunction FnTestAliasedEnumOutput(input: string) -> TestEnum {\n client GPT35\n prompt #\"\n Classify the user input into the following category\n \n {{ ctx.output_format }}\n\n {{ _.role('user') }}\n {{input}}\n\n {{ _.role('assistant') }}\n Category ID:\n \"#\n}\n\ntest FnTestAliasedEnumOutput {\n functions [FnTestAliasedEnumOutput]\n args {\n input \"mehhhhh\"\n }\n}", @@ -92,6 +92,7 @@ const fileMap = { "test-files/functions/prompts/no-chat-messages.baml": "\n\nfunction PromptTestClaude(input: string) -> string {\n client Sonnet\n prompt #\"\n Tell me a haiku about {{ input }}\n \"#\n}\n\n\nfunction PromptTestStreaming(input: string) -> string {\n client GPT35\n prompt #\"\n Tell me a short story about {{ input }}\n \"#\n}\n\ntest TestName {\n functions [PromptTestStreaming]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/functions/prompts/with-chat-messages.baml": "\nfunction PromptTestOpenAIChat(input: string) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestOpenAIChatNoSystem(input: string) -> string {\n client GPT35\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChat(input: string) -> string {\n client Claude\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChatNoSystem(input: string) -> string {\n client Claude\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\ntest TestSystemAndNonSystemChat1 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"cats\"\n }\n}\n\ntest TestSystemAndNonSystemChat2 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"lion\"\n }\n}", "test-files/functions/v2/basic.baml": "\n\nfunction ExtractResume2(resume: string) -> Resume {\n client GPT4\n prompt #\"\n {{ _.role('system') }}\n\n Extract the following information from the resume:\n\n Resume:\n <<<<\n {{ resume }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}\n\n\nclass WithReasoning {\n value string\n reasoning string @description(#\"\n Why the value is a good fit.\n \"#)\n}\n\n\nclass SearchParams {\n dateRange int? @description(#\"\n In ISO duration format, e.g. P1Y2M10D.\n \"#)\n location string[]\n jobTitle WithReasoning? @description(#\"\n An exact job title, not a general category.\n \"#)\n company WithReasoning? @description(#\"\n The exact name of the company, not a product or service.\n \"#)\n description WithReasoning[] @description(#\"\n Any specific projects or features the user is looking for.\n \"#)\n tags (Tag | string)[]\n}\n\nenum Tag {\n Security\n AI\n Blockchain\n}\n\nfunction GetQuery(query: string) -> SearchParams {\n client GPT4\n prompt #\"\n Extract the following information from the query:\n\n Query:\n <<<<\n {{ query }}\n <<<<\n\n OUTPUT_JSON_SCHEMA:\n {{ ctx.output_format }}\n\n Before OUTPUT_JSON_SCHEMA, list 5 intentions the user may have.\n --- EXAMPLES ---\n 1. \n 2. \n 3. \n 4. \n 5. \n\n {\n ... // OUTPUT_JSON_SCHEMA\n }\n \"#\n}\n\nclass RaysData {\n dataType DataType\n value Resume | Event\n}\n\nenum DataType {\n Resume\n Event\n}\n\nclass Event {\n title string\n date string\n location string\n description string\n}\n\nfunction GetDataType(text: string) -> RaysData {\n client GPT4\n prompt #\"\n Extract the relevant info.\n\n Text:\n <<<<\n {{ text }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}", + "test-files/load-test/memory.baml": "\n\nclass MemoryObject {\n id string\n name string\n description string\n}\n\nclass ComplexMemoryObject {\n id string\n name string\n description string\n metadata (string | int | float)[] @description(#\"\n Additional metadata about the memory object, which can be a mix of types.\n \"#)\n}\n\nclass AnotherObject {\n id string\n thingy2 string\n thingy3 string\n}\n\nclass TestMemoryOutput {\n items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 10 items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n more_items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 3 more items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n}\n\n\nfunction TestMemory(input: string) -> TestMemoryOutput {\n client GPT35\n prompt #\"\n Return a json blob that matches the schema:\n {{ ctx.output_format }}\n \"#\n}\n\ntest TestName {\n functions [TestMemory]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/providers/anthropic.baml": "function TestAnthropic(input: string) -> string {\n client Claude\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestAnthropicShorthand(input: string) -> string {\n client \"anthropic/claude-3-haiku-20240307\"\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestCaching(input: string, not_cached: string) -> string {\n client ClaudeWithCaching\n prompt #\"\n {{ _.role('system', cache_control={\"type\": \"ephemeral\"}) }}\n Generate the following story\n {{ input }}\n\n {# Haiku require 2048 tokens to cache -#}\n {{ input }}\n\n {{ _.role('user') }}\n {{ not_cached }}\n \"#\n}", "test-files/providers/aws.baml": "function TestAws(input: string) -> string {\n client AwsBedrock\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nclass UniverseQuestion {\n question string\n answer string\n}\n\nclass UniverseQuestionInput {\n question string\n}\n\nfunction TestUniverseQuestion(question: UniverseQuestionInput) -> UniverseQuestion {\n client AwsBedrock\n prompt #\"\n You are a helpful assistant that answers questions about the universe.\n\n {{ ctx.output_format }}\n\n {{ _.role(\"user\")}}\n\n Question: {{ question }}\n\n Answer:\n \"#\n}\n\n\nfunction TestAwsInvalidRegion(input: string) -> string {\n client AwsBedrockInvalidRegion\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidAccessKey(input: string) -> string {\n client AwsBedrockInvalidAccessKey\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidProfile(input: string) -> string {\n client AwsBedrockInvalidProfile\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidSessionToken(input: string) -> string {\n client AwsBedrockInvalidSessionToken\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}", "test-files/providers/azure.baml": "function TestAzure(input: string) -> string {\n client GPT35Azure\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nclient GPT35AzureFailed {\n provider azure-openai\n options {\n resource_name \"west-us-azure-baml-incorrect-suffix\"\n deployment_id \"gpt-35-turbo-default\"\n api_key env.AZURE_OPENAI_API_KEY\n }\n}\n\nfunction TestAzureFailure(input: string) -> string {\n client GPT35AzureFailed\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}", diff --git a/integ-tests/react/baml_client/partial_types.ts b/integ-tests/react/baml_client/partial_types.ts index 054cabbbe..cd6e87263 100644 --- a/integ-tests/react/baml_client/partial_types.ts +++ b/integ-tests/react/baml_client/partial_types.ts @@ -32,6 +32,12 @@ export interface StreamState { } +export interface AnotherObject { + id?: (string | null) + thingy2?: (string | null) + thingy3?: (string | null) +} + export interface BigNumbers { a?: (number | null) b?: (number | null) @@ -99,6 +105,13 @@ export interface ClassWithoutDone { s_20_words?: StreamState<(string | null)> } +export interface ComplexMemoryObject { + id?: (string | null) + name?: (string | null) + description?: (string | null) + metadata?: ((string | null) | (number | null) | (number | null) | null)[] +} + export interface CompoundBigNumbers { big?: partial_types.BigNumbers | null big_nums?: partial_types.BigNumbers | null[] @@ -283,6 +296,12 @@ export interface Martian { age?: Checked<(number | null),"young_enough"> } +export interface MemoryObject { + id?: (string | null) + name?: (string | null) + description?: (string | null) +} + export interface MergeAttrs { amount?: Checked<(number | null),"gt_ten"> } @@ -462,6 +481,11 @@ export interface TestClassWithEnum { prop2?: (EnumInClass | null) } +export interface TestMemoryOutput { + items?: (partial_types.MemoryObject | null | partial_types.ComplexMemoryObject | null | partial_types.AnotherObject | null | null)[] + more_items?: (partial_types.MemoryObject | null | partial_types.ComplexMemoryObject | null | partial_types.AnotherObject | null | null)[] +} + export interface TestOutputClass { prop1?: (string | null) prop2?: (number | null) diff --git a/integ-tests/react/baml_client/react/client.tsx b/integ-tests/react/baml_client/react/client.tsx index a18d9dbcc..29f513bf7 100644 --- a/integ-tests/react/baml_client/react/client.tsx +++ b/integ-tests/react/baml_client/react/client.tsx @@ -33,7 +33,7 @@ import type { Image, Audio } from "@boundaryml/baml" import { BamlValidationError, BamlClientFinishReasonError } from "@boundaryml/baml/errors" import * as ServerActions from './server'; -import type {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" +import type {AnotherObject, BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, ComplexMemoryObject, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MemoryObject, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestMemoryOutput, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" /** * Type guard to check if props are for streaming mode @@ -17174,6 +17174,138 @@ export function useTestImageListInput + * - Streaming Final: TestMemoryOutput + * + * Common Usage Patterns: + * 1. Non-streaming (Default) + * - Best for: Quick responses, simple UI updates + * - Avoid when: Response takes >5s or UI needs progressive updates + * + * 2. Streaming + * - Best for: Long-running operations, real-time UI feedback + * - Required when: Using features like chat interfaces or progress indicators + * + * Edge Cases & Gotchas: + * 1. Error Handling + * - Network failures won't trigger onPartial/onFinal + * - Always implement onError for graceful degradation + * - Check error.message for specific failure reasons + * + * 2. Streaming Mode + * - partialData may be null even after updates (handle this case!) + * - Stream can end without final data (connection loss) + * - Partial results may be incomplete/invalid + * + * 3. State Management + * - data persists after completion (clear if needed) + * - isPending stays true until final/error + * - Multiple rapid calls can race (latest wins) + * + * @example + * ```tsx + * // 1. Basic Usage (Non-streaming) + * const { data, error, isPending, mutate } = useTestMemory(); + * + * // Handle the response + * useEffect(() => { + * if (data) { + * // Type-safe access to TestMemoryOutput + * console.log('Success:', data); + * } + * }, [data]); + * + * // 2. Streaming with Progress + * const { + * data, // Type: TestMemoryOutput | null + * partialData, // Type: RecursivePartialNull | null + * isPending, + * error, + * mutate + * } = useTestMemory({ + * stream: true, + * + * // Handle partial updates (may be incomplete!) + * onPartial: (partial) => { + * console.log('Partial:', partial); + * }, + * + * // Handle successful completion + * onFinal: (final) => { + * console.log('Final:', final); + * }, + * + * // Robust error handling + * onError: (error) => { + * console.error('Request failed:', error); + * } + * }); + * + * // 3. Making the Request + * const handleSubmit = async () => { + * try { + * const result = await mutate({ + * // Type-safe parameters: + * input: someValue as string, // Replace someValue with your data + * }); + * + * if (result) { + * // Success case + * } + * } catch (e) { + * // Handle any synchronous errors + * } + * }; + * + * // 4. Race Condition Handling + * const handleMultipleCalls = async () => { + * // Only the latest call's results will be reflected in the UI + * const results = await Promise.all([ + * mutate({ + * input: firstValue as string, + * }), + * mutate({ + * input: secondValue as string, + * }) + * ]); + * // Check results[1] for the final state + * }; + * ``` + */ +export function useTestMemory( + props: StreamingProps +): StreamingHookResult; + +export function useTestMemory( + props?: NonStreamingProps +): NonStreamingHookResult; + +export function useTestMemory( + props: HookProps = {}, +): StreamingHookResult | NonStreamingHookResult { + if (props.stream) { + return useBamlAction( + ServerActions.TestMemoryStreamingAction, + props + ); + } + + return useBamlAction( + ServerActions.TestMemoryAction, + props + ); +} + /** * A specialized hook for the TestMulticlassNamedArgs BAML function that handles both streaming and non-streaming responses. * diff --git a/integ-tests/react/baml_client/react/server.ts b/integ-tests/react/baml_client/react/server.ts index f30796afb..8570301bf 100644 --- a/integ-tests/react/baml_client/react/server.ts +++ b/integ-tests/react/baml_client/react/server.ts @@ -21,7 +21,7 @@ import { b } from '../index'; import type { Check, Checked } from "../types" import type { ServerAction } from "./types" import type { Image, Audio } from "@boundaryml/baml" -import type {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" +import type {AnotherObject, BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, ComplexMemoryObject, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MemoryObject, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestMemoryOutput, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "../types" /** * Server action for the AaaSamOutputFormat BAML function. * @@ -3735,6 +3735,35 @@ export const TestImageListInputStreamingAction = async ( return stream.toStreamable(); }; +/** + * Server action for the TestMemory BAML function. + * + * Input Types: + * + * - input: string + * + * + * Return Type: + * - Non-streaming: TestMemoryOutput + * - Streaming: ReadableStream + */ +export const TestMemoryAction = async ( + input: string, +): Promise => { + return b.TestMemory( + input, + ); +}; + +export const TestMemoryStreamingAction = async ( + input: string, +): Promise> => { + const stream = b.stream.TestMemory( + input, + ); + return stream.toStreamable(); +}; + /** * Server action for the TestMulticlassNamedArgs BAML function. * diff --git a/integ-tests/react/baml_client/sync_client.ts b/integ-tests/react/baml_client/sync_client.ts index 431fb1725..7ef08587f 100644 --- a/integ-tests/react/baml_client/sync_client.ts +++ b/integ-tests/react/baml_client/sync_client.ts @@ -17,7 +17,7 @@ $ pnpm add @boundaryml/baml // biome-ignore format: autogenerated code import { BamlRuntime, FunctionResult, BamlCtxManager, BamlSyncStream, Image, ClientRegistry, createBamlValidationError, BamlValidationError } from "@boundaryml/baml" import { Checked, Check, RecursivePartialNull } from "./types" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" +import {AnotherObject, BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, ComplexMemoryObject, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MemoryObject, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestMemoryOutput, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" import TypeBuilder from "./type_builder" import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME } from "./globals" @@ -3221,6 +3221,31 @@ export class BamlSyncClient { } } + TestMemory( + input: string, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): TestMemoryOutput { + try { + const raw = this.runtime.callFunctionSync( + "TestMemory", + { + "input": input + }, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return raw.parsed(false) as TestMemoryOutput + } catch (error: any) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } else { + throw error; + } + } + } + TestMulticlassNamedArgs( myArg: NamedArgsSingleClass,myArg2: NamedArgsSingleClass, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } diff --git a/integ-tests/react/baml_client/tracing.ts b/integ-tests/react/baml_client/tracing.ts new file mode 100644 index 000000000..f39dc83a0 --- /dev/null +++ b/integ-tests/react/baml_client/tracing.ts @@ -0,0 +1,33 @@ +/************************************************************************************************* + +Welcome to Baml! To use this generated code, please run one of the following: + +$ npm install @boundaryml/baml +$ yarn add @boundaryml/baml +$ pnpm add @boundaryml/baml + +*************************************************************************************************/ + +// This file was generated by BAML: do not edit it. Instead, edit the BAML +// files and re-generate this code. +// +/* eslint-disable */ +// tslint:disable +// @ts-nocheck +// biome-ignore format: autogenerated code +import { BamlLogEvent } from '@boundaryml/baml'; +import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX } from './globals'; + +const traceAsync = +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.traceFnAsync.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX) +const traceSync = +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.traceFnSync.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX) +const setTags = +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.upsertTags.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX) +const flush = () => { + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.flush.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX)() +} +const onLogEvent = (callback: undefined | ((event: BamlLogEvent) => void)) => +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.onLogEvent(callback) + +export { traceAsync, traceSync, setTags, flush, onLogEvent } \ No newline at end of file diff --git a/integ-tests/react/baml_client/type_builder.ts b/integ-tests/react/baml_client/type_builder.ts index 86486a3d8..27a96b750 100644 --- a/integ-tests/react/baml_client/type_builder.ts +++ b/integ-tests/react/baml_client/type_builder.ts @@ -51,7 +51,7 @@ export default class TypeBuilder { constructor() { this.tb = new _TypeBuilder({ classes: new Set([ - "BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithBlockDone","ClassWithImage","ClassWithoutDone","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SemanticContainer","SmallThing","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning", + "AnotherObject","BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithBlockDone","ClassWithImage","ClassWithoutDone","ComplexMemoryObject","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MemoryObject","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SemanticContainer","SmallThing","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestMemoryOutput","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning", ]), enums: new Set([ "AliasedEnum","Category","Category2","Category3","Color","DataType","DynEnumOne","DynEnumTwo","EnumInClass","EnumOutput","Hobby","MapKey","NamedArgsSingleEnum","NamedArgsSingleEnumList","OptionalTest_CategoryType","OrderStatus","Tag","TestEnum", diff --git a/integ-tests/react/baml_client/types.ts b/integ-tests/react/baml_client/types.ts index 12c728864..aa806d41c 100644 --- a/integ-tests/react/baml_client/types.ts +++ b/integ-tests/react/baml_client/types.ts @@ -162,6 +162,13 @@ export enum TestEnum { G = "G", } +export interface AnotherObject { + id: string + thingy2: string + thingy3: string + +} + export interface BigNumbers { a: number b: number @@ -242,6 +249,14 @@ export interface ClassWithoutDone { } +export interface ComplexMemoryObject { + id: string + name: string + description: string + metadata: (string | number | number)[] + +} + export interface CompoundBigNumbers { big: BigNumbers big_nums: BigNumbers[] @@ -460,6 +475,13 @@ export interface Martian { } +export interface MemoryObject { + id: string + name: string + description: string + +} + export interface MergeAttrs { amount: Checked @@ -670,6 +692,12 @@ export interface TestClassWithEnum { } +export interface TestMemoryOutput { + items: (MemoryObject | ComplexMemoryObject | AnotherObject)[] + more_items: (MemoryObject | ComplexMemoryObject | AnotherObject)[] + +} + export interface TestOutputClass { prop1: string prop2: number diff --git a/integ-tests/ruby/baml_client/client.rb b/integ-tests/ruby/baml_client/client.rb index e1877faf2..49055a912 100644 --- a/integ-tests/ruby/baml_client/client.rb +++ b/integ-tests/ruby/baml_client/client.rb @@ -4114,6 +4114,38 @@ def TestImageListInput( (raw.parsed_using_types(Baml::Types, Baml::PartialTypes, false)) end + sig { + params( + varargs: T.untyped, + input: String, + baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)] + ).returns(Baml::Types::TestMemoryOutput) + } + def TestMemory( + *varargs, + input:, + baml_options: {} + ) + if varargs.any? + + raise ArgumentError.new("TestMemory may only be called with keyword arguments") + end + if (baml_options.keys - [:client_registry, :tb]).any? + raise ArgumentError.new("Received unknown keys in baml_options (valid keys: :client_registry, :tb): #{baml_options.keys - [:client_registry, :tb]}") + end + + raw = @runtime.call_function( + "TestMemory", + { + input: input, + }, + @ctx_manager, + baml_options[:tb]&.instance_variable_get(:@registry), + baml_options[:client_registry], + ) + (raw.parsed_using_types(Baml::Types, Baml::PartialTypes, false)) + end + sig { params( varargs: T.untyped, @@ -9116,6 +9148,41 @@ def TestImageListInput( ) end + sig { + params( + varargs: T.untyped, + input: String, + baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)] + ).returns(Baml::BamlStream[Baml::Types::TestMemoryOutput]) + } + def TestMemory( + *varargs, + input:, + baml_options: {} + ) + if varargs.any? + + raise ArgumentError.new("TestMemory may only be called with keyword arguments") + end + if (baml_options.keys - [:client_registry, :tb]).any? + raise ArgumentError.new("Received unknown keys in baml_options (valid keys: :client_registry, :tb): #{baml_options.keys - [:client_registry, :tb]}") + end + + raw = @runtime.stream_function( + "TestMemory", + { + input: input, + }, + @ctx_manager, + baml_options[:tb]&.instance_variable_get(:@registry), + baml_options[:client_registry], + ) + Baml::BamlStream[T.nilable(Baml::PartialTypes::TestMemoryOutput), Baml::Types::TestMemoryOutput].new( + ffi_stream: raw, + ctx_manager: @ctx_manager + ) + end + sig { params( varargs: T.untyped, diff --git a/integ-tests/ruby/baml_client/inlined.rb b/integ-tests/ruby/baml_client/inlined.rb index bb8a43d3b..04de2c7c9 100644 --- a/integ-tests/ruby/baml_client/inlined.rb +++ b/integ-tests/ruby/baml_client/inlined.rb @@ -26,7 +26,7 @@ module Inlined "fiddle-examples/images/image.baml" => "function DescribeImage(img: image) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\") }}\n\n\n Describe the image below in 20 words:\n {{ img }}\n \"#\n\n}\n\nclass FakeImage {\n url string\n}\n\nclass ClassWithImage {\n myImage image\n param2 string\n fake_image FakeImage\n}\n\n// chat role user present\nfunction DescribeImage2(classWithImage: ClassWithImage, img2: image) -> string { \n client GPT4Turbo\n prompt #\"\n {{ _.role(\"user\") }}\n You should return 2 answers that answer the following commands.\n\n 1. Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n 2. Also tell me what's happening here in one sentence:\n {{ img2 }}\n \"#\n}\n\n// no chat role\nfunction DescribeImage3(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\n\n// system prompt and chat prompt\nfunction DescribeImage4(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n {{ _.role(\"system\")}}\n\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\ntest TestName {\n functions [DescribeImage]\n args {\n img { url \"https://imgs.xkcd.com/comics/standards.png\"}\n }\n}\n", "fiddle-examples/symbol-tuning.baml" => "enum Category3 {\n Refund @alias(\"k1\")\n @description(\"Customer wants to refund a product\")\n\n CancelOrder @alias(\"k2\")\n @description(\"Customer wants to cancel an order\")\n\n TechnicalSupport @alias(\"k3\")\n @description(\"Customer needs help with a technical issue unrelated to account creation or login\")\n\n AccountIssue @alias(\"k4\")\n @description(\"Specifically relates to account-login or account-creation\")\n\n Question @alias(\"k5\")\n @description(\"Customer has a question\")\n}\n\nfunction ClassifyMessage3(input: string) -> Category {\n client GPT4\n\n prompt #\"\n Classify the following INPUT into ONE\n of the following categories:\n\n INPUT: {{ input }}\n\n {{ ctx.output_format }}\n\n Response:\n \"#\n}", "formatter/test-comments.baml" => "class FormatterTest0 {\n lorem string // trailing comments should be preserved\n ipsum string\n}\n\nclass FormatterTest1 {\n lorem string\n ipsum string\n // dolor string\n}\n\nclass FormatterTest2 {\n // \"lorem\" is a latin word\n lorem string\n // \"ipsum\" is a latin word\n ipsum string\n}\n\nclass FormatterTest3 {\n lorem string\n ipsum string\n // Lorem ipsum dolor sit amet\n // Consectetur adipiscing elit\n // Sed do eiusmod tempor incididunt\n // Ut labore et dolore magna aliqua\n // Ut enim ad minim veniam\n}", - "generators.baml" => "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.73.5\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.73.5\"\n}\n", + "generators.baml" => "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.74.0\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.74.0\"\n}\n\ngenerator openapi {\n output_type rest/openapi\n output_dir \"../openapi\"\n version \"0.74.0\"\n on_generate \"rm .gitignore\"\n}", "test-files/aliases/aliased-inputs.baml" => "\nclass InputClass {\n key string @alias(\"color\")\n key2 string\n}\n\n\nclass InputClassNested {\n key string\n nested InputClass @alias(\"interesting-key\")\n}\n \n\nfunction AliasedInputClass(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {{input}}\n\n This is a test. What's the name of the first json key above? Remember, tell me the key, not value.\n \"#\n}\n \nfunction AliasedInputClass2(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {# making sure we can still access the original key #}\n {%if input.key == \"tiger\"%}\n Repeat this value back to me, and nothing else: {{input.key}}\n {%endif%}\n \"#\n}\n \n function AliasedInputClassNested(input: InputClassNested) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n\n {{input}}\n\n This is a test. What's the name of the second json key above? Remember, tell me the key, not value.\n \"#\n }\n\n\nenum AliasedEnum {\n KEY_ONE @alias(\"tiger\")\n KEY_TWO\n}\n\nfunction AliasedInputEnum(input: AliasedEnum) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\")}}\n\n\n Write out this word only in your response, in lowercase:\n ---\n {{input}}\n ---\n Answer:\n \"#\n}\n\n\nfunction AliasedInputList(input: AliasedEnum[]) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n Given this array:\n ---\n {{input}}\n ---\n\n Return the first element in the array:\n \"#\n}\n\n", "test-files/aliases/classes.baml" => "class TestClassAlias {\n key string @alias(\"key-dash\") @description(#\"\n This is a description for key\n af asdf\n \"#)\n key2 string @alias(\"key21\")\n key3 string @alias(\"key with space\")\n key4 string //unaliased\n key5 string @alias(\"key.with.punctuation/123\")\n}\n\nfunction FnTestClassAlias(input: string) -> TestClassAlias {\n client GPT35\n prompt #\"\n {{ctx.output_format}}\n \"#\n}\n\ntest FnTestClassAlias {\n functions [FnTestClassAlias]\n args {\n input \"example input\"\n }\n}\n", "test-files/aliases/enums.baml" => "enum TestEnum {\n A @alias(\"k1\") @description(#\"\n User is angry\n \"#)\n B @alias(\"k22\") @description(#\"\n User is happy\n \"#)\n // tests whether k1 doesnt incorrectly get matched with k11\n C @alias(\"k11\") @description(#\"\n User is sad\n \"#)\n D @alias(\"k44\") @description(\n User is confused\n )\n E @description(\n User is excited\n )\n F @alias(\"k5\") // only alias\n \n G @alias(\"k6\") @description(#\"\n User is bored\n With a long description\n \"#)\n \n @@alias(\"Category\")\n}\n\nfunction FnTestAliasedEnumOutput(input: string) -> TestEnum {\n client GPT35\n prompt #\"\n Classify the user input into the following category\n \n {{ ctx.output_format }}\n\n {{ _.role('user') }}\n {{input}}\n\n {{ _.role('assistant') }}\n Category ID:\n \"#\n}\n\ntest FnTestAliasedEnumOutput {\n functions [FnTestAliasedEnumOutput]\n args {\n input \"mehhhhh\"\n }\n}", @@ -91,6 +91,7 @@ module Inlined "test-files/functions/prompts/no-chat-messages.baml" => "\n\nfunction PromptTestClaude(input: string) -> string {\n client Sonnet\n prompt #\"\n Tell me a haiku about {{ input }}\n \"#\n}\n\n\nfunction PromptTestStreaming(input: string) -> string {\n client GPT35\n prompt #\"\n Tell me a short story about {{ input }}\n \"#\n}\n\ntest TestName {\n functions [PromptTestStreaming]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/functions/prompts/with-chat-messages.baml" => "\nfunction PromptTestOpenAIChat(input: string) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestOpenAIChatNoSystem(input: string) -> string {\n client GPT35\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChat(input: string) -> string {\n client Claude\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChatNoSystem(input: string) -> string {\n client Claude\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\ntest TestSystemAndNonSystemChat1 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"cats\"\n }\n}\n\ntest TestSystemAndNonSystemChat2 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"lion\"\n }\n}", "test-files/functions/v2/basic.baml" => "\n\nfunction ExtractResume2(resume: string) -> Resume {\n client GPT4\n prompt #\"\n {{ _.role('system') }}\n\n Extract the following information from the resume:\n\n Resume:\n <<<<\n {{ resume }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}\n\n\nclass WithReasoning {\n value string\n reasoning string @description(#\"\n Why the value is a good fit.\n \"#)\n}\n\n\nclass SearchParams {\n dateRange int? @description(#\"\n In ISO duration format, e.g. P1Y2M10D.\n \"#)\n location string[]\n jobTitle WithReasoning? @description(#\"\n An exact job title, not a general category.\n \"#)\n company WithReasoning? @description(#\"\n The exact name of the company, not a product or service.\n \"#)\n description WithReasoning[] @description(#\"\n Any specific projects or features the user is looking for.\n \"#)\n tags (Tag | string)[]\n}\n\nenum Tag {\n Security\n AI\n Blockchain\n}\n\nfunction GetQuery(query: string) -> SearchParams {\n client GPT4\n prompt #\"\n Extract the following information from the query:\n\n Query:\n <<<<\n {{ query }}\n <<<<\n\n OUTPUT_JSON_SCHEMA:\n {{ ctx.output_format }}\n\n Before OUTPUT_JSON_SCHEMA, list 5 intentions the user may have.\n --- EXAMPLES ---\n 1. \n 2. \n 3. \n 4. \n 5. \n\n {\n ... // OUTPUT_JSON_SCHEMA\n }\n \"#\n}\n\nclass RaysData {\n dataType DataType\n value Resume | Event\n}\n\nenum DataType {\n Resume\n Event\n}\n\nclass Event {\n title string\n date string\n location string\n description string\n}\n\nfunction GetDataType(text: string) -> RaysData {\n client GPT4\n prompt #\"\n Extract the relevant info.\n\n Text:\n <<<<\n {{ text }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}", + "test-files/load-test/memory.baml" => "\n\nclass MemoryObject {\n id string\n name string\n description string\n}\n\nclass ComplexMemoryObject {\n id string\n name string\n description string\n metadata (string | int | float)[] @description(#\"\n Additional metadata about the memory object, which can be a mix of types.\n \"#)\n}\n\nclass AnotherObject {\n id string\n thingy2 string\n thingy3 string\n}\n\nclass TestMemoryOutput {\n items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 10 items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n more_items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 3 more items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n}\n\n\nfunction TestMemory(input: string) -> TestMemoryOutput {\n client GPT35\n prompt #\"\n Return a json blob that matches the schema:\n {{ ctx.output_format }}\n \"#\n}\n\ntest TestName {\n functions [TestMemory]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/providers/anthropic.baml" => "function TestAnthropic(input: string) -> string {\n client Claude\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestAnthropicShorthand(input: string) -> string {\n client \"anthropic/claude-3-haiku-20240307\"\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestCaching(input: string, not_cached: string) -> string {\n client ClaudeWithCaching\n prompt #\"\n {{ _.role('system', cache_control={\"type\": \"ephemeral\"}) }}\n Generate the following story\n {{ input }}\n\n {# Haiku require 2048 tokens to cache -#}\n {{ input }}\n\n {{ _.role('user') }}\n {{ not_cached }}\n \"#\n}", "test-files/providers/aws.baml" => "function TestAws(input: string) -> string {\n client AwsBedrock\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nclass UniverseQuestion {\n question string\n answer string\n}\n\nclass UniverseQuestionInput {\n question string\n}\n\nfunction TestUniverseQuestion(question: UniverseQuestionInput) -> UniverseQuestion {\n client AwsBedrock\n prompt #\"\n You are a helpful assistant that answers questions about the universe.\n\n {{ ctx.output_format }}\n\n {{ _.role(\"user\")}}\n\n Question: {{ question }}\n\n Answer:\n \"#\n}\n\n\nfunction TestAwsInvalidRegion(input: string) -> string {\n client AwsBedrockInvalidRegion\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidAccessKey(input: string) -> string {\n client AwsBedrockInvalidAccessKey\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidProfile(input: string) -> string {\n client AwsBedrockInvalidProfile\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidSessionToken(input: string) -> string {\n client AwsBedrockInvalidSessionToken\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}", "test-files/providers/azure.baml" => "function TestAzure(input: string) -> string {\n client GPT35Azure\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nclient GPT35AzureFailed {\n provider azure-openai\n options {\n resource_name \"west-us-azure-baml-incorrect-suffix\"\n deployment_id \"gpt-35-turbo-default\"\n api_key env.AZURE_OPENAI_API_KEY\n }\n}\n\nfunction TestAzureFailure(input: string) -> string {\n client GPT35AzureFailed\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}", diff --git a/integ-tests/ruby/baml_client/partial-types.rb b/integ-tests/ruby/baml_client/partial-types.rb new file mode 100644 index 000000000..c5cab11f6 --- /dev/null +++ b/integ-tests/ruby/baml_client/partial-types.rb @@ -0,0 +1,1421 @@ +############################################################################### +# +# Welcome to Baml! To use this generated code, please run the following: +# +# $ bundle add baml sorbet-runtime +# +############################################################################### + +# This file was generated by BAML: please do not edit it. Instead, edit the +# BAML files and re-generate this code. +# +# frozen_string_literal: true +# rubocop: disable +# formatter:off +# typed: false +require "sorbet-runtime" + +require_relative "types" + +module Baml + + module PartialTypes + class AnotherObject < T::Struct; end + class BigNumbers < T::Struct; end + class BinaryNode < T::Struct; end + class Blah < T::Struct; end + class BlockConstraint < T::Struct; end + class BlockConstraintForParam < T::Struct; end + class BookOrder < T::Struct; end + class ClassForNullLiteral < T::Struct; end + class ClassOptionalOutput < T::Struct; end + class ClassOptionalOutput2 < T::Struct; end + class ClassToRecAlias < T::Struct; end + class ClassWithBlockDone < T::Struct; end + class ClassWithImage < T::Struct; end + class ClassWithoutDone < T::Struct; end + class ComplexMemoryObject < T::Struct; end + class CompoundBigNumbers < T::Struct; end + class ContactInfo < T::Struct; end + class CustomTaskResult < T::Struct; end + class DummyOutput < T::Struct; end + class DynInputOutput < T::Struct; end + class DynamicClassOne < T::Struct; end + class DynamicClassTwo < T::Struct; end + class DynamicOutput < T::Struct; end + class Earthling < T::Struct; end + class Education < T::Struct; end + class Email < T::Struct; end + class EmailAddress < T::Struct; end + class Event < T::Struct; end + class FakeImage < T::Struct; end + class FlightConfirmation < T::Struct; end + class FooAny < T::Struct; end + class Forest < T::Struct; end + class FormatterTest0 < T::Struct; end + class FormatterTest1 < T::Struct; end + class FormatterTest2 < T::Struct; end + class FormatterTest3 < T::Struct; end + class GroceryReceipt < T::Struct; end + class InnerClass < T::Struct; end + class InnerClass2 < T::Struct; end + class InputClass < T::Struct; end + class InputClassNested < T::Struct; end + class LinkedList < T::Struct; end + class LinkedListAliasNode < T::Struct; end + class LiteralClassHello < T::Struct; end + class LiteralClassOne < T::Struct; end + class LiteralClassTwo < T::Struct; end + class MalformedConstraints < T::Struct; end + class MalformedConstraints2 < T::Struct; end + class Martian < T::Struct; end + class MemoryObject < T::Struct; end + class MergeAttrs < T::Struct; end + class NamedArgsSingleClass < T::Struct; end + class Nested < T::Struct; end + class Nested2 < T::Struct; end + class NestedBlockConstraint < T::Struct; end + class NestedBlockConstraintForParam < T::Struct; end + class Node < T::Struct; end + class NodeWithAliasIndirection < T::Struct; end + class OptionalListAndMap < T::Struct; end + class OptionalTest_Prop1 < T::Struct; end + class OptionalTest_ReturnType < T::Struct; end + class OrderInfo < T::Struct; end + class OriginalA < T::Struct; end + class OriginalB < T::Struct; end + class Person < T::Struct; end + class PhoneNumber < T::Struct; end + class Quantity < T::Struct; end + class RaysData < T::Struct; end + class ReceiptInfo < T::Struct; end + class ReceiptItem < T::Struct; end + class Recipe < T::Struct; end + class Resume < T::Struct; end + class Schema < T::Struct; end + class SearchParams < T::Struct; end + class SemanticContainer < T::Struct; end + class SmallThing < T::Struct; end + class SomeClassNestedDynamic < T::Struct; end + class StringToClassEntry < T::Struct; end + class TestClassAlias < T::Struct; end + class TestClassNested < T::Struct; end + class TestClassWithEnum < T::Struct; end + class TestMemoryOutput < T::Struct; end + class TestOutputClass < T::Struct; end + class Tree < T::Struct; end + class TwoStoriesOneTitle < T::Struct; end + class UnionTest_ReturnType < T::Struct; end + class UniverseQuestion < T::Struct; end + class UniverseQuestionInput < T::Struct; end + class WithReasoning < T::Struct; end + class AnotherObject < T::Struct + include Baml::Sorbet::Struct + const :id, T.nilable(String) + const :thingy2, T.nilable(String) + const :thingy3, T.nilable(String) + + def initialize(props) + super( + id: props[:id], + thingy2: props[:thingy2], + thingy3: props[:thingy3], + ) + + @props = props + end + end + class BigNumbers < T::Struct + include Baml::Sorbet::Struct + const :a, T.nilable(Integer) + const :b, T.nilable(Float) + + def initialize(props) + super( + a: props[:a], + b: props[:b], + ) + + @props = props + end + end + class BinaryNode < T::Struct + include Baml::Sorbet::Struct + const :data, T.nilable(Integer) + const :left, T.nilable(Baml::PartialTypes::BinaryNode) + const :right, T.nilable(Baml::PartialTypes::BinaryNode) + + def initialize(props) + super( + data: props[:data], + left: props[:left], + right: props[:right], + ) + + @props = props + end + end + class Blah < T::Struct + include Baml::Sorbet::Struct + const :prop4, T.nilable(String) + + def initialize(props) + super( + prop4: props[:prop4], + ) + + @props = props + end + end + class BlockConstraint < T::Struct + include Baml::Sorbet::Struct + const :foo, T.nilable(Integer) + const :bar, T.nilable(String) + + def initialize(props) + super( + foo: props[:foo], + bar: props[:bar], + ) + + @props = props + end + end + class BlockConstraintForParam < T::Struct + include Baml::Sorbet::Struct + const :bcfp, T.nilable(Integer) + const :bcfp2, T.nilable(String) + + def initialize(props) + super( + bcfp: props[:bcfp], + bcfp2: props[:bcfp2], + ) + + @props = props + end + end + class BookOrder < T::Struct + include Baml::Sorbet::Struct + const :orderId, T.nilable(String) + const :title, T.nilable(String) + const :quantity, T.nilable(Integer) + const :price, T.nilable(Float) + + def initialize(props) + super( + orderId: props[:orderId], + title: props[:title], + quantity: props[:quantity], + price: props[:price], + ) + + @props = props + end + end + class ClassForNullLiteral < T::Struct + include Baml::Sorbet::Struct + const :a, T.nilable(String) + + def initialize(props) + super( + a: props[:a], + ) + + @props = props + end + end + class ClassOptionalOutput < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(String) + const :prop2, T.nilable(String) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class ClassOptionalOutput2 < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(String) + const :prop2, T.nilable(String) + const :prop3, T.nilable(Baml::PartialTypes::Blah) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + prop3: props[:prop3], + ) + + @props = props + end + end + class ClassToRecAlias < T::Struct + include Baml::Sorbet::Struct + const :list, T.nilable(Baml::PartialTypes::LinkedListAliasNode) + + def initialize(props) + super( + list: props[:list], + ) + + @props = props + end + end + class ClassWithBlockDone < T::Struct + include Baml::Sorbet::Struct + const :i_16_digits, T.nilable(Integer) + const :s_20_words, T.nilable(String) + + def initialize(props) + super( + i_16_digits: props[:i_16_digits], + s_20_words: props[:s_20_words], + ) + + @props = props + end + end + class ClassWithImage < T::Struct + include Baml::Sorbet::Struct + const :myImage, T.nilable(Baml::Image) + const :param2, T.nilable(String) + const :fake_image, T.nilable(Baml::PartialTypes::FakeImage) + + def initialize(props) + super( + myImage: props[:myImage], + param2: props[:param2], + fake_image: props[:fake_image], + ) + + @props = props + end + end + class ClassWithoutDone < T::Struct + include Baml::Sorbet::Struct + const :i_16_digits, T.nilable(Integer) + const :s_20_words, Baml::StreamState[T.nilable(String)] + + def initialize(props) + super( + i_16_digits: props[:i_16_digits], + s_20_words: props[:s_20_words], + ) + + @props = props + end + end + class ComplexMemoryObject < T::Struct + include Baml::Sorbet::Struct + const :id, T.nilable(String) + const :name, T.nilable(String) + const :description, T.nilable(String) + const :metadata, T::Array[T.nilable(T.any(T.nilable(String), T.nilable(Integer), T.nilable(Float)))] + + def initialize(props) + super( + id: props[:id], + name: props[:name], + description: props[:description], + metadata: props[:metadata], + ) + + @props = props + end + end + class CompoundBigNumbers < T::Struct + include Baml::Sorbet::Struct + const :big, T.nilable(Baml::PartialTypes::BigNumbers) + const :big_nums, T::Array[T.nilable(Baml::PartialTypes::BigNumbers)] + const :another, T.nilable(Baml::PartialTypes::BigNumbers) + + def initialize(props) + super( + big: props[:big], + big_nums: props[:big_nums], + another: props[:another], + ) + + @props = props + end + end + class ContactInfo < T::Struct + include Baml::Sorbet::Struct + const :primary, T.nilable(T.any(T.nilable(Baml::PartialTypes::PhoneNumber), T.nilable(Baml::PartialTypes::EmailAddress))) + const :secondary, T.nilable(T.any(T.nilable(Baml::PartialTypes::PhoneNumber), T.nilable(Baml::PartialTypes::EmailAddress), T.nilable(NilClass))) + + def initialize(props) + super( + primary: props[:primary], + secondary: props[:secondary], + ) + + @props = props + end + end + class CustomTaskResult < T::Struct + include Baml::Sorbet::Struct + const :bookOrder, T.nilable(T.any(T.nilable(Baml::PartialTypes::BookOrder), T.nilable(NilClass))) + const :flightConfirmation, T.nilable(T.any(T.nilable(Baml::PartialTypes::FlightConfirmation), T.nilable(NilClass))) + const :groceryReceipt, T.nilable(T.any(T.nilable(Baml::PartialTypes::GroceryReceipt), T.nilable(NilClass))) + + def initialize(props) + super( + bookOrder: props[:bookOrder], + flightConfirmation: props[:flightConfirmation], + groceryReceipt: props[:groceryReceipt], + ) + + @props = props + end + end + class DummyOutput < T::Struct + include Baml::Sorbet::Struct + const :nonce, T.nilable(String) + const :nonce2, T.nilable(String) + + def initialize(props) + super( + nonce: props[:nonce], + nonce2: props[:nonce2], + ) + + @props = props + end + end + class DynInputOutput < T::Struct + include Baml::Sorbet::Struct + const :testKey, T.nilable(String) + + def initialize(props) + super( + testKey: props[:testKey], + ) + + @props = props + end + end + class DynamicClassOne < T::Struct + include Baml::Sorbet::Struct + + def initialize(props) + super( + ) + + @props = props + end + end + class DynamicClassTwo < T::Struct + include Baml::Sorbet::Struct + const :hi, T.nilable(String) + const :some_class, T.nilable(Baml::PartialTypes::SomeClassNestedDynamic) + const :status, T.nilable(Baml::Types::DynEnumOne) + + def initialize(props) + super( + hi: props[:hi], + some_class: props[:some_class], + status: props[:status], + ) + + @props = props + end + end + class DynamicOutput < T::Struct + include Baml::Sorbet::Struct + + def initialize(props) + super( + ) + + @props = props + end + end + class Earthling < T::Struct + include Baml::Sorbet::Struct + const :age, T.nilable(Baml::Checked[Integer]) + + def initialize(props) + super( + age: props[:age], + ) + + @props = props + end + end + class Education < T::Struct + include Baml::Sorbet::Struct + const :institution, T.nilable(String) + const :location, T.nilable(String) + const :degree, T.nilable(String) + const :major, T::Array[T.nilable(String)] + const :graduation_date, T.nilable(String) + + def initialize(props) + super( + institution: props[:institution], + location: props[:location], + degree: props[:degree], + major: props[:major], + graduation_date: props[:graduation_date], + ) + + @props = props + end + end + class Email < T::Struct + include Baml::Sorbet::Struct + const :subject, T.nilable(String) + const :body, T.nilable(String) + const :from_address, T.nilable(String) + + def initialize(props) + super( + subject: props[:subject], + body: props[:body], + from_address: props[:from_address], + ) + + @props = props + end + end + class EmailAddress < T::Struct + include Baml::Sorbet::Struct + const :value, T.nilable(String) + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class Event < T::Struct + include Baml::Sorbet::Struct + const :title, T.nilable(String) + const :date, T.nilable(String) + const :location, T.nilable(String) + const :description, T.nilable(String) + + def initialize(props) + super( + title: props[:title], + date: props[:date], + location: props[:location], + description: props[:description], + ) + + @props = props + end + end + class FakeImage < T::Struct + include Baml::Sorbet::Struct + const :url, T.nilable(String) + + def initialize(props) + super( + url: props[:url], + ) + + @props = props + end + end + class FlightConfirmation < T::Struct + include Baml::Sorbet::Struct + const :confirmationNumber, T.nilable(String) + const :flightNumber, T.nilable(String) + const :departureTime, T.nilable(String) + const :arrivalTime, T.nilable(String) + const :seatNumber, T.nilable(String) + + def initialize(props) + super( + confirmationNumber: props[:confirmationNumber], + flightNumber: props[:flightNumber], + departureTime: props[:departureTime], + arrivalTime: props[:arrivalTime], + seatNumber: props[:seatNumber], + ) + + @props = props + end + end + class FooAny < T::Struct + include Baml::Sorbet::Struct + const :planetary_age, T.nilable(T.any(T.nilable(Baml::PartialTypes::Martian), T.nilable(Baml::PartialTypes::Earthling))) + const :certainty, T.nilable(Baml::Checked[Integer]) + const :species, T.nilable(Baml::Checked[String]) + + def initialize(props) + super( + planetary_age: props[:planetary_age], + certainty: props[:certainty], + species: props[:species], + ) + + @props = props + end + end + class Forest < T::Struct + include Baml::Sorbet::Struct + const :trees, T::Array[T.nilable(Baml::PartialTypes::Tree)] + + def initialize(props) + super( + trees: props[:trees], + ) + + @props = props + end + end + class FormatterTest0 < T::Struct + include Baml::Sorbet::Struct + const :lorem, T.nilable(String) + const :ipsum, T.nilable(String) + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class FormatterTest1 < T::Struct + include Baml::Sorbet::Struct + const :lorem, T.nilable(String) + const :ipsum, T.nilable(String) + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class FormatterTest2 < T::Struct + include Baml::Sorbet::Struct + const :lorem, T.nilable(String) + const :ipsum, T.nilable(String) + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class FormatterTest3 < T::Struct + include Baml::Sorbet::Struct + const :lorem, T.nilable(String) + const :ipsum, T.nilable(String) + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class GroceryReceipt < T::Struct + include Baml::Sorbet::Struct + const :receiptId, T.nilable(String) + const :storeName, T.nilable(String) + const :items, T::Array[T.nilable(T.any(T.nilable(String), T.nilable(Integer), T.nilable(Float)))] + const :totalAmount, T.nilable(Float) + + def initialize(props) + super( + receiptId: props[:receiptId], + storeName: props[:storeName], + items: props[:items], + totalAmount: props[:totalAmount], + ) + + @props = props + end + end + class InnerClass < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(String) + const :prop2, T.nilable(String) + const :inner, T.nilable(Baml::PartialTypes::InnerClass2) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + inner: props[:inner], + ) + + @props = props + end + end + class InnerClass2 < T::Struct + include Baml::Sorbet::Struct + const :prop2, T.nilable(Integer) + const :prop3, T.nilable(Float) + + def initialize(props) + super( + prop2: props[:prop2], + prop3: props[:prop3], + ) + + @props = props + end + end + class InputClass < T::Struct + include Baml::Sorbet::Struct + const :key, T.nilable(String) + const :key2, T.nilable(String) + + def initialize(props) + super( + key: props[:key], + key2: props[:key2], + ) + + @props = props + end + end + class InputClassNested < T::Struct + include Baml::Sorbet::Struct + const :key, T.nilable(String) + const :nested, T.nilable(Baml::PartialTypes::InputClass) + + def initialize(props) + super( + key: props[:key], + nested: props[:nested], + ) + + @props = props + end + end + class LinkedList < T::Struct + include Baml::Sorbet::Struct + const :head, T.nilable(Baml::PartialTypes::Node) + const :len, T.nilable(Integer) + + def initialize(props) + super( + head: props[:head], + len: props[:len], + ) + + @props = props + end + end + class LinkedListAliasNode < T::Struct + include Baml::Sorbet::Struct + const :value, T.nilable(Integer) + const :next, T.nilable(Baml::PartialTypes::LinkedListAliasNode) + + def initialize(props) + super( + value: props[:value], + next: props[:next], + ) + + @props = props + end + end + class LiteralClassHello < T::Struct + include Baml::Sorbet::Struct + const :prop, T.nilable(String) + + def initialize(props) + super( + prop: props[:prop], + ) + + @props = props + end + end + class LiteralClassOne < T::Struct + include Baml::Sorbet::Struct + const :prop, T.nilable(String) + + def initialize(props) + super( + prop: props[:prop], + ) + + @props = props + end + end + class LiteralClassTwo < T::Struct + include Baml::Sorbet::Struct + const :prop, T.nilable(String) + + def initialize(props) + super( + prop: props[:prop], + ) + + @props = props + end + end + class MalformedConstraints < T::Struct + include Baml::Sorbet::Struct + const :foo, T.nilable(Baml::Checked[Integer]) + + def initialize(props) + super( + foo: props[:foo], + ) + + @props = props + end + end + class MalformedConstraints2 < T::Struct + include Baml::Sorbet::Struct + const :foo, T.nilable(Integer) + + def initialize(props) + super( + foo: props[:foo], + ) + + @props = props + end + end + # A Martian organism with an age. + # Such a nice type. + class Martian < T::Struct + include Baml::Sorbet::Struct + # The age of the Martian in Mars years. + # So many Mars years. + const :age, T.nilable(Baml::Checked[Integer]) + + def initialize(props) + super( + age: props[:age], + ) + + @props = props + end + end + class MemoryObject < T::Struct + include Baml::Sorbet::Struct + const :id, T.nilable(String) + const :name, T.nilable(String) + const :description, T.nilable(String) + + def initialize(props) + super( + id: props[:id], + name: props[:name], + description: props[:description], + ) + + @props = props + end + end + class MergeAttrs < T::Struct + include Baml::Sorbet::Struct + const :amount, T.nilable(Baml::Checked[Integer]) + + def initialize(props) + super( + amount: props[:amount], + ) + + @props = props + end + end + class NamedArgsSingleClass < T::Struct + include Baml::Sorbet::Struct + const :key, T.nilable(String) + const :key_two, T.nilable(T::Boolean) + const :key_three, T.nilable(Integer) + + def initialize(props) + super( + key: props[:key], + key_two: props[:key_two], + key_three: props[:key_three], + ) + + @props = props + end + end + class Nested < T::Struct + include Baml::Sorbet::Struct + const :prop3, T.nilable(T.any(T.nilable(String), T.nilable(NilClass))) + const :prop4, T.nilable(T.any(T.nilable(String), T.nilable(NilClass))) + const :prop20, T.nilable(Baml::PartialTypes::Nested2) + + def initialize(props) + super( + prop3: props[:prop3], + prop4: props[:prop4], + prop20: props[:prop20], + ) + + @props = props + end + end + class Nested2 < T::Struct + include Baml::Sorbet::Struct + const :prop11, T.nilable(T.any(T.nilable(String), T.nilable(NilClass))) + const :prop12, T.nilable(T.any(T.nilable(String), T.nilable(NilClass))) + + def initialize(props) + super( + prop11: props[:prop11], + prop12: props[:prop12], + ) + + @props = props + end + end + class NestedBlockConstraint < T::Struct + include Baml::Sorbet::Struct + const :nbc, T.nilable(Baml::PartialTypes::BlockConstraint) + + def initialize(props) + super( + nbc: props[:nbc], + ) + + @props = props + end + end + class NestedBlockConstraintForParam < T::Struct + include Baml::Sorbet::Struct + const :nbcfp, T.nilable(Baml::PartialTypes::BlockConstraintForParam) + + def initialize(props) + super( + nbcfp: props[:nbcfp], + ) + + @props = props + end + end + class Node < T::Struct + include Baml::Sorbet::Struct + const :data, T.nilable(Integer) + const :next, T.nilable(Baml::PartialTypes::Node) + + def initialize(props) + super( + data: props[:data], + next: props[:next], + ) + + @props = props + end + end + class NodeWithAliasIndirection < T::Struct + include Baml::Sorbet::Struct + const :value, T.nilable(Integer) + const :next, T.nilable(Baml::PartialTypes::NodeWithAliasIndirection) + + def initialize(props) + super( + value: props[:value], + next: props[:next], + ) + + @props = props + end + end + class OptionalListAndMap < T::Struct + include Baml::Sorbet::Struct + const :p, T::Array[T.nilable(String)] + const :q, T::Hash[String, T.nilable(String)] + + def initialize(props) + super( + p: props[:p], + q: props[:q], + ) + + @props = props + end + end + class OptionalTest_Prop1 < T::Struct + include Baml::Sorbet::Struct + const :omega_a, T.nilable(String) + const :omega_b, T.nilable(Integer) + + def initialize(props) + super( + omega_a: props[:omega_a], + omega_b: props[:omega_b], + ) + + @props = props + end + end + class OptionalTest_ReturnType < T::Struct + include Baml::Sorbet::Struct + const :omega_1, T.nilable(Baml::PartialTypes::OptionalTest_Prop1) + const :omega_2, T.nilable(String) + const :omega_3, T::Array[T.nilable(Baml::Types::OptionalTest_CategoryType)] + + def initialize(props) + super( + omega_1: props[:omega_1], + omega_2: props[:omega_2], + omega_3: props[:omega_3], + ) + + @props = props + end + end + class OrderInfo < T::Struct + include Baml::Sorbet::Struct + const :order_status, T.nilable(Baml::Types::OrderStatus) + const :tracking_number, T.nilable(String) + const :estimated_arrival_date, T.nilable(String) + + def initialize(props) + super( + order_status: props[:order_status], + tracking_number: props[:tracking_number], + estimated_arrival_date: props[:estimated_arrival_date], + ) + + @props = props + end + end + class OriginalA < T::Struct + include Baml::Sorbet::Struct + const :value, T.nilable(Integer) + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class OriginalB < T::Struct + include Baml::Sorbet::Struct + const :value, T.nilable(Integer) + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class Person < T::Struct + include Baml::Sorbet::Struct + const :name, T.nilable(String) + const :hair_color, T.nilable(Baml::Types::Color) + + def initialize(props) + super( + name: props[:name], + hair_color: props[:hair_color], + ) + + @props = props + end + end + class PhoneNumber < T::Struct + include Baml::Sorbet::Struct + const :value, T.nilable(String) + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class Quantity < T::Struct + include Baml::Sorbet::Struct + const :amount, T.nilable(T.any(T.nilable(Integer), T.nilable(Float))) + const :unit, T.nilable(String) + + def initialize(props) + super( + amount: props[:amount], + unit: props[:unit], + ) + + @props = props + end + end + class RaysData < T::Struct + include Baml::Sorbet::Struct + const :dataType, T.nilable(Baml::Types::DataType) + const :value, T.nilable(T.any(T.nilable(Baml::PartialTypes::Resume), T.nilable(Baml::PartialTypes::Event))) + + def initialize(props) + super( + dataType: props[:dataType], + value: props[:value], + ) + + @props = props + end + end + class ReceiptInfo < T::Struct + include Baml::Sorbet::Struct + const :items, T::Array[T.nilable(Baml::PartialTypes::ReceiptItem)] + const :total_cost, T.nilable(Float) + const :venue, T.nilable(T.any(T.nilable(String), T.nilable(String))) + + def initialize(props) + super( + items: props[:items], + total_cost: props[:total_cost], + venue: props[:venue], + ) + + @props = props + end + end + class ReceiptItem < T::Struct + include Baml::Sorbet::Struct + const :name, T.nilable(String) + const :description, T.nilable(String) + const :quantity, T.nilable(Integer) + const :price, T.nilable(Float) + + def initialize(props) + super( + name: props[:name], + description: props[:description], + quantity: props[:quantity], + price: props[:price], + ) + + @props = props + end + end + class Recipe < T::Struct + include Baml::Sorbet::Struct + const :ingredients, T::Hash[String, T.nilable(Baml::PartialTypes::Quantity)] + const :recipe_type, T.nilable(T.any(T.nilable(String), T.nilable(String))) + + def initialize(props) + super( + ingredients: props[:ingredients], + recipe_type: props[:recipe_type], + ) + + @props = props + end + end + class Resume < T::Struct + include Baml::Sorbet::Struct + const :name, T.nilable(String) + const :email, T.nilable(String) + const :phone, T.nilable(String) + const :experience, T::Array[T.nilable(Baml::PartialTypes::Education)] + const :education, T::Array[T.nilable(String)] + const :skills, T::Array[T.nilable(String)] + + def initialize(props) + super( + name: props[:name], + email: props[:email], + phone: props[:phone], + experience: props[:experience], + education: props[:education], + skills: props[:skills], + ) + + @props = props + end + end + class Schema < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(T.any(T.nilable(String), T.nilable(NilClass))) + const :prop2, T.nilable(T.any(T.nilable(Baml::PartialTypes::Nested), T.nilable(String))) + const :prop5, T::Array[T.nilable(T.any(T.nilable(String), T.nilable(NilClass)))] + const :prop6, T.nilable(T.any(T.nilable(String), T::Array[T.nilable(Baml::PartialTypes::Nested)])) + const :nested_attrs, T::Array[T.nilable(T.any(T.nilable(String), T.nilable(NilClass), T.nilable(Baml::PartialTypes::Nested)))] + const :parens, T.nilable(T.any(T.nilable(String), T.nilable(NilClass))) + const :other_group, T.nilable(T.any(T.nilable(String), T.nilable(T.any(T.nilable(Integer), T.nilable(String))))) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + prop5: props[:prop5], + prop6: props[:prop6], + nested_attrs: props[:nested_attrs], + parens: props[:parens], + other_group: props[:other_group], + ) + + @props = props + end + end + class SearchParams < T::Struct + include Baml::Sorbet::Struct + const :dateRange, T.nilable(Integer) + const :location, T::Array[T.nilable(String)] + const :jobTitle, T.nilable(Baml::PartialTypes::WithReasoning) + const :company, T.nilable(Baml::PartialTypes::WithReasoning) + const :description, T::Array[T.nilable(Baml::PartialTypes::WithReasoning)] + const :tags, T::Array[T.nilable(T.any(T.nilable(Baml::Types::Tag), T.nilable(String)))] + + def initialize(props) + super( + dateRange: props[:dateRange], + location: props[:location], + jobTitle: props[:jobTitle], + company: props[:company], + description: props[:description], + tags: props[:tags], + ) + + @props = props + end + end + class SemanticContainer < T::Struct + include Baml::Sorbet::Struct + const :sixteen_digit_number, T.nilable(Integer) + const :string_with_twenty_words, T.nilable(String) + const :class_1, T.nilable(Baml::PartialTypes::ClassWithoutDone) + const :class_2, T.nilable(Baml::Types::ClassWithBlockDone) + const :class_done_needed, Baml::Types::ClassWithBlockDone + const :class_needed, Baml::PartialTypes::ClassWithoutDone + const :three_small_things, T::Array[T.nilable(Baml::PartialTypes::SmallThing)] + const :final_string, T.nilable(String) + + def initialize(props) + super( + sixteen_digit_number: props[:sixteen_digit_number], + string_with_twenty_words: props[:string_with_twenty_words], + class_1: props[:class_1], + class_2: props[:class_2], + class_done_needed: props[:class_done_needed], + class_needed: props[:class_needed], + three_small_things: props[:three_small_things], + final_string: props[:final_string], + ) + + @props = props + end + end + class SmallThing < T::Struct + include Baml::Sorbet::Struct + const :i_16_digits, Integer + const :i_8_digits, T.nilable(Integer) + + def initialize(props) + super( + i_16_digits: props[:i_16_digits], + i_8_digits: props[:i_8_digits], + ) + + @props = props + end + end + class SomeClassNestedDynamic < T::Struct + include Baml::Sorbet::Struct + const :hi, T.nilable(String) + + def initialize(props) + super( + hi: props[:hi], + ) + + @props = props + end + end + class StringToClassEntry < T::Struct + include Baml::Sorbet::Struct + const :word, T.nilable(String) + + def initialize(props) + super( + word: props[:word], + ) + + @props = props + end + end + class TestClassAlias < T::Struct + include Baml::Sorbet::Struct + const :key, T.nilable(String) + const :key2, T.nilable(String) + const :key3, T.nilable(String) + const :key4, T.nilable(String) + const :key5, T.nilable(String) + + def initialize(props) + super( + key: props[:key], + key2: props[:key2], + key3: props[:key3], + key4: props[:key4], + key5: props[:key5], + ) + + @props = props + end + end + class TestClassNested < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(String) + const :prop2, T.nilable(Baml::PartialTypes::InnerClass) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class TestClassWithEnum < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(String) + const :prop2, T.nilable(Baml::Types::EnumInClass) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class TestMemoryOutput < T::Struct + include Baml::Sorbet::Struct + const :items, T::Array[T.nilable(T.any(T.nilable(Baml::PartialTypes::MemoryObject), T.nilable(Baml::PartialTypes::ComplexMemoryObject), T.nilable(Baml::PartialTypes::AnotherObject)))] + const :more_items, T::Array[T.nilable(T.any(T.nilable(Baml::PartialTypes::MemoryObject), T.nilable(Baml::PartialTypes::ComplexMemoryObject), T.nilable(Baml::PartialTypes::AnotherObject)))] + + def initialize(props) + super( + items: props[:items], + more_items: props[:more_items], + ) + + @props = props + end + end + class TestOutputClass < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(String) + const :prop2, T.nilable(Integer) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class Tree < T::Struct + include Baml::Sorbet::Struct + const :data, T.nilable(Integer) + const :children, T.nilable(Baml::PartialTypes::Forest) + + def initialize(props) + super( + data: props[:data], + children: props[:children], + ) + + @props = props + end + end + class TwoStoriesOneTitle < T::Struct + include Baml::Sorbet::Struct + const :title, T.nilable(String) + const :story_a, T.nilable(String) + const :story_b, T.nilable(String) + + def initialize(props) + super( + title: props[:title], + story_a: props[:story_a], + story_b: props[:story_b], + ) + + @props = props + end + end + class UnionTest_ReturnType < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(T.any(T.nilable(String), T.nilable(T::Boolean))) + const :prop2, T::Array[T.nilable(T.any(T.nilable(Float), T.nilable(T::Boolean)))] + const :prop3, T.nilable(T.any(T::Array[T.nilable(T::Boolean)], T::Array[T.nilable(Integer)])) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + prop3: props[:prop3], + ) + + @props = props + end + end + class UniverseQuestion < T::Struct + include Baml::Sorbet::Struct + const :question, T.nilable(String) + const :answer, T.nilable(String) + + def initialize(props) + super( + question: props[:question], + answer: props[:answer], + ) + + @props = props + end + end + class UniverseQuestionInput < T::Struct + include Baml::Sorbet::Struct + const :question, T.nilable(String) + + def initialize(props) + super( + question: props[:question], + ) + + @props = props + end + end + class WithReasoning < T::Struct + include Baml::Sorbet::Struct + const :value, T.nilable(String) + const :reasoning, T.nilable(String) + + def initialize(props) + super( + value: props[:value], + reasoning: props[:reasoning], + ) + + @props = props + end + end + end +end \ No newline at end of file diff --git a/integ-tests/ruby/baml_client/type-registry.rb b/integ-tests/ruby/baml_client/type-registry.rb index 172205c64..03de1b4b5 100644 --- a/integ-tests/ruby/baml_client/type-registry.rb +++ b/integ-tests/ruby/baml_client/type-registry.rb @@ -18,7 +18,7 @@ module Baml class TypeBuilder def initialize @registry = Baml::Ffi::TypeBuilder.new - @classes = Set[ "BigNumbers", "BinaryNode", "Blah", "BlockConstraint", "BlockConstraintForParam", "BookOrder", "ClassForNullLiteral", "ClassOptionalOutput", "ClassOptionalOutput2", "ClassToRecAlias", "ClassWithBlockDone", "ClassWithImage", "ClassWithoutDone", "CompoundBigNumbers", "ContactInfo", "CustomTaskResult", "DummyOutput", "DynInputOutput", "DynamicClassOne", "DynamicClassTwo", "DynamicOutput", "Earthling", "Education", "Email", "EmailAddress", "Event", "FakeImage", "FlightConfirmation", "FooAny", "Forest", "FormatterTest0", "FormatterTest1", "FormatterTest2", "FormatterTest3", "GroceryReceipt", "InnerClass", "InnerClass2", "InputClass", "InputClassNested", "LinkedList", "LinkedListAliasNode", "LiteralClassHello", "LiteralClassOne", "LiteralClassTwo", "MalformedConstraints", "MalformedConstraints2", "Martian", "MergeAttrs", "NamedArgsSingleClass", "Nested", "Nested2", "NestedBlockConstraint", "NestedBlockConstraintForParam", "Node", "NodeWithAliasIndirection", "OptionalListAndMap", "OptionalTest_Prop1", "OptionalTest_ReturnType", "OrderInfo", "OriginalA", "OriginalB", "Person", "PhoneNumber", "Quantity", "RaysData", "ReceiptInfo", "ReceiptItem", "Recipe", "Resume", "Schema", "SearchParams", "SemanticContainer", "SmallThing", "SomeClassNestedDynamic", "StringToClassEntry", "TestClassAlias", "TestClassNested", "TestClassWithEnum", "TestOutputClass", "Tree", "TwoStoriesOneTitle", "UnionTest_ReturnType", "UniverseQuestion", "UniverseQuestionInput", "WithReasoning", ] + @classes = Set[ "AnotherObject", "BigNumbers", "BinaryNode", "Blah", "BlockConstraint", "BlockConstraintForParam", "BookOrder", "ClassForNullLiteral", "ClassOptionalOutput", "ClassOptionalOutput2", "ClassToRecAlias", "ClassWithBlockDone", "ClassWithImage", "ClassWithoutDone", "ComplexMemoryObject", "CompoundBigNumbers", "ContactInfo", "CustomTaskResult", "DummyOutput", "DynInputOutput", "DynamicClassOne", "DynamicClassTwo", "DynamicOutput", "Earthling", "Education", "Email", "EmailAddress", "Event", "FakeImage", "FlightConfirmation", "FooAny", "Forest", "FormatterTest0", "FormatterTest1", "FormatterTest2", "FormatterTest3", "GroceryReceipt", "InnerClass", "InnerClass2", "InputClass", "InputClassNested", "LinkedList", "LinkedListAliasNode", "LiteralClassHello", "LiteralClassOne", "LiteralClassTwo", "MalformedConstraints", "MalformedConstraints2", "Martian", "MemoryObject", "MergeAttrs", "NamedArgsSingleClass", "Nested", "Nested2", "NestedBlockConstraint", "NestedBlockConstraintForParam", "Node", "NodeWithAliasIndirection", "OptionalListAndMap", "OptionalTest_Prop1", "OptionalTest_ReturnType", "OrderInfo", "OriginalA", "OriginalB", "Person", "PhoneNumber", "Quantity", "RaysData", "ReceiptInfo", "ReceiptItem", "Recipe", "Resume", "Schema", "SearchParams", "SemanticContainer", "SmallThing", "SomeClassNestedDynamic", "StringToClassEntry", "TestClassAlias", "TestClassNested", "TestClassWithEnum", "TestMemoryOutput", "TestOutputClass", "Tree", "TwoStoriesOneTitle", "UnionTest_ReturnType", "WithReasoning", ] @enums = Set[ "AliasedEnum", "Category", "Category2", "Category3", "Color", "DataType", "DynEnumOne", "DynEnumTwo", "EnumInClass", "EnumOutput", "Hobby", "MapKey", "NamedArgsSingleEnum", "NamedArgsSingleEnumList", "OptionalTest_CategoryType", "OrderStatus", "Tag", "TestEnum", ] end diff --git a/integ-tests/ruby/baml_client/types.rb b/integ-tests/ruby/baml_client/types.rb new file mode 100644 index 000000000..b9ed45659 --- /dev/null +++ b/integ-tests/ruby/baml_client/types.rb @@ -0,0 +1,1547 @@ +############################################################################### +# +# Welcome to Baml! To use this generated code, please run the following: +# +# $ bundle add baml sorbet-runtime +# +############################################################################### + +# This file was generated by BAML: please do not edit it. Instead, edit the +# BAML files and re-generate this code. +# +# frozen_string_literal: true +# rubocop: disable +# formatter:off +# typed: false +require "sorbet-runtime" + +module Baml + + module Types + class AliasedEnum < T::Enum + enums do + KEY_ONE = new("KEY_ONE") + KEY_TWO = new("KEY_TWO") + end + end + class Category < T::Enum + enums do + Refund = new("Refund") + CancelOrder = new("CancelOrder") + TechnicalSupport = new("TechnicalSupport") + AccountIssue = new("AccountIssue") + Question = new("Question") + end + end + class Category2 < T::Enum + enums do + Refund = new("Refund") + CancelOrder = new("CancelOrder") + TechnicalSupport = new("TechnicalSupport") + AccountIssue = new("AccountIssue") + Question = new("Question") + end + end + class Category3 < T::Enum + enums do + Refund = new("Refund") + CancelOrder = new("CancelOrder") + TechnicalSupport = new("TechnicalSupport") + AccountIssue = new("AccountIssue") + Question = new("Question") + end + end + class Color < T::Enum + enums do + RED = new("RED") + BLUE = new("BLUE") + GREEN = new("GREEN") + YELLOW = new("YELLOW") + BLACK = new("BLACK") + WHITE = new("WHITE") + end + end + class DataType < T::Enum + enums do + Resume = new("Resume") + Event = new("Event") + end + end + class DynEnumOne < T::Enum + end + class DynEnumTwo < T::Enum + end + class EnumInClass < T::Enum + enums do + ONE = new("ONE") + TWO = new("TWO") + end + end + class EnumOutput < T::Enum + # An enum with three values, + # ONE, TWO and THREE. + enums do + ONE = new("ONE") + TWO = new("TWO") + THREE = new("THREE") + end + end + class Hobby < T::Enum + enums do + SPORTS = new("SPORTS") + MUSIC = new("MUSIC") + READING = new("READING") + end + end + class MapKey < T::Enum + enums do + A = new("A") + B = new("B") + C = new("C") + end + end + class NamedArgsSingleEnum < T::Enum + enums do + ONE = new("ONE") + TWO = new("TWO") + end + end + class NamedArgsSingleEnumList < T::Enum + enums do + ONE = new("ONE") + TWO = new("TWO") + end + end + class OptionalTest_CategoryType < T::Enum + enums do + Aleph = new("Aleph") + Beta = new("Beta") + Gamma = new("Gamma") + end + end + class OrderStatus < T::Enum + enums do + ORDERED = new("ORDERED") + SHIPPED = new("SHIPPED") + DELIVERED = new("DELIVERED") + CANCELLED = new("CANCELLED") + end + end + class Tag < T::Enum + enums do + Security = new("Security") + AI = new("AI") + Blockchain = new("Blockchain") + end + end + class TestEnum < T::Enum + enums do + A = new("A") + B = new("B") + C = new("C") + D = new("D") + E = new("E") + F = new("F") + G = new("G") + end + end + class AnotherObject < T::Struct; end + class BigNumbers < T::Struct; end + class BinaryNode < T::Struct; end + class Blah < T::Struct; end + class BlockConstraint < T::Struct; end + class BlockConstraintForParam < T::Struct; end + class BookOrder < T::Struct; end + class ClassForNullLiteral < T::Struct; end + class ClassOptionalOutput < T::Struct; end + class ClassOptionalOutput2 < T::Struct; end + class ClassToRecAlias < T::Struct; end + class ClassWithBlockDone < T::Struct; end + class ClassWithImage < T::Struct; end + class ClassWithoutDone < T::Struct; end + class ComplexMemoryObject < T::Struct; end + class CompoundBigNumbers < T::Struct; end + class ContactInfo < T::Struct; end + class CustomTaskResult < T::Struct; end + class DummyOutput < T::Struct; end + class DynInputOutput < T::Struct; end + class DynamicClassOne < T::Struct; end + class DynamicClassTwo < T::Struct; end + class DynamicOutput < T::Struct; end + class Earthling < T::Struct; end + class Education < T::Struct; end + class Email < T::Struct; end + class EmailAddress < T::Struct; end + class Event < T::Struct; end + class FakeImage < T::Struct; end + class FlightConfirmation < T::Struct; end + class FooAny < T::Struct; end + class Forest < T::Struct; end + class FormatterTest0 < T::Struct; end + class FormatterTest1 < T::Struct; end + class FormatterTest2 < T::Struct; end + class FormatterTest3 < T::Struct; end + class GroceryReceipt < T::Struct; end + class InnerClass < T::Struct; end + class InnerClass2 < T::Struct; end + class InputClass < T::Struct; end + class InputClassNested < T::Struct; end + class LinkedList < T::Struct; end + class LinkedListAliasNode < T::Struct; end + class LiteralClassHello < T::Struct; end + class LiteralClassOne < T::Struct; end + class LiteralClassTwo < T::Struct; end + class MalformedConstraints < T::Struct; end + class MalformedConstraints2 < T::Struct; end + class Martian < T::Struct; end + class MemoryObject < T::Struct; end + class MergeAttrs < T::Struct; end + class NamedArgsSingleClass < T::Struct; end + class Nested < T::Struct; end + class Nested2 < T::Struct; end + class NestedBlockConstraint < T::Struct; end + class NestedBlockConstraintForParam < T::Struct; end + class Node < T::Struct; end + class NodeWithAliasIndirection < T::Struct; end + class OptionalListAndMap < T::Struct; end + class OptionalTest_Prop1 < T::Struct; end + class OptionalTest_ReturnType < T::Struct; end + class OrderInfo < T::Struct; end + class OriginalA < T::Struct; end + class OriginalB < T::Struct; end + class Person < T::Struct; end + class PhoneNumber < T::Struct; end + class Quantity < T::Struct; end + class RaysData < T::Struct; end + class ReceiptInfo < T::Struct; end + class ReceiptItem < T::Struct; end + class Recipe < T::Struct; end + class Resume < T::Struct; end + class Schema < T::Struct; end + class SearchParams < T::Struct; end + class SemanticContainer < T::Struct; end + class SmallThing < T::Struct; end + class SomeClassNestedDynamic < T::Struct; end + class StringToClassEntry < T::Struct; end + class TestClassAlias < T::Struct; end + class TestClassNested < T::Struct; end + class TestClassWithEnum < T::Struct; end + class TestMemoryOutput < T::Struct; end + class TestOutputClass < T::Struct; end + class Tree < T::Struct; end + class TwoStoriesOneTitle < T::Struct; end + class UnionTest_ReturnType < T::Struct; end + class UniverseQuestion < T::Struct; end + class UniverseQuestionInput < T::Struct; end + class WithReasoning < T::Struct; end + class AnotherObject < T::Struct + include Baml::Sorbet::Struct + const :id, String + const :thingy2, String + const :thingy3, String + + def initialize(props) + super( + id: props[:id], + thingy2: props[:thingy2], + thingy3: props[:thingy3], + ) + + @props = props + end + end + class BigNumbers < T::Struct + include Baml::Sorbet::Struct + const :a, Integer + const :b, Float + + def initialize(props) + super( + a: props[:a], + b: props[:b], + ) + + @props = props + end + end + class BinaryNode < T::Struct + include Baml::Sorbet::Struct + const :data, Integer + const :left, T.nilable(Baml::Types::BinaryNode) + const :right, T.nilable(Baml::Types::BinaryNode) + + def initialize(props) + super( + data: props[:data], + left: props[:left], + right: props[:right], + ) + + @props = props + end + end + class Blah < T::Struct + include Baml::Sorbet::Struct + const :prop4, T.nilable(String) + + def initialize(props) + super( + prop4: props[:prop4], + ) + + @props = props + end + end + class BlockConstraint < T::Struct + include Baml::Sorbet::Struct + const :foo, Integer + const :bar, String + + def initialize(props) + super( + foo: props[:foo], + bar: props[:bar], + ) + + @props = props + end + end + class BlockConstraintForParam < T::Struct + include Baml::Sorbet::Struct + const :bcfp, Integer + const :bcfp2, String + + def initialize(props) + super( + bcfp: props[:bcfp], + bcfp2: props[:bcfp2], + ) + + @props = props + end + end + class BookOrder < T::Struct + include Baml::Sorbet::Struct + const :orderId, String + const :title, String + const :quantity, Integer + const :price, Float + + def initialize(props) + super( + orderId: props[:orderId], + title: props[:title], + quantity: props[:quantity], + price: props[:price], + ) + + @props = props + end + end + class ClassForNullLiteral < T::Struct + include Baml::Sorbet::Struct + const :a, String + + def initialize(props) + super( + a: props[:a], + ) + + @props = props + end + end + class ClassOptionalOutput < T::Struct + include Baml::Sorbet::Struct + const :prop1, String + const :prop2, String + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class ClassOptionalOutput2 < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.nilable(String) + const :prop2, T.nilable(String) + const :prop3, T.nilable(Baml::Types::Blah) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + prop3: props[:prop3], + ) + + @props = props + end + end + class ClassToRecAlias < T::Struct + include Baml::Sorbet::Struct + const :list, Baml::Types::LinkedListAliasNode + + def initialize(props) + super( + list: props[:list], + ) + + @props = props + end + end + class ClassWithBlockDone < T::Struct + include Baml::Sorbet::Struct + const :i_16_digits, Integer + const :s_20_words, String + + def initialize(props) + super( + i_16_digits: props[:i_16_digits], + s_20_words: props[:s_20_words], + ) + + @props = props + end + end + class ClassWithImage < T::Struct + include Baml::Sorbet::Struct + const :myImage, Baml::Image + const :param2, String + const :fake_image, Baml::Types::FakeImage + + def initialize(props) + super( + myImage: props[:myImage], + param2: props[:param2], + fake_image: props[:fake_image], + ) + + @props = props + end + end + class ClassWithoutDone < T::Struct + include Baml::Sorbet::Struct + const :i_16_digits, Integer + const :s_20_words, String + + def initialize(props) + super( + i_16_digits: props[:i_16_digits], + s_20_words: props[:s_20_words], + ) + + @props = props + end + end + class ComplexMemoryObject < T::Struct + include Baml::Sorbet::Struct + const :id, String + const :name, String + const :description, String + const :metadata, T::Array[T.any(String, Integer, Float)] + + def initialize(props) + super( + id: props[:id], + name: props[:name], + description: props[:description], + metadata: props[:metadata], + ) + + @props = props + end + end + class CompoundBigNumbers < T::Struct + include Baml::Sorbet::Struct + const :big, Baml::Types::BigNumbers + const :big_nums, T::Array[Baml::Types::BigNumbers] + const :another, Baml::Types::BigNumbers + + def initialize(props) + super( + big: props[:big], + big_nums: props[:big_nums], + another: props[:another], + ) + + @props = props + end + end + class ContactInfo < T::Struct + include Baml::Sorbet::Struct + const :primary, T.any(Baml::Types::PhoneNumber, Baml::Types::EmailAddress) + const :secondary, T.any(Baml::Types::PhoneNumber, Baml::Types::EmailAddress, NilClass) + + def initialize(props) + super( + primary: props[:primary], + secondary: props[:secondary], + ) + + @props = props + end + end + class CustomTaskResult < T::Struct + include Baml::Sorbet::Struct + const :bookOrder, T.any(Baml::Types::BookOrder, T.nilable(NilClass)) + const :flightConfirmation, T.any(Baml::Types::FlightConfirmation, T.nilable(NilClass)) + const :groceryReceipt, T.any(Baml::Types::GroceryReceipt, T.nilable(NilClass)) + + def initialize(props) + super( + bookOrder: props[:bookOrder], + flightConfirmation: props[:flightConfirmation], + groceryReceipt: props[:groceryReceipt], + ) + + @props = props + end + end + class DummyOutput < T::Struct + include Baml::Sorbet::Struct + const :nonce, String + const :nonce2, String + + def initialize(props) + super( + nonce: props[:nonce], + nonce2: props[:nonce2], + ) + + @props = props + end + end + class DynInputOutput < T::Struct + include Baml::Sorbet::Struct + const :testKey, String + + def initialize(props) + super( + testKey: props[:testKey], + ) + + @props = props + end + end + class DynamicClassOne < T::Struct + include Baml::Sorbet::Struct + + def initialize(props) + super( + ) + + @props = props + end + end + class DynamicClassTwo < T::Struct + include Baml::Sorbet::Struct + const :hi, String + const :some_class, Baml::Types::SomeClassNestedDynamic + const :status, T.any(Baml::Types::DynEnumOne, String) + + def initialize(props) + super( + hi: props[:hi], + some_class: props[:some_class], + status: props[:status], + ) + + @props = props + end + end + class DynamicOutput < T::Struct + include Baml::Sorbet::Struct + + def initialize(props) + super( + ) + + @props = props + end + end + class Earthling < T::Struct + include Baml::Sorbet::Struct + const :age, Baml::Checked[Integer] + + def initialize(props) + super( + age: props[:age], + ) + + @props = props + end + end + class Education < T::Struct + include Baml::Sorbet::Struct + const :institution, String + const :location, String + const :degree, String + const :major, T::Array[String] + const :graduation_date, T.nilable(String) + + def initialize(props) + super( + institution: props[:institution], + location: props[:location], + degree: props[:degree], + major: props[:major], + graduation_date: props[:graduation_date], + ) + + @props = props + end + end + class Email < T::Struct + include Baml::Sorbet::Struct + const :subject, String + const :body, String + const :from_address, String + + def initialize(props) + super( + subject: props[:subject], + body: props[:body], + from_address: props[:from_address], + ) + + @props = props + end + end + class EmailAddress < T::Struct + include Baml::Sorbet::Struct + const :value, String + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class Event < T::Struct + include Baml::Sorbet::Struct + const :title, String + const :date, String + const :location, String + const :description, String + + def initialize(props) + super( + title: props[:title], + date: props[:date], + location: props[:location], + description: props[:description], + ) + + @props = props + end + end + class FakeImage < T::Struct + include Baml::Sorbet::Struct + const :url, String + + def initialize(props) + super( + url: props[:url], + ) + + @props = props + end + end + class FlightConfirmation < T::Struct + include Baml::Sorbet::Struct + const :confirmationNumber, String + const :flightNumber, String + const :departureTime, String + const :arrivalTime, String + const :seatNumber, String + + def initialize(props) + super( + confirmationNumber: props[:confirmationNumber], + flightNumber: props[:flightNumber], + departureTime: props[:departureTime], + arrivalTime: props[:arrivalTime], + seatNumber: props[:seatNumber], + ) + + @props = props + end + end + class FooAny < T::Struct + include Baml::Sorbet::Struct + const :planetary_age, T.any(Baml::Types::Martian, Baml::Types::Earthling) + const :certainty, Baml::Checked[Integer] + const :species, Baml::Checked[String] + + def initialize(props) + super( + planetary_age: props[:planetary_age], + certainty: props[:certainty], + species: props[:species], + ) + + @props = props + end + end + class Forest < T::Struct + include Baml::Sorbet::Struct + const :trees, T::Array[Baml::Types::Tree] + + def initialize(props) + super( + trees: props[:trees], + ) + + @props = props + end + end + class FormatterTest0 < T::Struct + include Baml::Sorbet::Struct + const :lorem, String + const :ipsum, String + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class FormatterTest1 < T::Struct + include Baml::Sorbet::Struct + const :lorem, String + const :ipsum, String + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class FormatterTest2 < T::Struct + include Baml::Sorbet::Struct + const :lorem, String + const :ipsum, String + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class FormatterTest3 < T::Struct + include Baml::Sorbet::Struct + const :lorem, String + const :ipsum, String + + def initialize(props) + super( + lorem: props[:lorem], + ipsum: props[:ipsum], + ) + + @props = props + end + end + class GroceryReceipt < T::Struct + include Baml::Sorbet::Struct + const :receiptId, String + const :storeName, String + const :items, T::Array[T.any(String, Integer, Float)] + const :totalAmount, Float + + def initialize(props) + super( + receiptId: props[:receiptId], + storeName: props[:storeName], + items: props[:items], + totalAmount: props[:totalAmount], + ) + + @props = props + end + end + class InnerClass < T::Struct + include Baml::Sorbet::Struct + const :prop1, String + const :prop2, String + const :inner, Baml::Types::InnerClass2 + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + inner: props[:inner], + ) + + @props = props + end + end + class InnerClass2 < T::Struct + include Baml::Sorbet::Struct + const :prop2, Integer + const :prop3, Float + + def initialize(props) + super( + prop2: props[:prop2], + prop3: props[:prop3], + ) + + @props = props + end + end + class InputClass < T::Struct + include Baml::Sorbet::Struct + const :key, String + const :key2, String + + def initialize(props) + super( + key: props[:key], + key2: props[:key2], + ) + + @props = props + end + end + class InputClassNested < T::Struct + include Baml::Sorbet::Struct + const :key, String + const :nested, Baml::Types::InputClass + + def initialize(props) + super( + key: props[:key], + nested: props[:nested], + ) + + @props = props + end + end + class LinkedList < T::Struct + include Baml::Sorbet::Struct + const :head, T.nilable(Baml::Types::Node) + const :len, Integer + + def initialize(props) + super( + head: props[:head], + len: props[:len], + ) + + @props = props + end + end + class LinkedListAliasNode < T::Struct + include Baml::Sorbet::Struct + const :value, Integer + const :next, T.nilable(Baml::Types::LinkedListAliasNode) + + def initialize(props) + super( + value: props[:value], + next: props[:next], + ) + + @props = props + end + end + class LiteralClassHello < T::Struct + include Baml::Sorbet::Struct + const :prop, String + + def initialize(props) + super( + prop: props[:prop], + ) + + @props = props + end + end + class LiteralClassOne < T::Struct + include Baml::Sorbet::Struct + const :prop, String + + def initialize(props) + super( + prop: props[:prop], + ) + + @props = props + end + end + class LiteralClassTwo < T::Struct + include Baml::Sorbet::Struct + const :prop, String + + def initialize(props) + super( + prop: props[:prop], + ) + + @props = props + end + end + class MalformedConstraints < T::Struct + include Baml::Sorbet::Struct + const :foo, Baml::Checked[Integer] + + def initialize(props) + super( + foo: props[:foo], + ) + + @props = props + end + end + class MalformedConstraints2 < T::Struct + include Baml::Sorbet::Struct + const :foo, Integer + + def initialize(props) + super( + foo: props[:foo], + ) + + @props = props + end + end + # A Martian organism with an age. + # Such a nice type. + class Martian < T::Struct + include Baml::Sorbet::Struct + # The age of the Martian in Mars years. + # So many Mars years. + const :age, Baml::Checked[Integer] + + def initialize(props) + super( + age: props[:age], + ) + + @props = props + end + end + class MemoryObject < T::Struct + include Baml::Sorbet::Struct + const :id, String + const :name, String + const :description, String + + def initialize(props) + super( + id: props[:id], + name: props[:name], + description: props[:description], + ) + + @props = props + end + end + class MergeAttrs < T::Struct + include Baml::Sorbet::Struct + const :amount, Baml::Checked[Integer] + + def initialize(props) + super( + amount: props[:amount], + ) + + @props = props + end + end + class NamedArgsSingleClass < T::Struct + include Baml::Sorbet::Struct + const :key, String + const :key_two, T::Boolean + const :key_three, Integer + + def initialize(props) + super( + key: props[:key], + key_two: props[:key_two], + key_three: props[:key_three], + ) + + @props = props + end + end + class Nested < T::Struct + include Baml::Sorbet::Struct + const :prop3, T.any(String, T.nilable(NilClass)) + const :prop4, T.any(String, T.nilable(NilClass)) + const :prop20, Baml::Types::Nested2 + + def initialize(props) + super( + prop3: props[:prop3], + prop4: props[:prop4], + prop20: props[:prop20], + ) + + @props = props + end + end + class Nested2 < T::Struct + include Baml::Sorbet::Struct + const :prop11, T.any(String, T.nilable(NilClass)) + const :prop12, T.any(String, T.nilable(NilClass)) + + def initialize(props) + super( + prop11: props[:prop11], + prop12: props[:prop12], + ) + + @props = props + end + end + class NestedBlockConstraint < T::Struct + include Baml::Sorbet::Struct + const :nbc, Baml::Checked[Baml::Types::BlockConstraint] + + def initialize(props) + super( + nbc: props[:nbc], + ) + + @props = props + end + end + class NestedBlockConstraintForParam < T::Struct + include Baml::Sorbet::Struct + const :nbcfp, Baml::Types::BlockConstraintForParam + + def initialize(props) + super( + nbcfp: props[:nbcfp], + ) + + @props = props + end + end + class Node < T::Struct + include Baml::Sorbet::Struct + const :data, Integer + const :next, T.nilable(Baml::Types::Node) + + def initialize(props) + super( + data: props[:data], + next: props[:next], + ) + + @props = props + end + end + class NodeWithAliasIndirection < T::Struct + include Baml::Sorbet::Struct + const :value, Integer + const :next, T.nilable(Baml::Types::NodeWithAliasIndirection) + + def initialize(props) + super( + value: props[:value], + next: props[:next], + ) + + @props = props + end + end + class OptionalListAndMap < T::Struct + include Baml::Sorbet::Struct + const :p, T.nilable(T::Array[String]) + const :q, T.nilable(T::Hash[String, String]) + + def initialize(props) + super( + p: props[:p], + q: props[:q], + ) + + @props = props + end + end + class OptionalTest_Prop1 < T::Struct + include Baml::Sorbet::Struct + const :omega_a, String + const :omega_b, Integer + + def initialize(props) + super( + omega_a: props[:omega_a], + omega_b: props[:omega_b], + ) + + @props = props + end + end + class OptionalTest_ReturnType < T::Struct + include Baml::Sorbet::Struct + const :omega_1, T.nilable(Baml::Types::OptionalTest_Prop1) + const :omega_2, T.nilable(String) + const :omega_3, T::Array[T.nilable(T.any(Baml::Types::OptionalTest_CategoryType, String))] + + def initialize(props) + super( + omega_1: props[:omega_1], + omega_2: props[:omega_2], + omega_3: props[:omega_3], + ) + + @props = props + end + end + class OrderInfo < T::Struct + include Baml::Sorbet::Struct + const :order_status, T.any(Baml::Types::OrderStatus, String) + const :tracking_number, T.nilable(String) + const :estimated_arrival_date, T.nilable(String) + + def initialize(props) + super( + order_status: props[:order_status], + tracking_number: props[:tracking_number], + estimated_arrival_date: props[:estimated_arrival_date], + ) + + @props = props + end + end + class OriginalA < T::Struct + include Baml::Sorbet::Struct + const :value, Integer + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class OriginalB < T::Struct + include Baml::Sorbet::Struct + const :value, Integer + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class Person < T::Struct + include Baml::Sorbet::Struct + const :name, T.nilable(String) + const :hair_color, T.nilable(T.any(Baml::Types::Color, String)) + + def initialize(props) + super( + name: props[:name], + hair_color: props[:hair_color], + ) + + @props = props + end + end + class PhoneNumber < T::Struct + include Baml::Sorbet::Struct + const :value, String + + def initialize(props) + super( + value: props[:value], + ) + + @props = props + end + end + class Quantity < T::Struct + include Baml::Sorbet::Struct + const :amount, T.any(Integer, Float) + const :unit, T.nilable(String) + + def initialize(props) + super( + amount: props[:amount], + unit: props[:unit], + ) + + @props = props + end + end + class RaysData < T::Struct + include Baml::Sorbet::Struct + const :dataType, T.any(Baml::Types::DataType, String) + const :value, T.any(Baml::Types::Resume, Baml::Types::Event) + + def initialize(props) + super( + dataType: props[:dataType], + value: props[:value], + ) + + @props = props + end + end + class ReceiptInfo < T::Struct + include Baml::Sorbet::Struct + const :items, T::Array[Baml::Types::ReceiptItem] + const :total_cost, T.nilable(Float) + const :venue, T.any(String, String) + + def initialize(props) + super( + items: props[:items], + total_cost: props[:total_cost], + venue: props[:venue], + ) + + @props = props + end + end + class ReceiptItem < T::Struct + include Baml::Sorbet::Struct + const :name, String + const :description, T.nilable(String) + const :quantity, Integer + const :price, Float + + def initialize(props) + super( + name: props[:name], + description: props[:description], + quantity: props[:quantity], + price: props[:price], + ) + + @props = props + end + end + class Recipe < T::Struct + include Baml::Sorbet::Struct + const :ingredients, T::Hash[String, Baml::Types::Quantity] + const :recipe_type, T.any(String, String) + + def initialize(props) + super( + ingredients: props[:ingredients], + recipe_type: props[:recipe_type], + ) + + @props = props + end + end + class Resume < T::Struct + include Baml::Sorbet::Struct + const :name, String + const :email, String + const :phone, String + const :experience, T::Array[Baml::Types::Education] + const :education, T::Array[String] + const :skills, T::Array[String] + + def initialize(props) + super( + name: props[:name], + email: props[:email], + phone: props[:phone], + experience: props[:experience], + education: props[:education], + skills: props[:skills], + ) + + @props = props + end + end + class Schema < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.any(String, T.nilable(NilClass)) + const :prop2, T.any(Baml::Types::Nested, String) + const :prop5, T::Array[T.any(String, T.nilable(NilClass))] + const :prop6, T.any(String, T::Array[Baml::Types::Nested]) + const :nested_attrs, T::Array[T.any(String, T.nilable(NilClass), Baml::Types::Nested)] + const :parens, T.any(String, T.nilable(NilClass)) + const :other_group, T.any(String, T.any(Integer, String)) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + prop5: props[:prop5], + prop6: props[:prop6], + nested_attrs: props[:nested_attrs], + parens: props[:parens], + other_group: props[:other_group], + ) + + @props = props + end + end + class SearchParams < T::Struct + include Baml::Sorbet::Struct + const :dateRange, T.nilable(Integer) + const :location, T::Array[String] + const :jobTitle, T.nilable(Baml::Types::WithReasoning) + const :company, T.nilable(Baml::Types::WithReasoning) + const :description, T::Array[Baml::Types::WithReasoning] + const :tags, T::Array[T.any(T.any(Baml::Types::Tag, String), String)] + + def initialize(props) + super( + dateRange: props[:dateRange], + location: props[:location], + jobTitle: props[:jobTitle], + company: props[:company], + description: props[:description], + tags: props[:tags], + ) + + @props = props + end + end + class SemanticContainer < T::Struct + include Baml::Sorbet::Struct + const :sixteen_digit_number, Integer + const :string_with_twenty_words, String + const :class_1, Baml::Types::ClassWithoutDone + const :class_2, Baml::Types::ClassWithBlockDone + const :class_done_needed, Baml::Types::ClassWithBlockDone + const :class_needed, Baml::Types::ClassWithoutDone + const :three_small_things, T::Array[Baml::Types::SmallThing] + const :final_string, String + + def initialize(props) + super( + sixteen_digit_number: props[:sixteen_digit_number], + string_with_twenty_words: props[:string_with_twenty_words], + class_1: props[:class_1], + class_2: props[:class_2], + class_done_needed: props[:class_done_needed], + class_needed: props[:class_needed], + three_small_things: props[:three_small_things], + final_string: props[:final_string], + ) + + @props = props + end + end + class SmallThing < T::Struct + include Baml::Sorbet::Struct + const :i_16_digits, Integer + const :i_8_digits, Integer + + def initialize(props) + super( + i_16_digits: props[:i_16_digits], + i_8_digits: props[:i_8_digits], + ) + + @props = props + end + end + class SomeClassNestedDynamic < T::Struct + include Baml::Sorbet::Struct + const :hi, String + + def initialize(props) + super( + hi: props[:hi], + ) + + @props = props + end + end + class StringToClassEntry < T::Struct + include Baml::Sorbet::Struct + const :word, String + + def initialize(props) + super( + word: props[:word], + ) + + @props = props + end + end + class TestClassAlias < T::Struct + include Baml::Sorbet::Struct + const :key, String + const :key2, String + const :key3, String + const :key4, String + const :key5, String + + def initialize(props) + super( + key: props[:key], + key2: props[:key2], + key3: props[:key3], + key4: props[:key4], + key5: props[:key5], + ) + + @props = props + end + end + class TestClassNested < T::Struct + include Baml::Sorbet::Struct + const :prop1, String + const :prop2, Baml::Types::InnerClass + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class TestClassWithEnum < T::Struct + include Baml::Sorbet::Struct + const :prop1, String + const :prop2, T.any(Baml::Types::EnumInClass, String) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class TestMemoryOutput < T::Struct + include Baml::Sorbet::Struct + const :items, T::Array[T.any(Baml::Types::MemoryObject, Baml::Types::ComplexMemoryObject, Baml::Types::AnotherObject)] + const :more_items, T::Array[T.any(Baml::Types::MemoryObject, Baml::Types::ComplexMemoryObject, Baml::Types::AnotherObject)] + + def initialize(props) + super( + items: props[:items], + more_items: props[:more_items], + ) + + @props = props + end + end + class TestOutputClass < T::Struct + include Baml::Sorbet::Struct + const :prop1, String + const :prop2, Integer + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + ) + + @props = props + end + end + class Tree < T::Struct + include Baml::Sorbet::Struct + const :data, Integer + const :children, Baml::Types::Forest + + def initialize(props) + super( + data: props[:data], + children: props[:children], + ) + + @props = props + end + end + class TwoStoriesOneTitle < T::Struct + include Baml::Sorbet::Struct + const :title, String + const :story_a, String + const :story_b, String + + def initialize(props) + super( + title: props[:title], + story_a: props[:story_a], + story_b: props[:story_b], + ) + + @props = props + end + end + class UnionTest_ReturnType < T::Struct + include Baml::Sorbet::Struct + const :prop1, T.any(String, T::Boolean) + const :prop2, T::Array[T.any(Float, T::Boolean)] + const :prop3, T.any(T::Array[T::Boolean], T::Array[Integer]) + + def initialize(props) + super( + prop1: props[:prop1], + prop2: props[:prop2], + prop3: props[:prop3], + ) + + @props = props + end + end + class UniverseQuestion < T::Struct + include Baml::Sorbet::Struct + const :question, String + const :answer, String + + def initialize(props) + super( + question: props[:question], + answer: props[:answer], + ) + + @props = props + end + end + class UniverseQuestionInput < T::Struct + include Baml::Sorbet::Struct + const :question, String + + def initialize(props) + super( + question: props[:question], + ) + + @props = props + end + end + class WithReasoning < T::Struct + include Baml::Sorbet::Struct + const :value, String + const :reasoning, String + + def initialize(props) + super( + value: props[:value], + reasoning: props[:reasoning], + ) + + @props = props + end + end + + end +end \ No newline at end of file diff --git a/integ-tests/typescript/baml_client/async_client.ts b/integ-tests/typescript/baml_client/async_client.ts index 8f49a32d0..5b8695842 100644 --- a/integ-tests/typescript/baml_client/async_client.ts +++ b/integ-tests/typescript/baml_client/async_client.ts @@ -18,19 +18,10 @@ $ pnpm add @boundaryml/baml import { BamlRuntime, FunctionResult, BamlCtxManager, BamlStream, Image, ClientRegistry, BamlValidationError, createBamlValidationError } from "@boundaryml/baml" import { Checked, Check } from "./types" import "./partial_types" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" +import {AnotherObject, BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, ComplexMemoryObject, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MemoryObject, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestMemoryOutput, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" import TypeBuilder from "./type_builder" import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME } from "./globals" -/** - * @deprecated Use RecursivePartialNull from 'baml_client/types' instead. - */ -export type RecursivePartialNull = T extends object - ? { - [P in keyof T]?: RecursivePartialNull; - } - : T | null; - export class BamlAsyncClient { private runtime: BamlRuntime private ctx_manager: BamlCtxManager @@ -3222,6 +3213,31 @@ export class BamlAsyncClient { } } + async TestMemory( + input: string, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): Promise { + try { + const raw = await this.runtime.callFunction( + "TestMemory", + { + "input": input + }, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return raw.parsed(false) as TestMemoryOutput + } catch (error: any) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } else { + throw error; + } + } + } + async TestMulticlassNamedArgs( myArg: NamedArgsSingleClass,myArg2: NamedArgsSingleClass, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } @@ -3472,31 +3488,6 @@ export class BamlAsyncClient { } } - async TestUniverseQuestion( - question: UniverseQuestionInput, - __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } - ): Promise { - try { - const raw = await this.runtime.callFunction( - "TestUniverseQuestion", - { - "question": question - }, - this.ctx_manager.cloneContext(), - __baml_options__?.tb?.__tb(), - __baml_options__?.clientRegistry, - ) - return raw.parsed(false) as UniverseQuestion - } catch (error: any) { - const bamlError = createBamlValidationError(error); - if (bamlError instanceof BamlValidationError) { - throw bamlError; - } else { - throw error; - } - } - } - async TestVertex( input: string, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } @@ -7844,6 +7835,39 @@ class BamlStreamClient { } } + TestMemory( + input: string, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): BamlStream { + try { + const raw = this.runtime.streamFunction( + "TestMemory", + { + "input": input + }, + undefined, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return new BamlStream( + raw, + (a): a is partial_types.TestMemoryOutput => a, + (a): a is TestMemoryOutput => a, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + ) + } catch (error) { + if (error instanceof Error) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } + } + throw error; + } + } + TestMulticlassNamedArgs( myArg: NamedArgsSingleClass,myArg2: NamedArgsSingleClass, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } @@ -8174,39 +8198,6 @@ class BamlStreamClient { } } - TestUniverseQuestion( - question: UniverseQuestionInput, - __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } - ): BamlStream { - try { - const raw = this.runtime.streamFunction( - "TestUniverseQuestion", - { - "question": question - }, - undefined, - this.ctx_manager.cloneContext(), - __baml_options__?.tb?.__tb(), - __baml_options__?.clientRegistry, - ) - return new BamlStream( - raw, - (a): a is partial_types.UniverseQuestion => a, - (a): a is UniverseQuestion => a, - this.ctx_manager.cloneContext(), - __baml_options__?.tb?.__tb(), - ) - } catch (error) { - if (error instanceof Error) { - const bamlError = createBamlValidationError(error); - if (bamlError instanceof BamlValidationError) { - throw bamlError; - } - } - throw error; - } - } - TestVertex( input: string, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } diff --git a/integ-tests/typescript/baml_client/globals.ts b/integ-tests/typescript/baml_client/globals.ts new file mode 100644 index 000000000..00b093019 --- /dev/null +++ b/integ-tests/typescript/baml_client/globals.ts @@ -0,0 +1,37 @@ +/************************************************************************************************* + +Welcome to Baml! To use this generated code, please run one of the following: + +$ npm install @boundaryml/baml +$ yarn add @boundaryml/baml +$ pnpm add @boundaryml/baml + +*************************************************************************************************/ + +// This file was generated by BAML: do not edit it. Instead, edit the BAML +// files and re-generate this code. +// +/* eslint-disable */ +// tslint:disable +// @ts-nocheck +// biome-ignore format: autogenerated code +import { BamlCtxManager, BamlRuntime } from '@boundaryml/baml' +import { getBamlFiles } from './inlinedbaml' + + +export const DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME = BamlRuntime.fromFiles( + 'baml_src', + getBamlFiles(), + process.env +) +export const DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX = new BamlCtxManager(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME) + + +export function resetBamlEnvVars(envVars: Record) { + if (DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.allowResets()) { + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME.reset('baml_src', getBamlFiles(), envVars) + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.reset() + } else { + throw new Error('BamlError: Cannot reset BAML environment variables while there are active BAML contexts.') + } +} \ No newline at end of file diff --git a/integ-tests/typescript/baml_client/index.ts b/integ-tests/typescript/baml_client/index.ts new file mode 100644 index 000000000..6fc0cb7ab --- /dev/null +++ b/integ-tests/typescript/baml_client/index.ts @@ -0,0 +1,24 @@ +/************************************************************************************************* + +Welcome to Baml! To use this generated code, please run one of the following: + +$ npm install @boundaryml/baml +$ yarn add @boundaryml/baml +$ pnpm add @boundaryml/baml + +*************************************************************************************************/ + +// This file was generated by BAML: do not edit it. Instead, edit the BAML +// files and re-generate this code. +// +/* eslint-disable */ +// tslint:disable +// @ts-nocheck +// biome-ignore format: autogenerated code + +export { b } from "./async_client" + +export * from "./types" +export * from "./tracing" +export { resetBamlEnvVars } from "./globals" +export { BamlValidationError } from "@boundaryml/baml" \ No newline at end of file diff --git a/integ-tests/typescript/baml_client/inlinedbaml.ts b/integ-tests/typescript/baml_client/inlinedbaml.ts index af238d609..0cdddaf8b 100644 --- a/integ-tests/typescript/baml_client/inlinedbaml.ts +++ b/integ-tests/typescript/baml_client/inlinedbaml.ts @@ -27,7 +27,7 @@ const fileMap = { "fiddle-examples/images/image.baml": "function DescribeImage(img: image) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\") }}\n\n\n Describe the image below in 20 words:\n {{ img }}\n \"#\n\n}\n\nclass FakeImage {\n url string\n}\n\nclass ClassWithImage {\n myImage image\n param2 string\n fake_image FakeImage\n}\n\n// chat role user present\nfunction DescribeImage2(classWithImage: ClassWithImage, img2: image) -> string { \n client GPT4Turbo\n prompt #\"\n {{ _.role(\"user\") }}\n You should return 2 answers that answer the following commands.\n\n 1. Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n 2. Also tell me what's happening here in one sentence:\n {{ img2 }}\n \"#\n}\n\n// no chat role\nfunction DescribeImage3(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\n\n// system prompt and chat prompt\nfunction DescribeImage4(classWithImage: ClassWithImage, img2: image) -> string {\n client GPT4Turbo\n prompt #\"\n {{ _.role(\"system\")}}\n\n Describe this in 5 words:\n {{ classWithImage.myImage }}\n\n Tell me also what's happening here in one sentence and relate it to the word {{ classWithImage.param2 }}:\n {{ img2 }}\n \"#\n}\n\ntest TestName {\n functions [DescribeImage]\n args {\n img { url \"https://imgs.xkcd.com/comics/standards.png\"}\n }\n}\n", "fiddle-examples/symbol-tuning.baml": "enum Category3 {\n Refund @alias(\"k1\")\n @description(\"Customer wants to refund a product\")\n\n CancelOrder @alias(\"k2\")\n @description(\"Customer wants to cancel an order\")\n\n TechnicalSupport @alias(\"k3\")\n @description(\"Customer needs help with a technical issue unrelated to account creation or login\")\n\n AccountIssue @alias(\"k4\")\n @description(\"Specifically relates to account-login or account-creation\")\n\n Question @alias(\"k5\")\n @description(\"Customer has a question\")\n}\n\nfunction ClassifyMessage3(input: string) -> Category {\n client GPT4\n\n prompt #\"\n Classify the following INPUT into ONE\n of the following categories:\n\n INPUT: {{ input }}\n\n {{ ctx.output_format }}\n\n Response:\n \"#\n}", "formatter/test-comments.baml": "class FormatterTest0 {\n lorem string // trailing comments should be preserved\n ipsum string\n}\n\nclass FormatterTest1 {\n lorem string\n ipsum string\n // dolor string\n}\n\nclass FormatterTest2 {\n // \"lorem\" is a latin word\n lorem string\n // \"ipsum\" is a latin word\n ipsum string\n}\n\nclass FormatterTest3 {\n lorem string\n ipsum string\n // Lorem ipsum dolor sit amet\n // Consectetur adipiscing elit\n // Sed do eiusmod tempor incididunt\n // Ut labore et dolore magna aliqua\n // Ut enim ad minim veniam\n}", - "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.73.5\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.73.5\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.73.5\"\n}\n", + "generators.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.74.0\"\n}\n\ngenerator lang_typescript_react {\n output_type typescript/react\n output_dir \"../react\"\n version \"0.74.0\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.74.0\"\n}\n\ngenerator openapi {\n output_type rest/openapi\n output_dir \"../openapi\"\n version \"0.74.0\"\n on_generate \"rm .gitignore\"\n}", "test-files/aliases/aliased-inputs.baml": "\nclass InputClass {\n key string @alias(\"color\")\n key2 string\n}\n\n\nclass InputClassNested {\n key string\n nested InputClass @alias(\"interesting-key\")\n}\n \n\nfunction AliasedInputClass(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {{input}}\n\n This is a test. What's the name of the first json key above? Remember, tell me the key, not value.\n \"#\n}\n \nfunction AliasedInputClass2(input: InputClass) -> string {\n client GPT35\n prompt #\"\n\n {# making sure we can still access the original key #}\n {%if input.key == \"tiger\"%}\n Repeat this value back to me, and nothing else: {{input.key}}\n {%endif%}\n \"#\n}\n \n function AliasedInputClassNested(input: InputClassNested) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n\n {{input}}\n\n This is a test. What's the name of the second json key above? Remember, tell me the key, not value.\n \"#\n }\n\n\nenum AliasedEnum {\n KEY_ONE @alias(\"tiger\")\n KEY_TWO\n}\n\nfunction AliasedInputEnum(input: AliasedEnum) -> string {\n client GPT4o\n prompt #\"\n {{ _.role(\"user\")}}\n\n\n Write out this word only in your response, in lowercase:\n ---\n {{input}}\n ---\n Answer:\n \"#\n}\n\n\nfunction AliasedInputList(input: AliasedEnum[]) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"user\")}}\n Given this array:\n ---\n {{input}}\n ---\n\n Return the first element in the array:\n \"#\n}\n\n", "test-files/aliases/classes.baml": "class TestClassAlias {\n key string @alias(\"key-dash\") @description(#\"\n This is a description for key\n af asdf\n \"#)\n key2 string @alias(\"key21\")\n key3 string @alias(\"key with space\")\n key4 string //unaliased\n key5 string @alias(\"key.with.punctuation/123\")\n}\n\nfunction FnTestClassAlias(input: string) -> TestClassAlias {\n client GPT35\n prompt #\"\n {{ctx.output_format}}\n \"#\n}\n\ntest FnTestClassAlias {\n functions [FnTestClassAlias]\n args {\n input \"example input\"\n }\n}\n", "test-files/aliases/enums.baml": "enum TestEnum {\n A @alias(\"k1\") @description(#\"\n User is angry\n \"#)\n B @alias(\"k22\") @description(#\"\n User is happy\n \"#)\n // tests whether k1 doesnt incorrectly get matched with k11\n C @alias(\"k11\") @description(#\"\n User is sad\n \"#)\n D @alias(\"k44\") @description(\n User is confused\n )\n E @description(\n User is excited\n )\n F @alias(\"k5\") // only alias\n \n G @alias(\"k6\") @description(#\"\n User is bored\n With a long description\n \"#)\n \n @@alias(\"Category\")\n}\n\nfunction FnTestAliasedEnumOutput(input: string) -> TestEnum {\n client GPT35\n prompt #\"\n Classify the user input into the following category\n \n {{ ctx.output_format }}\n\n {{ _.role('user') }}\n {{input}}\n\n {{ _.role('assistant') }}\n Category ID:\n \"#\n}\n\ntest FnTestAliasedEnumOutput {\n functions [FnTestAliasedEnumOutput]\n args {\n input \"mehhhhh\"\n }\n}", @@ -92,6 +92,7 @@ const fileMap = { "test-files/functions/prompts/no-chat-messages.baml": "\n\nfunction PromptTestClaude(input: string) -> string {\n client Sonnet\n prompt #\"\n Tell me a haiku about {{ input }}\n \"#\n}\n\n\nfunction PromptTestStreaming(input: string) -> string {\n client GPT35\n prompt #\"\n Tell me a short story about {{ input }}\n \"#\n}\n\ntest TestName {\n functions [PromptTestStreaming]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/functions/prompts/with-chat-messages.baml": "\nfunction PromptTestOpenAIChat(input: string) -> string {\n client GPT35\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestOpenAIChatNoSystem(input: string) -> string {\n client GPT35\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChat(input: string) -> string {\n client Claude\n prompt #\"\n {{ _.role(\"system\") }}\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\nfunction PromptTestClaudeChatNoSystem(input: string) -> string {\n client Claude\n prompt #\"\n You are an assistant that always responds in a very excited way with emojis and also outputs this word 4 times after giving a response: {{ input }}\n \n {{ _.role(\"user\") }}\n Tell me a haiku about {{ input }}\n \"#\n}\n\ntest TestSystemAndNonSystemChat1 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"cats\"\n }\n}\n\ntest TestSystemAndNonSystemChat2 {\n functions [PromptTestClaude, PromptTestOpenAI, PromptTestOpenAIChat, PromptTestOpenAIChatNoSystem, PromptTestClaudeChat, PromptTestClaudeChatNoSystem]\n args {\n input \"lion\"\n }\n}", "test-files/functions/v2/basic.baml": "\n\nfunction ExtractResume2(resume: string) -> Resume {\n client GPT4\n prompt #\"\n {{ _.role('system') }}\n\n Extract the following information from the resume:\n\n Resume:\n <<<<\n {{ resume }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}\n\n\nclass WithReasoning {\n value string\n reasoning string @description(#\"\n Why the value is a good fit.\n \"#)\n}\n\n\nclass SearchParams {\n dateRange int? @description(#\"\n In ISO duration format, e.g. P1Y2M10D.\n \"#)\n location string[]\n jobTitle WithReasoning? @description(#\"\n An exact job title, not a general category.\n \"#)\n company WithReasoning? @description(#\"\n The exact name of the company, not a product or service.\n \"#)\n description WithReasoning[] @description(#\"\n Any specific projects or features the user is looking for.\n \"#)\n tags (Tag | string)[]\n}\n\nenum Tag {\n Security\n AI\n Blockchain\n}\n\nfunction GetQuery(query: string) -> SearchParams {\n client GPT4\n prompt #\"\n Extract the following information from the query:\n\n Query:\n <<<<\n {{ query }}\n <<<<\n\n OUTPUT_JSON_SCHEMA:\n {{ ctx.output_format }}\n\n Before OUTPUT_JSON_SCHEMA, list 5 intentions the user may have.\n --- EXAMPLES ---\n 1. \n 2. \n 3. \n 4. \n 5. \n\n {\n ... // OUTPUT_JSON_SCHEMA\n }\n \"#\n}\n\nclass RaysData {\n dataType DataType\n value Resume | Event\n}\n\nenum DataType {\n Resume\n Event\n}\n\nclass Event {\n title string\n date string\n location string\n description string\n}\n\nfunction GetDataType(text: string) -> RaysData {\n client GPT4\n prompt #\"\n Extract the relevant info.\n\n Text:\n <<<<\n {{ text }}\n <<<<\n\n Output JSON schema:\n {{ ctx.output_format }}\n\n JSON:\n \"#\n}", + "test-files/load-test/memory.baml": "\n\nclass MemoryObject {\n id string\n name string\n description string\n}\n\nclass ComplexMemoryObject {\n id string\n name string\n description string\n metadata (string | int | float)[] @description(#\"\n Additional metadata about the memory object, which can be a mix of types.\n \"#)\n}\n\nclass AnotherObject {\n id string\n thingy2 string\n thingy3 string\n}\n\nclass TestMemoryOutput {\n items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 10 items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n more_items (MemoryObject | ComplexMemoryObject | AnotherObject)[] @description(#\"\n Add 3 more items, which can be either simple MemoryObjects or more complex MemoryObjects with metadata.\n \"#)\n}\n\n\nfunction TestMemory(input: string) -> TestMemoryOutput {\n client GPT35\n prompt #\"\n Return a json blob that matches the schema:\n {{ ctx.output_format }}\n \"#\n}\n\ntest TestName {\n functions [TestMemory]\n args {\n input #\"\n hello world\n \"#\n }\n}\n", "test-files/providers/anthropic.baml": "function TestAnthropic(input: string) -> string {\n client Claude\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nfunction TestAnthropicShorthand(input: string) -> string {\n client \"anthropic/claude-3-haiku-20240307\"\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestCaching(input: string, not_cached: string) -> string {\n client ClaudeWithCaching\n prompt #\"\n {{ _.role('system', cache_control={\"type\": \"ephemeral\"}) }}\n Generate the following story\n {{ input }}\n\n {# Haiku require 2048 tokens to cache -#}\n {{ input }}\n\n {{ _.role('user') }}\n {{ not_cached }}\n \"#\n}", "test-files/providers/aws.baml": "function TestAws(input: string) -> string {\n client AwsBedrock\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nclass UniverseQuestion {\n question string\n answer string\n}\n\nclass UniverseQuestionInput {\n question string\n}\n\nfunction TestUniverseQuestion(question: UniverseQuestionInput) -> UniverseQuestion {\n client AwsBedrock\n prompt #\"\n You are a helpful assistant that answers questions about the universe.\n\n {{ ctx.output_format }}\n\n {{ _.role(\"user\")}}\n\n Question: {{ question }}\n\n Answer:\n \"#\n}\n\n\nfunction TestAwsInvalidRegion(input: string) -> string {\n client AwsBedrockInvalidRegion\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidAccessKey(input: string) -> string {\n client AwsBedrockInvalidAccessKey\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidProfile(input: string) -> string {\n client AwsBedrockInvalidProfile\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}\n\nfunction TestAwsInvalidSessionToken(input: string) -> string {\n client AwsBedrockInvalidSessionToken\n prompt #\"\n Write a nice short story about {{ input }}\n \"#\n}", "test-files/providers/azure.baml": "function TestAzure(input: string) -> string {\n client GPT35Azure\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}\n\nclient GPT35AzureFailed {\n provider azure-openai\n options {\n resource_name \"west-us-azure-baml-incorrect-suffix\"\n deployment_id \"gpt-35-turbo-default\"\n api_key env.AZURE_OPENAI_API_KEY\n }\n}\n\nfunction TestAzureFailure(input: string) -> string {\n client GPT35AzureFailed\n prompt #\"\n Write a nice haiku about {{ input }}\n \"#\n}", diff --git a/integ-tests/typescript/baml_client/partial_types.ts b/integ-tests/typescript/baml_client/partial_types.ts index 054cabbbe..cd6e87263 100644 --- a/integ-tests/typescript/baml_client/partial_types.ts +++ b/integ-tests/typescript/baml_client/partial_types.ts @@ -32,6 +32,12 @@ export interface StreamState { } +export interface AnotherObject { + id?: (string | null) + thingy2?: (string | null) + thingy3?: (string | null) +} + export interface BigNumbers { a?: (number | null) b?: (number | null) @@ -99,6 +105,13 @@ export interface ClassWithoutDone { s_20_words?: StreamState<(string | null)> } +export interface ComplexMemoryObject { + id?: (string | null) + name?: (string | null) + description?: (string | null) + metadata?: ((string | null) | (number | null) | (number | null) | null)[] +} + export interface CompoundBigNumbers { big?: partial_types.BigNumbers | null big_nums?: partial_types.BigNumbers | null[] @@ -283,6 +296,12 @@ export interface Martian { age?: Checked<(number | null),"young_enough"> } +export interface MemoryObject { + id?: (string | null) + name?: (string | null) + description?: (string | null) +} + export interface MergeAttrs { amount?: Checked<(number | null),"gt_ten"> } @@ -462,6 +481,11 @@ export interface TestClassWithEnum { prop2?: (EnumInClass | null) } +export interface TestMemoryOutput { + items?: (partial_types.MemoryObject | null | partial_types.ComplexMemoryObject | null | partial_types.AnotherObject | null | null)[] + more_items?: (partial_types.MemoryObject | null | partial_types.ComplexMemoryObject | null | partial_types.AnotherObject | null | null)[] +} + export interface TestOutputClass { prop1?: (string | null) prop2?: (number | null) diff --git a/integ-tests/typescript/baml_client/sync_client.ts b/integ-tests/typescript/baml_client/sync_client.ts index 431fb1725..471131f0d 100644 --- a/integ-tests/typescript/baml_client/sync_client.ts +++ b/integ-tests/typescript/baml_client/sync_client.ts @@ -16,20 +16,11 @@ $ pnpm add @boundaryml/baml // @ts-nocheck // biome-ignore format: autogenerated code import { BamlRuntime, FunctionResult, BamlCtxManager, BamlSyncStream, Image, ClientRegistry, createBamlValidationError, BamlValidationError } from "@boundaryml/baml" -import { Checked, Check, RecursivePartialNull } from "./types" -import {BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, UniverseQuestion, UniverseQuestionInput, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" +import { Checked, Check } from "./types" +import {AnotherObject, BigNumbers, BinaryNode, Blah, BlockConstraint, BlockConstraintForParam, BookOrder, ClassForNullLiteral, ClassOptionalOutput, ClassOptionalOutput2, ClassToRecAlias, ClassWithBlockDone, ClassWithImage, ClassWithoutDone, ComplexMemoryObject, CompoundBigNumbers, ContactInfo, CustomTaskResult, DummyOutput, DynInputOutput, DynamicClassOne, DynamicClassTwo, DynamicOutput, Earthling, Education, Email, EmailAddress, Event, FakeImage, FlightConfirmation, FooAny, Forest, FormatterTest0, FormatterTest1, FormatterTest2, FormatterTest3, GroceryReceipt, InnerClass, InnerClass2, InputClass, InputClassNested, LinkedList, LinkedListAliasNode, LiteralClassHello, LiteralClassOne, LiteralClassTwo, MalformedConstraints, MalformedConstraints2, Martian, MemoryObject, MergeAttrs, NamedArgsSingleClass, Nested, Nested2, NestedBlockConstraint, NestedBlockConstraintForParam, Node, NodeWithAliasIndirection, OptionalListAndMap, OptionalTest_Prop1, OptionalTest_ReturnType, OrderInfo, OriginalA, OriginalB, Person, PhoneNumber, Quantity, RaysData, ReceiptInfo, ReceiptItem, Recipe, Resume, Schema, SearchParams, SemanticContainer, SmallThing, SomeClassNestedDynamic, StringToClassEntry, TestClassAlias, TestClassNested, TestClassWithEnum, TestMemoryOutput, TestOutputClass, Tree, TwoStoriesOneTitle, UnionTest_ReturnType, WithReasoning, AliasedEnum, Category, Category2, Category3, Color, DataType, DynEnumOne, DynEnumTwo, EnumInClass, EnumOutput, Hobby, MapKey, NamedArgsSingleEnum, NamedArgsSingleEnumList, OptionalTest_CategoryType, OrderStatus, Tag, TestEnum} from "./types" import TypeBuilder from "./type_builder" import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX, DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_RUNTIME } from "./globals" -/** - * @deprecated Use RecursivePartialNull from 'baml_client/types' instead. - */ -export type RecursivePartialNull = T extends object - ? { - [P in keyof T]?: RecursivePartialNull; - } - : T | null; - export class BamlSyncClient { private runtime: BamlRuntime private ctx_manager: BamlCtxManager @@ -43,7 +34,7 @@ export class BamlSyncClient { */ get stream() { throw new Error("stream is not available in BamlSyncClient. Use `import { b } from 'baml_client/async_client") - } + } AaaSamOutputFormat( @@ -3221,6 +3212,31 @@ export class BamlSyncClient { } } + TestMemory( + input: string, + __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } + ): TestMemoryOutput { + try { + const raw = this.runtime.callFunctionSync( + "TestMemory", + { + "input": input + }, + this.ctx_manager.cloneContext(), + __baml_options__?.tb?.__tb(), + __baml_options__?.clientRegistry, + ) + return raw.parsed(false) as TestMemoryOutput + } catch (error: any) { + const bamlError = createBamlValidationError(error); + if (bamlError instanceof BamlValidationError) { + throw bamlError; + } else { + throw error; + } + } + } + TestMulticlassNamedArgs( myArg: NamedArgsSingleClass,myArg2: NamedArgsSingleClass, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } @@ -3471,31 +3487,6 @@ export class BamlSyncClient { } } - TestUniverseQuestion( - question: UniverseQuestionInput, - __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } - ): UniverseQuestion { - try { - const raw = this.runtime.callFunctionSync( - "TestUniverseQuestion", - { - "question": question - }, - this.ctx_manager.cloneContext(), - __baml_options__?.tb?.__tb(), - __baml_options__?.clientRegistry, - ) - return raw.parsed(false) as UniverseQuestion - } catch (error: any) { - const bamlError = createBamlValidationError(error); - if (bamlError instanceof BamlValidationError) { - throw bamlError; - } else { - throw error; - } - } - } - TestVertex( input: string, __baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry } diff --git a/integ-tests/typescript/baml_client/tracing.ts b/integ-tests/typescript/baml_client/tracing.ts new file mode 100644 index 000000000..f39dc83a0 --- /dev/null +++ b/integ-tests/typescript/baml_client/tracing.ts @@ -0,0 +1,33 @@ +/************************************************************************************************* + +Welcome to Baml! To use this generated code, please run one of the following: + +$ npm install @boundaryml/baml +$ yarn add @boundaryml/baml +$ pnpm add @boundaryml/baml + +*************************************************************************************************/ + +// This file was generated by BAML: do not edit it. Instead, edit the BAML +// files and re-generate this code. +// +/* eslint-disable */ +// tslint:disable +// @ts-nocheck +// biome-ignore format: autogenerated code +import { BamlLogEvent } from '@boundaryml/baml'; +import { DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX } from './globals'; + +const traceAsync = +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.traceFnAsync.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX) +const traceSync = +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.traceFnSync.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX) +const setTags = +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.upsertTags.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX) +const flush = () => { + DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.flush.bind(DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX)() +} +const onLogEvent = (callback: undefined | ((event: BamlLogEvent) => void)) => +DO_NOT_USE_DIRECTLY_UNLESS_YOU_KNOW_WHAT_YOURE_DOING_CTX.onLogEvent(callback) + +export { traceAsync, traceSync, setTags, flush, onLogEvent } \ No newline at end of file diff --git a/integ-tests/typescript/baml_client/type_builder.ts b/integ-tests/typescript/baml_client/type_builder.ts index 86486a3d8..144a363d7 100644 --- a/integ-tests/typescript/baml_client/type_builder.ts +++ b/integ-tests/typescript/baml_client/type_builder.ts @@ -15,9 +15,8 @@ $ pnpm add @boundaryml/baml // tslint:disable // @ts-nocheck // biome-ignore format: autogenerated code -import type { FieldType } from '@boundaryml/baml/native' -import { TypeBuilder as _TypeBuilder } from '@boundaryml/baml/type_builder' -import type { EnumBuilder, ClassBuilder } from '@boundaryml/baml/type_builder' +import { FieldType } from '@boundaryml/baml/native' +import { TypeBuilder as _TypeBuilder, EnumBuilder, ClassBuilder } from '@boundaryml/baml/type_builder' export default class TypeBuilder { private tb: _TypeBuilder; @@ -51,7 +50,7 @@ export default class TypeBuilder { constructor() { this.tb = new _TypeBuilder({ classes: new Set([ - "BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithBlockDone","ClassWithImage","ClassWithoutDone","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SemanticContainer","SmallThing","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","UniverseQuestion","UniverseQuestionInput","WithReasoning", + "AnotherObject","BigNumbers","BinaryNode","Blah","BlockConstraint","BlockConstraintForParam","BookOrder","ClassForNullLiteral","ClassOptionalOutput","ClassOptionalOutput2","ClassToRecAlias","ClassWithBlockDone","ClassWithImage","ClassWithoutDone","ComplexMemoryObject","CompoundBigNumbers","ContactInfo","CustomTaskResult","DummyOutput","DynInputOutput","DynamicClassOne","DynamicClassTwo","DynamicOutput","Earthling","Education","Email","EmailAddress","Event","FakeImage","FlightConfirmation","FooAny","Forest","FormatterTest0","FormatterTest1","FormatterTest2","FormatterTest3","GroceryReceipt","InnerClass","InnerClass2","InputClass","InputClassNested","LinkedList","LinkedListAliasNode","LiteralClassHello","LiteralClassOne","LiteralClassTwo","MalformedConstraints","MalformedConstraints2","Martian","MemoryObject","MergeAttrs","NamedArgsSingleClass","Nested","Nested2","NestedBlockConstraint","NestedBlockConstraintForParam","Node","NodeWithAliasIndirection","OptionalListAndMap","OptionalTest_Prop1","OptionalTest_ReturnType","OrderInfo","OriginalA","OriginalB","Person","PhoneNumber","Quantity","RaysData","ReceiptInfo","ReceiptItem","Recipe","Resume","Schema","SearchParams","SemanticContainer","SmallThing","SomeClassNestedDynamic","StringToClassEntry","TestClassAlias","TestClassNested","TestClassWithEnum","TestMemoryOutput","TestOutputClass","Tree","TwoStoriesOneTitle","UnionTest_ReturnType","WithReasoning", ]), enums: new Set([ "AliasedEnum","Category","Category2","Category3","Color","DataType","DynEnumOne","DynEnumTwo","EnumInClass","EnumOutput","Hobby","MapKey","NamedArgsSingleEnum","NamedArgsSingleEnumList","OptionalTest_CategoryType","OrderStatus","Tag","TestEnum", @@ -112,7 +111,7 @@ export default class TypeBuilder { __tb() { return this.tb._tb(); } - + string(): FieldType { return this.tb.string() } diff --git a/integ-tests/typescript/baml_client/types.ts b/integ-tests/typescript/baml_client/types.ts index 12c728864..aa806d41c 100644 --- a/integ-tests/typescript/baml_client/types.ts +++ b/integ-tests/typescript/baml_client/types.ts @@ -162,6 +162,13 @@ export enum TestEnum { G = "G", } +export interface AnotherObject { + id: string + thingy2: string + thingy3: string + +} + export interface BigNumbers { a: number b: number @@ -242,6 +249,14 @@ export interface ClassWithoutDone { } +export interface ComplexMemoryObject { + id: string + name: string + description: string + metadata: (string | number | number)[] + +} + export interface CompoundBigNumbers { big: BigNumbers big_nums: BigNumbers[] @@ -460,6 +475,13 @@ export interface Martian { } +export interface MemoryObject { + id: string + name: string + description: string + +} + export interface MergeAttrs { amount: Checked @@ -670,6 +692,12 @@ export interface TestClassWithEnum { } +export interface TestMemoryOutput { + items: (MemoryObject | ComplexMemoryObject | AnotherObject)[] + more_items: (MemoryObject | ComplexMemoryObject | AnotherObject)[] + +} + export interface TestOutputClass { prop1: string prop2: number