-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from parea-ai/test_collection_in_experiment
feat(experiment): use test collection in experiment
- Loading branch information
Showing
8 changed files
with
1,949 additions
and
1,814 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { Parea } from '../client'; | ||
import { Completion, CompletionResponse, Log, Message } from '../types'; | ||
import { trace } from '../utils/trace_utils'; | ||
import * as dotenv from 'dotenv'; | ||
|
||
dotenv.config(); | ||
|
||
const p = new Parea(process.env.DEV_API_KEY); | ||
|
||
function evalFunc(log: Log): number { | ||
if (log.inputs?.['x']?.toLowerCase() === 'python') { | ||
return 1.0; | ||
} | ||
return Math.random(); | ||
} | ||
|
||
const callLLM = async (data: Message[]): Promise<CompletionResponse> => { | ||
const completion: Completion = { | ||
llm_configuration: { | ||
model: 'gpt-4', | ||
model_params: { temp: 1.0 }, | ||
messages: data, | ||
}, | ||
}; | ||
return await p.completion(completion); | ||
}; | ||
|
||
const helloWorld = trace( | ||
'helloWorld', | ||
async (x: string, y: string): Promise<string> => { | ||
const response = await callLLM([{ role: 'user', content: `Write a hello world program in ${x} using ${y}` }]); | ||
return response.content; | ||
}, | ||
{ | ||
evalFuncs: [evalFunc], | ||
}, | ||
); | ||
|
||
export async function main() { | ||
const e = p.experiment( | ||
'Hello World Example', // this is the name of my Test Collection in Parea (TestHub page) | ||
helloWorld, | ||
); | ||
return await e.run(); | ||
} | ||
|
||
main().then(() => { | ||
console.log('Experiment complete!'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.