@agentscope-ai/chat 1.1.70 → 1.1.71-beta.1781610744021

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/components/AgentScopeRuntimeWebUI/core/Chat/Input/index.tsx +38 -5
  2. package/components/AgentScopeRuntimeWebUI/core/Chat/InputQueue/Panel.tsx +82 -0
  3. package/components/AgentScopeRuntimeWebUI/core/Chat/InputQueue/__tests__/inputQueue.test.ts +112 -0
  4. package/components/AgentScopeRuntimeWebUI/core/Chat/InputQueue/index.ts +122 -0
  5. package/components/AgentScopeRuntimeWebUI/core/Chat/hooks/useChatController.tsx +111 -4
  6. package/components/AgentScopeRuntimeWebUI/core/Chat/index.tsx +21 -3
  7. package/components/AgentScopeRuntimeWebUI/core/Chat/styles.tsx +68 -1
  8. package/components/AgentScopeRuntimeWebUI/core/ChatAnywhere/index.tsx +1 -1
  9. package/components/AgentScopeRuntimeWebUI/core/Context/ChatAnywhereI18nContext.tsx +14 -0
  10. package/components/AgentScopeRuntimeWebUI/starter/index.tsx +100 -14
  11. package/components/AgentScopeRuntimeWebUI/starterForMe/index.tsx +31 -0
  12. package/lib/AgentScopeRuntimeWebUI/core/Chat/Input/index.d.ts +8 -0
  13. package/lib/AgentScopeRuntimeWebUI/core/Chat/Input/index.js +36 -8
  14. package/lib/AgentScopeRuntimeWebUI/core/Chat/InputQueue/Panel.d.ts +9 -0
  15. package/lib/AgentScopeRuntimeWebUI/core/Chat/InputQueue/Panel.js +78 -0
  16. package/lib/AgentScopeRuntimeWebUI/core/Chat/InputQueue/index.d.ts +37 -0
  17. package/lib/AgentScopeRuntimeWebUI/core/Chat/InputQueue/index.js +74 -0
  18. package/lib/AgentScopeRuntimeWebUI/core/Chat/hooks/useChatController.d.ts +7 -0
  19. package/lib/AgentScopeRuntimeWebUI/core/Chat/hooks/useChatController.js +204 -63
  20. package/lib/AgentScopeRuntimeWebUI/core/Chat/index.js +14 -2
  21. package/lib/AgentScopeRuntimeWebUI/core/Chat/styles.js +31 -1
  22. package/lib/AgentScopeRuntimeWebUI/core/Context/ChatAnywhereI18nContext.d.ts +11 -1
  23. package/lib/AgentScopeRuntimeWebUI/core/Context/ChatAnywhereI18nContext.js +12 -0
  24. package/lib/AgentScopeRuntimeWebUI/starter/index.js +144 -20
  25. package/lib/AgentScopeRuntimeWebUI/starterForMe/index.d.ts +1 -0
  26. package/lib/AgentScopeRuntimeWebUI/starterForMe/index.js +34 -0
  27. package/package.json +2 -1
  28. package/bin/starter_webui/README.md +0 -75
  29. package/bin/starter_webui/eslint.config.js +0 -28
  30. package/bin/starter_webui/index.html +0 -12
  31. package/bin/starter_webui/package.json +0 -34
  32. package/bin/starter_webui/src/App.tsx +0 -20
  33. package/bin/starter_webui/src/components/Chat/OptionsPanel/FormItem.tsx +0 -37
  34. package/bin/starter_webui/src/components/Chat/OptionsPanel/OptionsEditor.tsx +0 -160
  35. package/bin/starter_webui/src/components/Chat/OptionsPanel/defaultConfig.ts +0 -41
  36. package/bin/starter_webui/src/components/Chat/OptionsPanel/index.tsx +0 -27
  37. package/bin/starter_webui/src/components/Chat/index.tsx +0 -45
  38. package/bin/starter_webui/src/components/Chat/sessionApi/index.ts +0 -53
  39. package/bin/starter_webui/src/main.tsx +0 -9
  40. package/bin/starter_webui/src/vite-env.d.ts +0 -4
  41. package/bin/starter_webui/tsconfig.app.json +0 -24
  42. package/bin/starter_webui/tsconfig.json +0 -7
  43. package/bin/starter_webui/tsconfig.node.json +0 -22
  44. package/bin/starter_webui/vite.config.ts +0 -11
