mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-10-12 16:09:33 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 38226b9413 |
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"gitbook": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Simplify AI Chat
|
||||||
@@ -21,6 +21,7 @@ export type AIChatMessage = {
|
|||||||
role: AIMessageRole;
|
role: AIMessageRole;
|
||||||
content: React.ReactNode;
|
content: React.ReactNode;
|
||||||
query?: string;
|
query?: string;
|
||||||
|
note?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type AIChatPendingTool = {
|
export type AIChatPendingTool = {
|
||||||
@@ -391,11 +392,11 @@ export function AIChatProvider(props: {
|
|||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
messages: [
|
messages: [
|
||||||
...state.messages,
|
|
||||||
{
|
{
|
||||||
role: AIMessageRole.User,
|
role: AIMessageRole.User,
|
||||||
content: input.message,
|
content: input.message,
|
||||||
query: input.message,
|
query: input.message,
|
||||||
|
note: state.messages.length > 0 ? 'Starting a new chat' : undefined,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
query: input.message,
|
query: input.message,
|
||||||
|
|||||||
@@ -6,14 +6,13 @@ import type React from 'react';
|
|||||||
import type { AIChatController, AIChatState } from '../AI';
|
import type { AIChatController, AIChatState } from '../AI';
|
||||||
import { AIChatToolConfirmations } from './AIChatToolConfirmations';
|
import { AIChatToolConfirmations } from './AIChatToolConfirmations';
|
||||||
import { AIResponseFeedback } from './AIResponseFeedback';
|
import { AIResponseFeedback } from './AIResponseFeedback';
|
||||||
import { AIChatFollowupSuggestions } from './AiChatFollowupSuggestions';
|
|
||||||
|
|
||||||
export function AIChatMessages(props: {
|
export function AIChatMessages(props: {
|
||||||
chat: AIChatState;
|
chat: AIChatState;
|
||||||
chatController: AIChatController;
|
chatController: AIChatController;
|
||||||
lastUserMessageRef?: React.RefObject<HTMLDivElement>;
|
lastUserMessageRef?: React.RefObject<HTMLDivElement>;
|
||||||
}) {
|
}) {
|
||||||
const { chat, chatController, lastUserMessageRef } = props;
|
const { chat, lastUserMessageRef } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -24,6 +23,15 @@ export function AIChatMessages(props: {
|
|||||||
index === chat.messages.map((m) => m.role).lastIndexOf(AIMessageRole.User);
|
index === chat.messages.map((m) => m.role).lastIndexOf(AIMessageRole.User);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
|
{message.note ? (
|
||||||
|
<div
|
||||||
|
key={`${index}-note`}
|
||||||
|
className="self-center text-tint-subtle text-xs"
|
||||||
|
>
|
||||||
|
{message.note}
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
<div
|
<div
|
||||||
ref={isLastUserMessage ? lastUserMessageRef : undefined}
|
ref={isLastUserMessage ? lastUserMessageRef : undefined}
|
||||||
data-testid="ai-chat-message"
|
data-testid="ai-chat-message"
|
||||||
@@ -68,13 +76,10 @@ export function AIChatMessages(props: {
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
<AIChatToolConfirmations chat={chat} />
|
<AIChatToolConfirmations chat={chat} />
|
||||||
<AIChatFollowupSuggestions
|
|
||||||
chat={chat}
|
|
||||||
chatController={chatController}
|
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</>
|
</>
|
||||||
|
|||||||
Reference in New Issue
Block a user