Skip to content

Commit

Permalink
feat: support custom chat render (#3499)
Browse files Browse the repository at this point in the history
Co-authored-by: 野声 <lijiacheng.ljc@antgroup.com>
  • Loading branch information
Ricbet and bytemain authored Apr 10, 2024
1 parent 55b36cc commit ed65cb4
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 102 deletions.
8 changes: 8 additions & 0 deletions packages/ai-native/src/browser/ai-core.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { InlineChatIsVisible } from '@opensumi/ide-core-browser/lib/contextkey/a
import { LayoutViewSizeConfig } from '@opensumi/ide-core-browser/lib/layout/constants';
import {
ChatFeatureRegistryToken,
ChatRenderRegistryToken,
CommandService,
InlineChatFeatureRegistryToken,
RenameCandidatesProviderRegistryToken,
Expand All @@ -50,6 +51,7 @@ import { AIChatTabRenderer, AILeftTabRenderer, AIRightTabRenderer } from './layo
import {
AINativeCoreContribution,
IChatFeatureRegistry,
IChatRenderRegistry,
IInlineChatFeatureRegistry,
IRenameCandidatesProviderRegistry,
IResolveConflictRegistry,
Expand Down Expand Up @@ -89,6 +91,9 @@ export class AINativeBrowserContribution
@Autowired(ChatFeatureRegistryToken)
private readonly chatFeatureRegistry: IChatFeatureRegistry;

@Autowired(ChatRenderRegistryToken)
private readonly chatRenderRegistry: IChatRenderRegistry;

@Autowired(ResolveConflictRegistryToken)
private readonly resolveConflictRegistry: IResolveConflictRegistry;

Expand Down Expand Up @@ -162,6 +167,9 @@ export class AINativeBrowserContribution
if (contribution.registerRenameProvider) {
contribution.registerRenameProvider(this.renameCandidatesProviderRegistry);
}
if (contribution.registerChatRender) {
contribution.registerChatRender(this.chatRenderRegistry);
}
});
}

Expand Down
34 changes: 34 additions & 0 deletions packages/ai-native/src/browser/chat/chat.render.registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Injectable } from '@opensumi/di';
import { Disposable } from '@opensumi/ide-core-common';

import {
ChatAIRoleRender,
ChatThinkingRender,
ChatUserRoleRender,
ChatWelcomeRender,
IChatRenderRegistry,
} from '../types';

@Injectable()
export class ChatRenderRegistry extends Disposable implements IChatRenderRegistry {
public chatWelcomeRender?: ChatWelcomeRender;
public chatAIRoleRender?: ChatAIRoleRender;
public chatUserRoleRender?: ChatUserRoleRender;
public chatThinkingRender?: ChatThinkingRender;

registerWelcomeRender(render: ChatWelcomeRender): void {
this.chatWelcomeRender = render;
}

registerAIRoleRender(render: ChatAIRoleRender): void {
this.chatAIRoleRender = render;
}

registerUserRoleRender(render: ChatUserRoleRender): void {
this.chatUserRoleRender = render;
}

registerThinkingRender(render: ChatThinkingRender): void {
this.chatThinkingRender = render;
}
}
Loading

0 comments on commit ed65cb4

Please sign in to comment.