Langfuse JS/TS SDKs
    Preparing search index...

    Type Alias ExperimentTask<Input, ExpectedOutput, Metadata>

    ExperimentTask: (
        params: ExperimentTaskParams<Input, ExpectedOutput, Metadata>,
    ) => Promise<any>

    Function type for experiment tasks that process input data and return output.

    The task function is the core component being tested in an experiment. It receives either an ExperimentItem or DatasetItem and produces output that will be evaluated.

    Type Parameters

    • Input = any
    • ExpectedOutput = any
    • Metadata extends Record<string, any> = Record<string, any>

    Type declaration

    const universalTask: ExperimentTask = async (item) => {
    // Works with both ExperimentItem and DatasetItem
    const input = item.input;
    const metadata = item.metadata;

    const response = await openai.chat.completions.create({
    model: "gpt-4",
    messages: [{ role: "user", content: input }]
    });

    return response.choices[0].message.content;
    };

    4.1.0