Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
.idea
temp*
.tmp-aigc-dts
robotMsg.json
.history

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "packages/common"]
path = packages/common
url = https://github.com/Tencent/tdesign-common.git
[submodule "packages/ai-core"]
path = packages/ai-core
url = https://github.com/TDesignOteam/tdesign-ai-core.git
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"glob": "^9.0.3",
"happy-dom": "^15.11.0",
"husky": "^7.0.4",
"immer": "^10.0.0",
"jest-canvas-mock": "^2.4.0",
"jsdom": "^20.0.1",
"less": "4.4.2",
Expand Down Expand Up @@ -146,6 +147,7 @@
"@popperjs/core": "~2.11.2",
"tdesign-react": "workspace:^",
"@tdesign-react/chat": "workspace:^",
"@tdesign/ai-chat-engine": "workspace:^",
"@tdesign/common": "workspace:^",
"@tdesign/common-docs": "workspace:^",
"@tdesign/common-js": "workspace:^",
Expand Down
1 change: 1 addition & 0 deletions packages/ai-core
Submodule ai-core added at 129aae
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useMemo } from 'react';
import { Card, Space, Button, Divider } from 'tdesign-react';
import { AGUIAdapter } from 'tdesign-web-components/lib/chat-engine';
import type { AGUIHistoryMessage, AGUIActivityMessage } from 'tdesign-web-components/lib/chat-engine';
import { AGUIAdapter } from '@tdesign-react/chat';
import type { AGUIHistoryMessage, AGUIActivityMessage } from '@tdesign-react/chat';

/**
* AG-UI 历史消息转换测试
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { useEffect, useState, useRef } from 'react';
import { Button, Card, Space, Tag, Divider, List, MessagePlugin } from 'tdesign-react';
import ChatEngine, {
ChatEngineEventType,
type SSEChunkData,
type AIMessageContent,
} from 'tdesign-web-components/lib/chat-engine';
import { ChatEngine, ChatEngineEventType, type SSEChunkData, type AIMessageContent } from '@tdesign-react/chat';

/**
* Headless 事件总线示例
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React, { useEffect, useRef } from 'react';
import { Card, Button, Space, Divider } from 'tdesign-react';
import ChatEngine, {
ChatEngineEventType,
type SSEChunkData,
type AIMessageContent,
} from 'tdesign-web-components/lib/chat-engine';
import { ChatEngine, ChatEngineEventType, type SSEChunkData, type AIMessageContent } from '@tdesign-react/chat';

/**
* 纯 Headless 示例 - 无 UI 依赖的 ChatEngine 使用方式
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useState, useEffect, useMemo, Component, ErrorInfo } from 'react';
import isEqual from 'react-fast-compare';
import { type ActivityData } from 'tdesign-web-components';
import { type ActivityData } from '@tdesign/ai-chat-engine';
import type { ActivityComponentProps } from './types';
import { activityRegistry } from './registry';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect, useCallback, useMemo, Component, ErrorInfo } from 'react';
import { AGUIEventType, ToolCall } from 'tdesign-web-components/lib/chat-engine';
import { AGUIEventType, ToolCall } from '@tdesign/ai-chat-engine';
import { isNonInteractiveConfig, type ToolcallComponentProps } from './types';
import { agentToolcallRegistry } from './registry';
import { AgentStateContext, useAgentStateDataByKey } from '../../hooks/useAgentState';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* eslint-disable react-hooks/exhaustive-deps */
import { useState, useEffect, useRef, createContext, useContext, useMemo } from 'react';
// import { stateManager } from 'tdesign-web-components/lib/chat-engine';
import { stateManager } from 'tdesign-web-components/lib/chat-engine';
import { stateManager } from '@tdesign/ai-chat-engine';

