Skip to content

Commit

Permalink
fix: rename
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Jul 31, 2024
1 parent 724b5d8 commit 63c64e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
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

0 comments on commit 63c64e0

Please sign in to comment.