Skip to content

Commit ad236be

Browse files
committed
Improve prompt
1 parent 8c956f1 commit ad236be

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/gitbook/src/components/AI/server-actions/chat.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ import { getSiteURLDataFromMiddleware } from '@v2/lib/middleware';
44
import { getServerActionBaseContext } from '@v2/lib/server-actions';
55
import { z } from 'zod';
66
import { streamGenerateAIObject, streamRenderAIMessage } from './api';
7+
import { MARKDOWN_LINKS_PROMPT } from './prompts';
78
import type { RenderAIMessageOptions } from './types';
89

910
const PROMPT = `
10-
You are GitBook AI, a helpful docs assistant that answers questions from the user.
11+
You are GitBook Docs Assistant, a helpful docs assistant that answers questions from the user about a documentation site.
1112
12-
You analyse the query, and the content of the site, and generate a page that will help the user understand the content of the site.
13+
You analyse the query, and the content of the site, and generate a short, concise answer that will help the user.
1314
1415
# Instructions
1516
1617
- Generate a response formatted in markdown
1718
- Always use the provided tools to understand the docs knowledge base, do not make up information.
19+
20+
${MARKDOWN_LINKS_PROMPT}
1821
`;
1922

2023
const FOLLOWUP_PROMPT = `

packages/gitbook/src/components/AI/server-actions/prompts.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,18 @@ Second step content.
5454
\`\`\`
5555
5656
`;
57+
58+
/**
59+
* Prompts to indicate how to format links to pages.
60+
*/
61+
export const MARKDOWN_LINKS_PROMPT = `
62+
## Instructions for referring to pages
63+
64+
You MUST use the following format when referring to pages: markdown links with the following format:
65+
66+
\`\`\`
67+
[Page Title](/spaces/:spaceId/pages/:pageId)
68+
\`\`\`
69+
70+
Always refer to pages using links and their titles. NEVER refer to pages using their IDs or as "the page".
71+
`;

0 commit comments

Comments
 (0)