/**
* 状态订阅相关类型定义
Expand Down
6 changes: 2 additions & 4 deletions packages/pro-components/chat/chat-engine/hooks/useChat.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useEffect, useRef, useState } from 'react';
import ChatEngine from 'tdesign-web-components/lib/chat-engine';
import type { ChatMessagesData, ChatServiceConfig, ChatStatus } from 'tdesign-web-components/lib/chat-engine';
// import ChatEngine from 'tdesign-web-components/lib/chat-engine';
// import type { ChatMessagesData, ChatServiceConfig, ChatStatus } from 'tdesign-web-components/lib/chat-engine';
import ChatEngine from '@tdesign/ai-chat-engine';
import type { ChatMessagesData, ChatServiceConfig, ChatStatus } from '@tdesign/ai-chat-engine';

export type IUseChat = {
defaultMessages?: ChatMessagesData[];
Expand Down
67 changes: 65 additions & 2 deletions packages/pro-components/chat/chat-engine/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,70 @@
// React hooks
export * from './hooks/useChat';
export * from './hooks/useAgentToolcall';
export * from './hooks/useAgentState';
export * from './hooks/useAgentActivity';
// React components
export * from './components';
// export * from './core'; // 用于调试
export * from 'tdesign-web-components/lib/chat-engine';

// Re-export core API from @tdesign/ai-chat-engine
// For full core API, use: import { ... } from '@tdesign/ai-chat-engine'
export { default as ChatEngine } from '@tdesign/ai-chat-engine';
export { ChatEngineEventType, ChatEventBus, createEventBus } from '@tdesign/ai-chat-engine';
export { AGUIAdapter, stateManager, activityManager } from '@tdesign/ai-chat-engine';
export {
isAIMessage,
isUserMessage,
isTextContent,
isMarkdownContent,
isToolCallContent,
isActivityContent,
isThinkingContent,
isReasoningContent,
isSearchContent,
isSuggestionContent,
isAttachmentContent,
isImageContent,
applyJsonPatch,
safeParseJSON,
getMessageContentForCopy,
findTargetElement,
} from '@tdesign/ai-chat-engine';
export { AGUIEventType } from '@tdesign/ai-chat-engine';

// Re-export commonly used types
export type {
ChatMessagesData,
ChatServiceConfig,
ChatServiceConfigSetter,
ChatStatus,
ChatMessageStatus,
ChatMessageRole,
ChatRequestParams,
ChatMessageSetterMode,
AIMessageContent,
UserMessageContent,
SSEChunkData,
IChatEngine,
IChatEventBus,
UserMessage,
AIMessage,
SystemMessage,
ToolCall,
ToolCallContent,
ActivityData,
ActivityContent,
TextContent,
MarkdownContent,
ThinkingContent,
ReasoningContent,
SearchContent,
SuggestionContent,
ImageContent,
AttachmentContent,
AttachmentItem,
ChatBaseContent,
ChatContentType,
ChatEventBusOptions,
AGUIHistoryMessage,
AGUIActivityMessage,
} from '@tdesign/ai-chat-engine';
5 changes: 5 additions & 0 deletions packages/tdesign-react-aigc/site/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import path from 'path';
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import tdocPlugin from './plugin-tdoc';
import pkg from '../package.json';

const publicPathMap = {
preview: '/',
Expand All @@ -25,6 +26,7 @@ export default ({ mode }) =>
resolve: {
alias: {
'@tdesign-react/chat': path.resolve(__dirname, '../../pro-components/chat'),
'@tdesign/ai-chat-engine': path.resolve(__dirname, '../../ai-core/packages/chat-engine/index.ts'),
'@tdesign/react-aigc-site': path.resolve(__dirname, './'),
'tdesign-react/es': path.resolve(__dirname, '../../components'),
'tdesign-react': path.resolve(__dirname, '../../components'),
Expand All @@ -38,6 +40,9 @@ export default ({ mode }) =>
},
},
},
define: {
__VERSION__: JSON.stringify(pkg.version),
},
jsx: 'react',
server: {
host: '0.0.0.0',
Expand Down
3 changes: 2 additions & 1 deletion script/rollup.aigc.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import { resolve } from 'path';
import pkg from '../packages/tdesign-react-aigc/package.json';

const name = 'tdesign';
const externalDeps = Object.keys(pkg.dependencies || {});
const internalWorkspaceDeps = ['@tdesign/ai-chat-engine', '@tdesign/ai-shared'];
const externalDeps = Object.keys(pkg.dependencies || {}).filter((dep) => !internalWorkspaceDeps.includes(dep));
const externalPeerDeps = Object.keys(pkg.peerDependencies || {});

// 分析模式配置
Expand Down
9 changes: 8 additions & 1 deletion tsconfig.aigc.build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"extends": "./tsconfig",
"include": ["packages/pro-components/chat"],
"exclude": ["**/**/__tests__/*", "**/**/_example/*", "**/**/_example-js/*","**/**/_usage/*", "es", "node_modules"],
"exclude": [
"**/**/__tests__/*",
"**/**/_example/*",
"**/**/_example-js/*",
"**/**/_usage/*",
"es",
"node_modules"
],
"compilerOptions": {
"jsx": "react-jsx",
"emitDeclarationOnly": true,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
],
"@common/*": [
"packages/common/*"
]
],
},
"allowJs": true,
"checkJs": true,
Expand Down
Loading