Skip to content

Commit

Permalink
fix: refactor for general type
Browse files Browse the repository at this point in the history
  • Loading branch information
e-vandenberg committed Oct 10, 2023
1 parent f75ecd0 commit 18eeb21
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
24 changes: 24 additions & 0 deletions packages/base-types/src/node/knowledgeBase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { BaseResponseTrace, BaseTraceFrame, TraceType } from './utils';

export enum KnowledgeBaseCtxType {
FAQ = 'faq',
DOCUMENTS = 'documents',
}

interface AbstractKnowledgeBasePayload extends BaseResponseTrace {
contextType: KnowledgeBaseCtxType;
}

export interface FAQPayload extends AbstractKnowledgeBasePayload {
contextType: KnowledgeBaseCtxType.FAQ;
faqQuestion: string;
faqAnswer: string;
query: string;
}

// TODO: Write DocumentsPayload for when KB response comes from the docs
export type KnowledgeBasePayload = FAQPayload;

export interface TraceFrame extends BaseTraceFrame<KnowledgeBasePayload> {
type: TraceType.KNOWLEDGE_BASE;
}
11 changes: 0 additions & 11 deletions packages/base-types/src/node/knowledgeBaseFaq.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/base-types/src/node/utils/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export enum TraceType {
NO_REPLY = 'no-reply',
ENTITY_FILLING = 'entity-filling',
CHANNEL_ACTION = 'channel-action',
KNOWLEDGE_BASE_FAQ = 'knowledge-base-faq',
KNOWLEDGE_BASE = 'knowledgeBase',
}

export interface BaseTraceFramePath<Event extends BaseEvent = BaseEvent> {
Expand Down
2 changes: 1 addition & 1 deletion packages/base-types/src/trace/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export { TraceFrame as Carousel } from '@base-types/node/carousel';
export { TraceFrame as End } from '@base-types/node/exit';
export { TraceFrame as Flow } from '@base-types/node/flow';
export { TraceFrame as Choice } from '@base-types/node/interaction';
export { TraceFrame as KnowledgeBaseFaq } from '@base-types/node/knowledgeBaseFaq';
export { TraceFrame as KnowledgeBase } from '@base-types/node/knowledgeBase';
export { TraceFrame as Speak } from '@base-types/node/speak';
export { TraceFrame as Stream } from '@base-types/node/stream';
export { TraceFrame as Text } from '@base-types/node/text';
Expand Down

0 comments on commit 18eeb21

Please sign in to comment.