@rimori/react-client 0.4.8-next.0 → 0.4.8-next.1

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.
@@ -9,6 +9,7 @@ interface Props {
9
9
  children?: React.ReactNode;
10
10
  autoStartConversation?: FirstMessages;
11
11
  className?: string;
12
+ knowledgeId?: string;
12
13
  }
13
- export declare function Avatar({ avatarImageUrl, voiceId, agentTools, autoStartConversation, children, circleSize, className, cache, }: Props): import("react/jsx-runtime").JSX.Element;
14
+ export declare function Avatar({ avatarImageUrl, voiceId, agentTools, autoStartConversation, children, circleSize, className, cache, knowledgeId, }: Props): import("react/jsx-runtime").JSX.Element;
14
15
  export {};
@@ -7,13 +7,13 @@ import { useChat } from '../../hooks/UseChatHook';
7
7
  import { useRimori } from '../../providers/PluginProvider';
8
8
  import { getFirstMessages } from './utils';
9
9
  import { useTheme } from '../../hooks/ThemeSetter';
10
- export function Avatar({ avatarImageUrl, voiceId, agentTools, autoStartConversation, children, circleSize = '300px', className, cache = false, }) {
10
+ export function Avatar({ avatarImageUrl, voiceId, agentTools, autoStartConversation, children, circleSize = '300px', className, cache = false, knowledgeId, }) {
11
11
  const { ai, event, plugin } = useRimori();
12
12
  const { isDark: isDarkThemeValue } = useTheme(plugin.theme);
13
13
  const [agentReplying, setAgentReplying] = useState(false);
14
14
  const [isProcessingMessage, setIsProcessingMessage] = useState(false);
15
15
  const sender = useMemo(() => new MessageSender((...args) => ai.getVoice(...args), voiceId, cache), [voiceId, ai, cache]);
16
- const { messages, append, isLoading, lastMessage, setMessages } = useChat(agentTools);
16
+ const { messages, append, isLoading, lastMessage, setMessages } = useChat(agentTools, { knowledgeId });
17
17
  useEffect(() => {
18
18
  console.log('messages', messages);
19
19
  }, [messages]);
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
2
  import { Tool } from '@rimori/client';
3
3
  import { Message } from '@rimori/client';
4
- export declare function useChat(tools?: Tool[]): {
4
+ export declare function useChat(tools?: Tool[], options?: {
5
+ knowledgeId?: string | (() => string | undefined);
6
+ }): {
5
7
  messages: Message[];
6
8
  append: (appendMessages: Message[]) => void;
7
9
  isLoading: boolean;
@@ -1,12 +1,13 @@
1
1
  import React from 'react';
2
2
  import { useRimori } from '../providers/PluginProvider';
3
- export function useChat(tools) {
3
+ export function useChat(tools, options) {
4
4
  const [messages, setMessages] = React.useState([]);
5
5
  const [isLoading, setIsLoading] = React.useState(false);
6
6
  const { ai } = useRimori();
7
7
  const append = (appendMessages) => {
8
8
  const allMessages = [...messages, ...appendMessages];
9
9
  setMessages(allMessages);
10
+ const knowledgeId = typeof (options === null || options === void 0 ? void 0 : options.knowledgeId) === 'function' ? options.knowledgeId() : options === null || options === void 0 ? void 0 : options.knowledgeId;
10
11
  ai.getSteamedText(allMessages, (id, message, finished, toolInvocations) => {
11
12
  const lastMessage = messages[messages.length - 1];
12
13
  setIsLoading(!finished);
@@ -17,7 +18,7 @@ export function useChat(tools) {
17
18
  else {
18
19
  setMessages([...allMessages, { id, role: 'assistant', content: message, toolCalls: toolInvocations }]);
19
20
  }
20
- }, tools);
21
+ }, tools, false, undefined, knowledgeId);
21
22
  };
22
23
  return {
23
24
  messages,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/react-client",
3
- "version": "0.4.8-next.0",
3
+ "version": "0.4.8-next.1",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "format": "prettier --write ."
24
24
  },
25
25
  "peerDependencies": {
26
- "@rimori/client": "^2.5.13",
26
+ "@rimori/client": "2.5.14-next.3",
27
27
  "react": "^18.1.0",
28
28
  "react-dom": "^18.1.0"
29
29
  },
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "devDependencies": {
36
36
  "@eslint/js": "^9.37.0",
37
- "@rimori/client": "^2.5.13",
37
+ "@rimori/client": "2.5.14-next.3",
38
38
  "@types/react": "^18.3.21",
39
39
  "eslint-config-prettier": "^10.1.8",
40
40
  "eslint-plugin-prettier": "^5.5.4",
@@ -18,6 +18,7 @@ interface Props {
18
18
  children?: React.ReactNode;
19
19
  autoStartConversation?: FirstMessages;
20
20
  className?: string;
21
+ knowledgeId?: string;
21
22
  }
22
23
 
23
24
  export function Avatar({
@@ -29,6 +30,7 @@ export function Avatar({
29
30
  circleSize = '300px',
30
31
  className,
31
32
  cache = false,
33
+ knowledgeId,
32
34
  }: Props) {
33
35
  const { ai, event, plugin } = useRimori();
34
36
  const { isDark: isDarkThemeValue } = useTheme(plugin.theme);
@@ -38,7 +40,7 @@ export function Avatar({
38
40
  () => new MessageSender((...args) => ai.getVoice(...args), voiceId, cache),
39
41
  [voiceId, ai, cache],
40
42
  );
41
- const { messages, append, isLoading, lastMessage, setMessages } = useChat(agentTools);
43
+ const { messages, append, isLoading, lastMessage, setMessages } = useChat(agentTools, { knowledgeId });
42
44
 
43
45
  useEffect(() => {
44
46
  console.log('messages', messages);
@@ -3,7 +3,7 @@ import { Tool } from '@rimori/client';
3
3
  import { useRimori } from '../providers/PluginProvider';
4
4
  import { Message, ToolInvocation } from '@rimori/client';
5
5
 
6
- export function useChat(tools?: Tool[]) {
6
+ export function useChat(tools?: Tool[], options?: { knowledgeId?: string | (() => string | undefined) }) {
7
7
  const [messages, setMessages] = React.useState<Message[]>([]);
8
8
  const [isLoading, setIsLoading] = React.useState(false);
9
9
  const { ai } = useRimori();
@@ -11,6 +11,7 @@ export function useChat(tools?: Tool[]) {
11
11
  const append = (appendMessages: Message[]) => {
12
12
  const allMessages = [...messages, ...appendMessages];
13
13
  setMessages(allMessages);
14
+ const knowledgeId = typeof options?.knowledgeId === 'function' ? options.knowledgeId() : options?.knowledgeId;
14
15
  ai.getSteamedText(
15
16
  allMessages,
16
17
  (id, message, finished: boolean, toolInvocations?: ToolInvocation[]) => {
@@ -25,6 +26,9 @@ export function useChat(tools?: Tool[]) {
25
26
  }
26
27
  },
27
28
  tools,
29
+ false,
30
+ undefined,
31
+ knowledgeId,
28
32
  );
29
33
  };
30
34