mirror of
https://github.com/supabase/supabase.git
synced 2026-10-19 08:09:11 +03:00
feat: factuality eval with assistant response
This commit is contained in:
1 parent
4a2ddb6bc4
commit
e6d2a6d78d
1 file changed
+31
@@ -0,0 +1,31 @@
|
||||
import { openai } from '@ai-sdk/openai'
|
||||
import { Factuality } from 'autoevals'
|
||||
import { Eval } from 'braintrust'
|
||||
import { generateAssistantResponse } from 'lib/ai/generate-assistant-response'
|
||||
import assert from 'node:assert'
|
||||
|
||||
assert(process.env.BRAINTRUST_PROJECT_ID, 'BRAINTRUST_PROJECT_ID is not set')
|
||||
assert(process.env.OPENAI_API_KEY, 'OPENAI_API_KEY is not set')
|
||||
|
||||
Eval('Assistant', {
|
||||
projectId: process.env.BRAINTRUST_PROJECT_ID,
|
||||
data: () => {
|
||||
return [
|
||||
{
|
||||
input: 'Hello!',
|
||||
expected: 'Hello, world!',
|
||||
},
|
||||
]
|
||||
},
|
||||
task: async (input) => {
|
||||
const result = await generateAssistantResponse({
|
||||
model: openai('gpt-5'),
|
||||
messages: [{ id: '1', role: 'user', parts: [{ type: 'text', text: input }] }],
|
||||
tools: {},
|
||||
})
|
||||
|
||||
const text = await result.text
|
||||
return text
|
||||
},
|
||||
scores: [Factuality],
|
||||
})
|
||||
Reference in new issue
Block a user