@@ -1,41 +0,0 @@
1
- export default {
2
- theme: {
3
- colorPrimary: '#615CED',
4
- darkMode: true,
5
- prefix: 'agentscope-runtime-webui',
6
- leftHeader: {
7
- logo: 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
8
- title: 'Runtime WebUI',
9
- },
10
- },
11
- sender: {
12
- attachments: false,
13
- maxLength: 10000,
14
- disclaimer:
15
- 'AI can also make mistakes, so please check carefully and use it with caution',
16
- },
17
-
18
- welcome: {
19
- greeting: 'Hello, how can I help you today?',
20
- description:
21
- 'I am a helpful assistant that can help you with your questions.',
22
- avatar:
23
- 'https://img.alicdn.com/imgextra/i2/O1CN01lmoGYn1kjoXATy4PX_!!6000000004720-2-tps-200-200.png',
24
- prompts: [
25
- {
26
- value: 'Hello',
27
- },
28
- {
29
- value: 'How are you?',
30
- },
31
- {
32
- value: 'What can you do?',
33
- },
34
- ],
35
- },
36
- api: {
37
- baseURL: BASE_URL,
38
- token: TOKEN,
39
- },
40
- };
41
-
@@ -1,27 +0,0 @@
1
- import { SparkSettingLine } from "@agentscope-ai/icons";
2
- import { IconButton, Drawer } from "@agentscope-ai/design";
3
- import { useState } from "react";
4
- import OptionsEditor from "./OptionsEditor";
5
-
6
- interface OptionsPanelProps {
7
- value?: any;
8
- onChange?: any;
9
- }
10
-
11
- export default function OptionsPanel(props: OptionsPanelProps) {
12
- const [open, setOpen] = useState(false);
13
-
14
- return <>
15
- <IconButton onClick={() => setOpen(true)} icon={<SparkSettingLine />} bordered={false} />
16
- <Drawer
17
- destroyOnHidden
18
- open={open}
19
- onClose={() => setOpen(false)}
20
- styles={{ body: { padding: 0 }, header: { padding: 8 } }}>
21
- <OptionsEditor value={props.value} onChange={(v: typeof props.value) => {
22
- setOpen(false);
23
- props.onChange(v);
24
- }} />
25
- </Drawer>
26
- </>
27
- }
@@ -1,45 +0,0 @@
1
- import { AgentScopeRuntimeWebUI, IAgentScopeRuntimeWebUIOptions } from '@agentscope-ai/chat';
2
- import OptionsPanel from './OptionsPanel';
3
- import { useMemo } from 'react';
4
- import sessionApi from './sessionApi';
5
- import { useLocalStorageState } from 'ahooks';
6
- import defaultConfig from './OptionsPanel/defaultConfig';
7
-
8
- export default function () {
9
- const [optionsConfig, setOptionsConfig] = useLocalStorageState('agent-scope-runtime-webui-options', {
10
- defaultValue: defaultConfig,
11
- listenStorageChange: true,
12
- });
13
-
14
- const options = useMemo(() => {
15
- const rightHeader = <OptionsPanel value={optionsConfig} onChange={(v: typeof optionsConfig) => {
16
- setOptionsConfig(prev => ({
17
- ...prev,
18
- ...v,
19
- }));
20
- }} />;
21
-
22
-
23
-
24
- return {
25
- ...optionsConfig,
26
- session: {
27
- multiple: true,
28
- api: sessionApi,
29
- },
30
- theme: {
31
- ...optionsConfig.theme,
32
- rightHeader,
33
- },
34
- };
35
- }, [optionsConfig]);
36
-
37
-
38
-
39
-
40
- return <div style={{ height: '100vh' }}>
41
- <AgentScopeRuntimeWebUI
42
- options={options as unknown as IAgentScopeRuntimeWebUIOptions}
43
- />
44
- </div>;
45
- }
@@ -1,53 +0,0 @@
1
- import {
2
- IAgentScopeRuntimeWebUISession,
3
- IAgentScopeRuntimeWebUISessionAPI,
4
- } from '@agentscope-ai/chat';
5
-
6
- class SessionApi implements IAgentScopeRuntimeWebUISessionAPI {
7
- private lsKey: string;
8
- private sessionList: IAgentScopeRuntimeWebUISession[];
9
-
10
- constructor() {
11
- this.lsKey = 'agent-scope-runtime-webui-sessions';
12
- this.sessionList = [];
13
- }
14
-
15
- async getSessionList() {
16
- this.sessionList = JSON.parse(localStorage.getItem(this.lsKey) || '[]');
17
- return [...this.sessionList];
18
- }
19
-
20
- async getSession(sessionId: string) {
21
- return this.sessionList.find((session) => session.id === sessionId) as IAgentScopeRuntimeWebUISession;
22
- }
23
-
24
- async updateSession(session: Partial<IAgentScopeRuntimeWebUISession>) {
25
- const index = this.sessionList.findIndex((item) => item.id === session.id);
26
- if (index > -1) {
27
- this.sessionList[index] = {
28
- ...this.sessionList[index],
29
- ...session,
30
- };
31
- localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
32
- }
33
-
34
- return [...this.sessionList];
35
- }
36
-
37
- async createSession(session: Partial<IAgentScopeRuntimeWebUISession>) {
38
- session.id = Date.now().toString();
39
- this.sessionList.unshift(session as IAgentScopeRuntimeWebUISession);
40
- localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
41
- return [...this.sessionList];
42
- }
43
-
44
- async removeSession(session: Partial<IAgentScopeRuntimeWebUISession>) {
45
- this.sessionList = this.sessionList.filter(
46
- (item) => item.id !== session.id,
47
- );
48
- localStorage.setItem(this.lsKey, JSON.stringify(this.sessionList));
49
- return [...this.sessionList];
50
- }
51
- }
52
-
53
- export default new SessionApi();
@@ -1,9 +0,0 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import App from './App.tsx'
4
-
5
- createRoot(document.getElementById('root')!).render(
6
- <StrictMode>
7
- <App />
8
- </StrictMode>,
9
- )
@@ -1,4 +0,0 @@
1
- /// <reference types="vite/client" />
2
-
3
- declare const BASE_URL: string;
4
- declare const TOKEN: string;
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4
- "target": "ES2020",
5
- "useDefineForClassFields": true,
6
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
- "module": "ESNext",
8
- "skipLibCheck": true,
9
-
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "moduleDetection": "force",
13
- "noEmit": true,
14
- "jsx": "react-jsx",
15
-
16
- "strict": true,
17
- "noUnusedLocals": true,
18
- "noUnusedParameters": true,
19
- "erasableSyntaxOnly": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedSideEffectImports": true
22
- },
23
- "include": ["src"]
24
- }
@@ -1,7 +0,0 @@
1
- {
2
- "files": [],
3
- "references": [
4
- { "path": "./tsconfig.app.json" },
5
- { "path": "./tsconfig.node.json" }
6
- ]
7
- }
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
4
- "target": "ES2022",
5
- "lib": ["ES2023"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
-
9
- "moduleResolution": "bundler",
10
- "allowImportingTsExtensions": true,
11
- "moduleDetection": "force",
12
- "noEmit": true,
13
-
14
- "strict": true,
15
- "noUnusedLocals": true,
16
- "noUnusedParameters": true,
17
- "erasableSyntaxOnly": true,
18
- "noFallthroughCasesInSwitch": true,
19
- "noUncheckedSideEffectImports": true
20
- },
21
- "include": ["vite.config.ts"]
22
- }
@@ -1,11 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
3
-
4
- export default defineConfig({
5
- define: {
6
- BASE_URL: JSON.stringify(process.env.BASE_URL || ''),
7
- TOKEN: JSON.stringify(process.env.TOKEN || ''),
8
- MOBILE: false,
9
- },
10
- plugins: [react()],
11
- })