Skip to content

Commit

Permalink
Fix integ test issues (#1281)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronvg authored Dec 31, 2024
1 parent 3687b55 commit 8161bcf
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 45 deletions.
10 changes: 9 additions & 1 deletion integ-tests/baml_src/clients.baml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ client<llm> GPT4Turbo {
}
}

retry_policy GPT4oRetry {
max_retries 2
strategy {
type exponential_backoff
}
}

client<llm> GPT35 {
provider openai
retry_policy GPT4oRetry
options {
model "gpt-3.5-turbo"
model "gpt-4o-mini"
api_key env.OPENAI_API_KEY
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function FnOutputBool(input: string) -> bool {
client GPT35
prompt #"
Return a true: {{ ctx.output_format}}
Return "true"
"#
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class InnerClass2 {
}

function FnOutputClassNested(input: string) -> TestClassNested {
client Ollama
client GPT35
prompt #"
Return a made up json blob that matches this schema:
{{ctx.output_format}}
Expand Down
6 changes: 3 additions & 3 deletions integ-tests/python/baml_client/inlinedbaml.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions integ-tests/ruby/baml_client/inlined.rb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions integ-tests/typescript/baml_client/inlinedbaml.ts

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion integ-tests/typescript/test-report.html

Large diffs are not rendered by default.

57 changes: 25 additions & 32 deletions integ-tests/typescript/tests/integ-tests.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,35 +228,28 @@ describe('Integ tests', () => {
expect(res.amount.checks['gt_ten'].status).toEqual('succeeded')
})

it('return alias with merged attrs', async () => {
const res = await b.ReturnAliasWithMergedAttributes({
value: 123,
checks: {
gt_ten: {
name: 'gt_ten',
expr: 'value > 10',
status: 'succeeded',
},
},
})
expect(res.value).toEqual(123)
expect(res.checks['gt_ten'].status).toEqual('succeeded')
})

it('alias with multiple attrs', async () => {
const res = await b.AliasWithMultipleAttrs({
value: 123,
checks: {
gt_ten: {
name: 'gt_ten',
expr: 'value > 10',
status: 'succeeded',
},
},
})
expect(res.value).toEqual(123)
expect(res.checks['gt_ten'].status).toEqual('succeeded')
})
// Inputs with checks are not supported yet
// it('return alias with merged attrs', async () => {
// const res = await b.ReturnAliasWithMergedAttributes({
// value: 123,
// checks: {
// gt_ten: {
// name: 'gt_ten',
// expr: 'value > 10',
// status: 'succeeded',
// },
// },
// })
// expect(res.value).toEqual(123)
// expect(res.checks['gt_ten'].status).toEqual('succeeded')
// })

// TODO: checks as inputs are not supported yet
// it('alias with multiple attrs', async () => {
// const res = await b.AliasWithMultipleAttrs(123)
// expect(res.value).toEqual(123)
// expect(res.checks['gt_ten'].status).toEqual('succeeded')
// })

it('simple recursive map alias', async () => {
const res = await b.SimpleRecursiveMapAlias({ one: { two: { three: {} } } })
Expand Down Expand Up @@ -911,7 +904,7 @@ describe('Integ tests', () => {

it('should use aliases when serializing, but still have original keys in jinja', async () => {
const res = await b.AliasedInputClass2({ key: 'tiger', key2: 'world' })
expect(res).toContain('tiger')
expect(res.toLowerCase()).toContain('tiger')

const res2 = await b.AliasedInputClassNested({
key: 'hello',
Expand All @@ -923,13 +916,13 @@ describe('Integ tests', () => {
// TODO: Enum aliases are not supported
it('should use aliases when serializing input objects - enums', async () => {
const res = await b.AliasedInputEnum(AliasedEnum.KEY_ONE)
expect(res).not.toContain('tiger')
expect(res.toLowerCase()).not.toContain('tiger')
})

// TODO: enum aliases are not supported
it('should use aliases when serializing input objects - lists', async () => {
const res = await b.AliasedInputList([AliasedEnum.KEY_ONE, AliasedEnum.KEY_TWO])
expect(res).not.toContain('tiger')
expect(res.toLowerCase()).not.toContain('tiger')
})

it('constraints: should handle checks in return types', async () => {
Expand Down

0 comments on commit 8161bcf

Please sign in to comment.