Skip to content

Commit

Permalink
stableish for node generation
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-palakurthi committed Jul 16, 2024
1 parent 62b3666 commit 702a855
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 293 deletions.
19 changes: 13 additions & 6 deletions integ-tests/baml_src/test-files/strategies/fallback.baml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ client<llm> FallbackClient {
FaultyClient

Lottery_SimpleSyntax
// FaultyClient,

// RetryClientConstant
// RetryClientExponential
// Gemini
SecondaryFallback
TertiaryFallback

]
}
Expand All @@ -33,8 +30,18 @@ client<llm> SecondaryFallback {
strategy [
FaultyClient
RetryClientExponential
// RetryClientConstant
// GPT4

]
}
}

client<llm> TertiaryFallback {
provider fallback
options {
strategy [
FaultyClient
RetryClientExponential

]
}
}
Expand Down
49 changes: 37 additions & 12 deletions integ-tests/python/baml_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,30 @@ async def TestRetryExponential(
mdl = create_model("TestRetryExponentialReturnType", inner=(str, ...))
return coerce(mdl, raw.parsed())

async def TestRoundRobin(
self,

baml_options: BamlCallOptions = {},
) -> str:
__tb__ = baml_options.get("tb", None)
if __tb__ is not None:
tb = __tb__._tb
else:
tb = None
__cr__ = baml_options.get("client_registry", None)

raw = await self.__runtime.call_function(
"TestRoundRobin",
{

},
self.__ctx_manager.get(),
tb,
__cr__,
)
mdl = create_model("TestRoundRobinReturnType", inner=(str, ...))
return coerce(mdl, raw.parsed())

async def TestVertex(
self,
input: str,
Expand Down Expand Up @@ -3650,9 +3674,9 @@ def TestRetryExponential(
self.__ctx_manager.get(),
)

def TestVertex(
def TestRoundRobin(
self,
input: str,

baml_options: BamlCallOptions = {},
) -> baml_py.BamlStream[Optional[str], str]:
__tb__ = baml_options.get("tb", None)
Expand All @@ -3663,18 +3687,17 @@ def TestVertex(
__cr__ = baml_options.get("client_registry", None)

raw = self.__runtime.stream_function(
"TestVertex",
"TestRoundRobin",
{
"input": input,
},
None,
self.__ctx_manager.get(),
tb,
__cr__,
)

mdl = create_model("TestVertexReturnType", inner=(str, ...))
partial_mdl = create_model("TestVertexPartialReturnType", inner=(Optional[str], ...))
mdl = create_model("TestRoundRobinReturnType", inner=(str, ...))
partial_mdl = create_model("TestRoundRobinPartialReturnType", inner=(Optional[str], ...))

return baml_py.BamlStream[Optional[str], str](
raw,
Expand All @@ -3683,35 +3706,37 @@ def TestVertex(
self.__ctx_manager.get(),
)

def TestRoundRobin(
def TestVertex(
self,

input: str,
baml_options: BamlCallOptions = {},
) -> baml_py.BamlStream[Optional[str], str]:
__tb__ = baml_options.get("tb", None)
if __tb__ is not None:
tb = __tb__._tb
else:
tb = None
__cr__ = baml_options.get("client_registry", None)

raw = self.__runtime.stream_function(
"TestRoundRobin",
"TestVertex",
{
"input": input,
},
None,
self.__ctx_manager.get(),
tb,
__cr__,
)

mdl = create_model("TestRoundRobinReturnType", inner=(str, ...))
partial_mdl = create_model("TestRoundRobinPartialReturnType", inner=(Optional[str], ...))
mdl = create_model("TestVertexReturnType", inner=(str, ...))
partial_mdl = create_model("TestVertexPartialReturnType", inner=(Optional[str], ...))

return baml_py.BamlStream[Optional[str], str](
raw,
lambda x: coerce(partial_mdl, x),
lambda x: coerce(mdl, x),
self.__ctx_manager.get(),
tb,
)

def UnionTest_Function(
Expand Down
6 changes: 3 additions & 3 deletions integ-tests/python/baml_client/inlinedbaml.py

Large diffs are not rendered by default.

22 changes: 10 additions & 12 deletions integ-tests/ruby/baml_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1285,18 +1285,16 @@ def TestRetryExponential(

sig {

params(
input: String,
).returns(String)
returns(String)

}
def TestVertex(
input:
def TestRoundRobin(

)
raw = @runtime.call_function(
"TestVertex",
"TestRoundRobin",
{
"input" => input,

},
@ctx_manager,
)
Expand Down Expand Up @@ -2660,16 +2658,16 @@ def TestRetryExponential(

sig {
params(
input: String,

).returns(Baml::BamlStream[String])
}
def TestVertex(
input:
def TestRoundRobin(

)
raw = @runtime.stream_function(
"TestVertex",
"TestRoundRobin",
{
"input" => input,

},
@ctx_manager,
)
Expand Down
6 changes: 3 additions & 3 deletions integ-tests/ruby/baml_client/inlined.rb

Large diffs are not rendered by default.

38 changes: 20 additions & 18 deletions integ-tests/typescript/baml_client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,14 +1033,14 @@ export class BamlClient {
return raw.parsed() as string
}

async TestVertex(
input: string,
async TestRoundRobin(

__baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry }
): Promise<string> {
const raw = await this.runtime.callFunction(
"TestVertex",
"TestRoundRobin",
{
"input": input

},
this.ctx_manager.cloneContext(),
__baml_options__?.tb?.__tb(),
Expand All @@ -1049,17 +1049,18 @@ export class BamlClient {
return raw.parsed() as string
}

async TestRoundRobin(

__baml_options__?: { tb?: TypeBuilder }
async TestVertex(
input: string,
__baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry }
): Promise<string> {
const raw = await this.runtime.callFunction(
"TestRoundRobin",
"TestVertex",
{

"input": input
},
this.ctx_manager.cloneContext(),
__baml_options__?.tb?.__tb(),
__baml_options__?.cr,
)
return raw.parsed() as string
}
Expand Down Expand Up @@ -2512,14 +2513,14 @@ class BamlStreamClient {
)
}

TestVertex(
input: string,
TestRoundRobin(

__baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry }
): BamlStream<RecursivePartialNull<string>, string> {
const raw = this.runtime.streamFunction(
"TestVertex",
"TestRoundRobin",
{
"input": input

},
undefined,
this.ctx_manager.cloneContext(),
Expand All @@ -2535,18 +2536,19 @@ class BamlStreamClient {
)
}

TestRoundRobin(

__baml_options__?: { tb?: TypeBuilder }
TestVertex(
input: string,
__baml_options__?: { tb?: TypeBuilder, clientRegistry?: ClientRegistry }
): BamlStream<RecursivePartialNull<string>, string> {
const raw = this.runtime.streamFunction(
"TestRoundRobin",
"TestVertex",
{

"input": input
},
undefined,
this.ctx_manager.cloneContext(),
__baml_options__?.tb?.__tb(),
__baml_options__?.cr,
)
return new BamlStream<RecursivePartialNull<string>, string>(
raw,
Expand Down
Loading

0 comments on commit 702a855

Please sign in to comment.