Skip to content

Commit

Permalink
Improved AI context adapter implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
salmenus committed Mar 16, 2024
1 parent 2e3c4e0 commit c8f3d68
Show file tree
Hide file tree
Showing 80 changed files with 4,162 additions and 753 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Observable} from '../../../../core/bus/observable';
import {ExceptionId} from '../../../../exceptions/exceptions';
import {ChatAdapterExtras, DataTransferMode} from '../../../../types/aiChat/chatAdapter';
import {ChatAdapterExtras} from '../../../../types/adapters/chat/chaAdapterExtras';
import {DataTransferMode} from '../../../../types/adapters/chat/chatAdapter';
import {ControllerContext} from '../../../../types/controllerContext';
import {warn} from '../../../../x/warn';
import {CompConversation} from '../../conversation/conversation.model';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {comp} from '../../../core/aiChat/comp/comp';
import {CompEventListener, Model} from '../../../core/aiChat/comp/decorators';
import {HistoryPayloadSize} from '../../../core/aiChat/options/conversationOptions';
import {BotPersona, UserPersona} from '../../../core/aiChat/options/personaOptions';
import {isStandardChatAdapter, StandardChatAdapter} from '../../../types/aiChat/standardChatAdapter';
import {isStandardChatAdapter, StandardChatAdapter} from '../../../types/adapters/chat/standardChatAdapter';
import {ControllerContext} from '../../../types/controllerContext';
import {ConversationItem} from '../../../types/conversation';
import {CompConversation} from '../conversation/conversation.model';
Expand Down
20 changes: 9 additions & 11 deletions packages/js/core/src/core/aiChat/aiChat.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {registerAllComponents} from '../../components/components';
import {ChatAdapter} from '../../types/aiChat/chatAdapter';
import {ChatAdapterBuilder} from '../../types/aiChat/chatAdapterBuilder';
import {ChatAdapter} from '../../types/adapters/chat/chatAdapter';
import {ChatAdapterBuilder} from '../../types/adapters/chat/chatAdapterBuilder';
import {StandardChatAdapter} from '../../types/adapters/chat/standardChatAdapter';
import {IAiChat} from '../../types/aiChat/aiChat';
import {AiChatProps} from '../../types/aiChat/props';
import {StandardChatAdapter} from '../../types/aiChat/standardChatAdapter';
import {ConversationItem} from '../../types/conversation';
import {EventCallback, EventName, EventsMap} from '../../types/event';
import {debug} from '../../x/debug';
import {NluxRenderingError, NluxUsageError, NluxValidationError} from '../error';
import {IAiChat} from '../interface';
import {NluxController} from './controller/controller';
import {HighlighterExtension} from './highlighter/highlighter';
import {ConversationOptions} from './options/conversationOptions';
Expand Down Expand Up @@ -205,7 +205,6 @@ export class AiChat implements IAiChat {
}

const anAdapterOrAdapterBuilder = adapter as any;

if (typeof anAdapterOrAdapterBuilder.create === 'function') {
this.theAdapterType = 'builder';
this.theAdapterBuilder = anAdapterOrAdapterBuilder.create();
Expand Down Expand Up @@ -264,7 +263,7 @@ export class AiChat implements IAiChat {
});
}

this.theConversationOptions = conversationOptions;
this.theConversationOptions = {...conversationOptions};
return this;
}

Expand All @@ -283,7 +282,7 @@ export class AiChat implements IAiChat {
});
}

this.theInitialConversation = initialConversation;
this.theInitialConversation = [...initialConversation];
return this;
}

Expand All @@ -302,8 +301,7 @@ export class AiChat implements IAiChat {
});
}

this.theLayoutOptions = layoutOptions;

this.theLayoutOptions = {...layoutOptions};
return this;
}

Expand All @@ -322,7 +320,7 @@ export class AiChat implements IAiChat {
});
}

this.thePersonasOptions = personaOptions;
this.thePersonasOptions = {...personaOptions};
return this;
}

Expand All @@ -341,7 +339,7 @@ export class AiChat implements IAiChat {
});
}

this.thePromptBoxOptions = promptBoxOptions;
this.thePromptBoxOptions = {...promptBoxOptions};
return this;
}

Expand Down
Loading

0 comments on commit c8f3d68

Please sign in to comment.