Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

Commit

Permalink
refactor: remove noise
Browse files Browse the repository at this point in the history
  • Loading branch information
effervescentia committed Jan 3, 2025
1 parent ed79b46 commit 5d0637d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/sdk-runtime/src/sdk/sdk.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class VoiceflowRuntime<T> {

public async interact(context: T, request: RuntimeInteractRequest): Promise<T> {
const response = await this.runtime.interact(request);
return this.trace.processResponse(context, response);
return this.trace.processTrace(context, response);
}

public async feedback(request: RuntimeFeedbackRequest) {
Expand Down
9 changes: 7 additions & 2 deletions packages/sdk-runtime/src/trace/trace.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ export class TraceService<T = unknown> {
private readonly traces: TraceDeclaration<T, any>[] = [];

public constructor(options: TraceOptions<T> = {}) {
this.traces = options.traces ?? [];
this.registerTraces(options.traces ?? []);
}

public registerTrace(step: TraceDeclaration<T, any>): this {
this.traces.push(step);
return this;
}

public async processResponse(context: T, response: Pick<RuntimeInteractResponse, 'trace'>): Promise<T> {
public registerTraces(steps: TraceDeclaration<T, any>[]): this {
steps.forEach((step) => this.registerTrace(step));
return this;
}

public async processTrace(context: T, response: Pick<RuntimeInteractResponse, 'trace'>): Promise<T> {
const meta: TraceHandlerMeta<T> = { context };

for (const trace of response.trace) {
Expand Down

0 comments on commit 5d0637d

Please sign in to comment.