Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename #50

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import instrumentation from './instrumentation';
import openai from './openai';
import {
Environment,
ExperimentRun,
ExperimentItemRun,
Step,
StepConstructor,
Thread,
Expand All @@ -20,7 +20,7 @@ export type * from './instrumentation';
type StoredContext = {
currentThread: Thread | null;
currentStep: Step | null;
currentExperimentRunId?: string | null;
currentExperimentItemRunId?: string | null;
};

const storage = new AsyncLocalStorage<StoredContext>();
Expand Down Expand Up @@ -67,8 +67,8 @@ export class LiteralClient {
return this.step({ ...data, type: 'run' });
}

experimentRun(data?: Omit<StepConstructor, 'type' | 'name'>) {
return new ExperimentRun(this, {
experimentItemRun(data?: Omit<StepConstructor, 'type' | 'name'>) {
return new ExperimentItemRun(this, {
...(data || {}),
name: 'Experiment Run',
type: 'run'
Expand Down
18 changes: 10 additions & 8 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ export class Thread extends ThreadFields {
const output = await this.client.store.run(
{
currentThread: this,
currentExperimentRunId: currentStore?.currentExperimentRunId ?? null,
currentExperimentItemRunId:
currentStore?.currentExperimentItemRunId ?? null,
currentStep: null
},
() => cb(this)
Expand Down Expand Up @@ -418,7 +419,8 @@ export class Step extends StepFields {
const output = await this.client.store.run(
{
currentThread: currentStore?.currentThread ?? null,
currentExperimentRunId: currentStore?.currentExperimentRunId ?? null,
currentExperimentItemRunId:
currentStore?.currentExperimentItemRunId ?? null,
currentStep: this
},
() => cb(this)
Expand Down Expand Up @@ -457,14 +459,14 @@ export class Step extends StepFields {
}

/**
* Represents a step in a process or workflow, extending the fields and methods from StepFields.
* Represents an item in an experiment.
*/
export class ExperimentRun extends Step {
export class ExperimentItemRun extends Step {
api: API;
client: LiteralClient;

/**
* Constructs a new ExperimentRun instance.
* Constructs a new ExperimentItemRun instance.
* @param api The API instance to be used for sending and managing steps.
* @param data The initial data for the step, excluding utility properties.
*/
Expand Down Expand Up @@ -493,7 +495,7 @@ export class ExperimentRun extends Step {
{
currentThread: currentStore?.currentThread ?? null,
currentStep: this,
currentExperimentRunId: this.id ?? null
currentExperimentItemRunId: this.id ?? null
},
async () => {
try {
Expand All @@ -503,7 +505,7 @@ export class ExperimentRun extends Step {
// Clear the currentExperimentRunId after execution
const updatedStore = this.client.store.getStore();
if (updatedStore) {
updatedStore.currentExperimentRunId = null;
updatedStore.currentExperimentItemRunId = null;
}
}
}
Expand Down Expand Up @@ -737,7 +739,7 @@ export class DatasetExperiment extends Utils {
>
) {
const currentStore = this.api.client.store.getStore();
const experimentRunId = currentStore?.currentExperimentRunId;
const experimentRunId = currentStore?.currentExperimentItemRunId;

const datasetExperimentItem = new DatasetExperimentItem({
...itemFields,
Expand Down
2 changes: 1 addition & 1 deletion tests/wrappers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ describe('Wrapper', () => {
let persistedExperimentItem: DatasetExperimentItem | undefined =
undefined;

await client.experimentRun().wrap(async () => {
await client.experimentItemRun().wrap(async () => {
const scores = [
{
name: 'context_relevancy',
Expand Down
Loading