Skip to content

Commit

Permalink
regenerated clients
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-palakurthi committed Aug 7, 2024
1 parent da9343a commit 52df798
Show file tree
Hide file tree
Showing 19 changed files with 1,904 additions and 2,759 deletions.
15 changes: 3 additions & 12 deletions engine/baml-lib/baml-types/src/field_type/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,10 @@ impl FieldType {
pub fn is_optional(&self) -> bool {
match self {
FieldType::Optional(_) => true,
FieldType::Primitive(TypeValue::Null) => {
println!("found a null in is_optional");
true
}
FieldType::Primitive(TypeValue::Null) => true,

FieldType::Union(types) => {
println!("found a union in is_optional");
types.iter().any(FieldType::is_optional)
}
_ => {
// println!("non-optional in is_optional: {:#?}", self);
false
}
FieldType::Union(types) => types.iter().any(FieldType::is_optional),
_ => false,
}
}
}
1 change: 0 additions & 1 deletion engine/baml-lib/schema-ast/src/parser/parse_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ fn parse_base_type(pair: Pair<'_>, diagnostics: &mut Diagnostics) -> Option<Fiel
if let Some(current) = pair.into_inner().next() {
return match current.as_rule() {
Rule::identifier => {
// log::info!("Parsing identifier {:?}", current.as_str());
let identifier = parse_identifier(current.clone(), diagnostics);
let field_type = match current.as_str() {
"string" | "int" | "float" | "bool" | "image" | "audio" => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,6 @@ impl SseResponseTrait for OpenAIClient {
Some(FinishReason::Stop.to_string());
}
finish_reason => {
// log::info!(
// "Received a non-stop finish reason: {:?}",
// finish_reason
// );
inner.metadata.baml_is_complete = false;
inner.metadata.finish_reason =
finish_reason.as_ref().map(|r| r.to_string());
Expand Down
2 changes: 1 addition & 1 deletion engine/baml-schema-wasm/src/runtime_wasm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use wasm_bindgen::prelude::*;

#[wasm_bindgen(start)]
pub fn on_wasm_init() {
match console_log::init_with_level(log::Level::Info) {
match console_log::init_with_level(log::Level::Warn) {
Ok(_) => web_sys::console::log_1(&"Initialized BAML runtime logging".into()),
Err(e) => web_sys::console::log_1(
&format!("Failed to initialize BAML runtime logging: {:?}", e).into(),
Expand Down
1 change: 1 addition & 0 deletions integ-tests/baml_src/main.baml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ generator lang_typescript {
output_type typescript
output_dir "../typescript"
version "0.53.0"

}

generator lang_ruby {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,22 @@
// function AudioInput(aud: audio) -> string{
// client Gemini
// prompt #"
// {{ _.role("user") }}
function AudioInput(aud: audio) -> string{
client Gemini
prompt #"
{{ _.role("user") }}

// Does this sound like a roar? Yes or no? One word no other characters.
Does this sound like a roar? Yes or no? One word no other characters.

// {{ aud }}
// "#
// }



// test TestURLAudioInput{
// functions [AudioInput]
// args {
// aud{
// url https://actions.google.com/sounds/v1/emergency/beeper_emergency_call.ogg
// }
// }
// }


enum CatA {
A
{{ aud }}
"#
}

enum CatB {
C
D
}

class CatAPicker {
cat CatA
}

class CatBPicker {
cat CatB
item int
test TestURLAudioInput{
functions [AudioInput]
args {
aud{
url https://actions.google.com/sounds/v1/emergency/beeper_emergency_call.ogg
}
}
}

enum CatC {
E
F
G
H
I
}

class CatCPicker {
cat CatC
item int | string | null
data int?
}
8 changes: 4 additions & 4 deletions integ-tests/python/baml_client/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ async def ExtractReceiptInfo(

async def ExtractResume(
self,
resume: str,img: baml_py.Image,
resume: str,img: Optional[baml_py.Image],
baml_options: BamlCallOptions = {},
) -> types.Resume:
__tb__ = baml_options.get("tb", None)
Expand Down Expand Up @@ -613,7 +613,7 @@ async def FnEnumOutput(

async def FnNamedArgsSingleStringOptional(
self,
myString: str,
myString: Optional[str],
baml_options: BamlCallOptions = {},
) -> str:
__tb__ = baml_options.get("tb", None)
Expand Down Expand Up @@ -2315,7 +2315,7 @@ def ExtractReceiptInfo(

def ExtractResume(
self,
resume: str,img: baml_py.Image,
resume: str,img: Optional[baml_py.Image],
baml_options: BamlCallOptions = {},
) -> baml_py.BamlStream[partial_types.Resume, types.Resume]:
__tb__ = baml_options.get("tb", None)
Expand Down Expand Up @@ -2514,7 +2514,7 @@ def FnEnumOutput(

def FnNamedArgsSingleStringOptional(
self,
myString: str,
myString: Optional[str],
baml_options: BamlCallOptions = {},
) -> baml_py.BamlStream[Optional[str], str]:
__tb__ = baml_options.get("tb", None)
Expand Down
4 changes: 2 additions & 2 deletions integ-tests/python/baml_client/inlinedbaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
"fiddle-examples/extract-receipt-info.baml": "class ReceiptItem {\n name string\n description string?\n quantity int\n price float\n}\n\nclass ReceiptInfo {\n items ReceiptItem[]\n total_cost float?\n}\n\nfunction ExtractReceiptInfo(email: string) -> ReceiptInfo {\n client GPT4o\n prompt #\"\n Given the receipt below:\n\n ```\n {{email}}\n ```\n\n {{ ctx.output_format }}\n \"#\n}\n\n",
"fiddle-examples/images/image.baml": "function DescribeImage(img: image) -> string {\n client AwsBedrock\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}",
"main.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.53.0\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.53.0\"\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.53.0\"\n}\n",
"main.baml": "generator lang_python {\n output_type python/pydantic\n output_dir \"../python\"\n version \"0.53.0\"\n}\n\ngenerator lang_typescript {\n output_type typescript\n output_dir \"../typescript\"\n version \"0.53.0\"\n\n}\n\ngenerator lang_ruby {\n output_type ruby/sorbet\n output_dir \"../ruby\"\n version \"0.53.0\"\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}",
"test-files/comments/comments.baml": "// add some functions, classes, enums etc with comments all over.",
"test-files/dynamic/client-registry.baml": "// Intentionally use a bad key\nclient<llm> BadClient {\n provider openai\n options {\n model \"gpt-3.5-turbo\"\n api_key \"sk-invalid\"\n }\n}\n\nfunction ExpectFailure() -> string {\n client BadClient\n\n prompt #\"\n What is the capital of England?\n \"#\n}\n",
"test-files/dynamic/dynamic.baml": "class DynamicClassOne {\n @@dynamic\n}\n\nenum DynEnumOne {\n @@dynamic\n}\n\nenum DynEnumTwo {\n @@dynamic\n}\n\nclass SomeClassNestedDynamic {\n hi string\n @@dynamic\n\n}\n\nclass DynamicClassTwo {\n hi string\n some_class SomeClassNestedDynamic\n status DynEnumOne\n @@dynamic\n}\n\nfunction DynamicFunc(input: DynamicClassOne) -> DynamicClassTwo {\n client GPT35\n prompt #\"\n Please extract the schema from \n {{ input }}\n\n {{ ctx.output_format }}\n \"#\n}\n\nclass DynInputOutput {\n testKey string\n @@dynamic\n}\n\nfunction DynamicInputOutput(input: DynInputOutput) -> DynInputOutput {\n client GPT35\n prompt #\"\n Here is some input data:\n ----\n {{ input }}\n ----\n\n Extract the information.\n {{ ctx.output_format }}\n \"#\n}\n\nfunction DynamicListInputOutput(input: DynInputOutput[]) -> DynInputOutput[] {\n client GPT35\n prompt #\"\n Here is some input data:\n ----\n {{ input }}\n ----\n\n Extract the information.\n {{ ctx.output_format }}\n \"#\n}\n\n\n\nclass DynamicOutput {\n @@dynamic\n}\n \nfunction MyFunc(input: string) -> DynamicOutput {\n client GPT35\n prompt #\"\n Given a string, extract info using the schema:\n\n {{ input}}\n\n {{ ctx.output_format }}\n \"#\n}\n\n",
"test-files/functions/input/named-args/single/named-audio.baml": "function AudioInput(aud: audio) -> string{\n client Gemini\n prompt #\"\n {{ _.role(\"user\") }}\n\n Does this sound like a roar? Yes or no? One word no other characters.\n \n {{ aud }}\n \"#\n}\n\n\n\ntest TestURLAudioInput{\n functions [AudioInput]\n args {\n aud{ \n url https://actions.google.com/sounds/v1/emergency/beeper_emergency_call.ogg\n }\n } \n}\n\n\n",
"test-files/functions/input/named-args/single/named-audio.baml": "function AudioInput(aud: audio) -> string{\n client Gemini\n prompt #\"\n {{ _.role(\"user\") }}\n\n Does this sound like a roar? Yes or no? One word no other characters.\n \n {{ aud }}\n \"#\n}\n\n\ntest TestURLAudioInput{\n functions [AudioInput]\n args {\n aud{ \n url https://actions.google.com/sounds/v1/emergency/beeper_emergency_call.ogg\n }\n } \n}\n\n\n",
"test-files/functions/input/named-args/single/named-boolean.baml": "\n\nfunction TestFnNamedArgsSingleBool(myBool: bool) -> string{\n client Vertex\n prompt #\"\n Return this value back to me: {{myBool}}\n \"#\n}\n\ntest TestFnNamedArgsSingleBool {\n functions [TestFnNamedArgsSingleBool]\n args {\n myBool true\n }\n}",
"test-files/functions/input/named-args/single/named-class-list.baml": "\n\n\nfunction TestFnNamedArgsSingleStringList(myArg: string[]) -> string{\n client GPT35\n prompt #\"\n Return this value back to me: {{myArg}}\n \"#\n}\n\ntest TestFnNamedArgsSingleStringList {\n functions [TestFnNamedArgsSingleStringList]\n args {\n myArg [\"hello\", \"world\"]\n }\n}",
"test-files/functions/input/named-args/single/named-class.baml": "class NamedArgsSingleClass {\n key string\n key_two bool\n key_three int\n // TODO: doesn't work with keys with numbers\n // key2 bool\n // key3 int\n}\n\nfunction TestFnNamedArgsSingleClass(myArg: NamedArgsSingleClass) -> string {\n client GPT35\n prompt #\"\n Print these values back to me:\n {{myArg.key}}\n {{myArg.key_two}}\n {{myArg.key_three}}\n \"#\n}\n\ntest TestFnNamedArgsSingleClass {\n functions [TestFnNamedArgsSingleClass]\n args {\n myArg {\n key \"example\",\n key_two true,\n key_three 42\n }\n }\n}\n\nfunction TestMulticlassNamedArgs(myArg: NamedArgsSingleClass, myArg2: NamedArgsSingleClass) -> string {\n client GPT35\n prompt #\"\n Print these values back to me:\n {{myArg.key}}\n {{myArg.key_two}}\n {{myArg.key_three}}\n {{myArg2.key}}\n {{myArg2.key_two}}\n {{myArg2.key_three}}\n \"#\n}",
Expand Down
8 changes: 4 additions & 4 deletions integ-tests/python/baml_client/sync_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def ExtractReceiptInfo(

def ExtractResume(
self,
resume: str,img: baml_py.Image,
resume: str,img: Optional[baml_py.Image],
baml_options: BamlCallOptions = {},
) -> types.Resume:
__tb__ = baml_options.get("tb", None)
Expand Down Expand Up @@ -611,7 +611,7 @@ def FnEnumOutput(

def FnNamedArgsSingleStringOptional(
self,
myString: str,
myString: Optional[str],
baml_options: BamlCallOptions = {},
) -> str:
__tb__ = baml_options.get("tb", None)
Expand Down Expand Up @@ -2314,7 +2314,7 @@ def ExtractReceiptInfo(

def ExtractResume(
self,
resume: str,img: baml_py.Image,
resume: str,img: Optional[baml_py.Image],
baml_options: BamlCallOptions = {},
) -> baml_py.BamlSyncStream[partial_types.Resume, types.Resume]:
__tb__ = baml_options.get("tb", None)
Expand Down Expand Up @@ -2513,7 +2513,7 @@ def FnEnumOutput(

def FnNamedArgsSingleStringOptional(
self,
myString: str,
myString: Optional[str],
baml_options: BamlCallOptions = {},
) -> baml_py.BamlSyncStream[Optional[str], str]:
__tb__ = baml_options.get("tb", None)
Expand Down
24 changes: 12 additions & 12 deletions integ-tests/python/baml_client/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class TestEnum(str, Enum):
class Blah(BaseModel):


prop4: str
prop4: Optional[str] = None

class ClassOptionalOutput(BaseModel):

Expand All @@ -133,8 +133,8 @@ class ClassOptionalOutput(BaseModel):
class ClassOptionalOutput2(BaseModel):


prop1: str
prop2: str
prop1: Optional[str] = None
prop2: Optional[str] = None
prop3: Optional["Blah"] = None

class ClassWithImage(BaseModel):
Expand Down Expand Up @@ -182,7 +182,7 @@ class Education(BaseModel):
location: str
degree: str
major: List[str]
graduation_date: str
graduation_date: Optional[str] = None

class Email(BaseModel):

Expand Down Expand Up @@ -234,28 +234,28 @@ class OptionalTest_ReturnType(BaseModel):


omega_1: Optional["OptionalTest_Prop1"] = None
omega_2: str
omega_2: Optional[str] = None
omega_3: List[Optional["OptionalTest_CategoryType"]]

class OrderInfo(BaseModel):


order_status: "OrderStatus"
tracking_number: str
estimated_arrival_date: str
tracking_number: Optional[str] = None
estimated_arrival_date: Optional[str] = None

class Person(BaseModel):

model_config = ConfigDict(extra='allow')

name: str
name: Optional[str] = None
hair_color: Optional[Union["Color", str]] = None

class Quantity(BaseModel):


amount: Union[Union[int], Union[float]]
unit: str
unit: Optional[str] = None

class RaysData(BaseModel):

Expand All @@ -267,13 +267,13 @@ class ReceiptInfo(BaseModel):


items: List["ReceiptItem"]
total_cost: float
total_cost: Optional[float] = None

class ReceiptItem(BaseModel):


name: str
description: str
description: Optional[str] = None
quantity: int
price: float

Expand All @@ -295,7 +295,7 @@ class Resume(BaseModel):
class SearchParams(BaseModel):


dateRange: int
dateRange: Optional[int] = None
location: List[str]
jobTitle: Optional["WithReasoning"] = None
company: Optional["WithReasoning"] = None
Expand Down
8 changes: 4 additions & 4 deletions integ-tests/ruby/baml_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def ExtractReceiptInfo(
sig {
params(
varargs: T.untyped,
resume: String,img: Baml::Image,
resume: String,img: T.nilable(Baml::Image),
baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)]
).returns(Baml::Types::Resume)
}
Expand Down Expand Up @@ -789,7 +789,7 @@ def FnEnumOutput(
sig {
params(
varargs: T.untyped,
myString: String,
myString: T.nilable(String),
baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)]
).returns(String)
}
Expand Down Expand Up @@ -2901,7 +2901,7 @@ def ExtractReceiptInfo(
sig {
params(
varargs: T.untyped,
resume: String,img: Baml::Image,
resume: String,img: T.nilable(Baml::Image),
baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)]
).returns(Baml::BamlStream[Baml::Types::Resume])
}
Expand Down Expand Up @@ -3111,7 +3111,7 @@ def FnEnumOutput(
sig {
params(
varargs: T.untyped,
myString: String,
myString: T.nilable(String),
baml_options: T::Hash[Symbol, T.any(Baml::TypeBuilder, Baml::ClientRegistry)]
).returns(Baml::BamlStream[String])
}
Expand Down
Loading

0 comments on commit 52df798

Please sign in to comment.