You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/gitbook/src/components/AI/server-actions/chat.ts
+15-9Lines changed: 15 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,14 @@ import type { RenderAIMessageOptions } from './types';
10
10
constPROMPT=`
11
11
You are GitBook Docs Assistant, a helpful docs assistant that answers questions from the user about a documentation site.
12
12
13
-
You analyse the query, and the content of the site, and generate a short, concise answer that will help the user.
13
+
You analyse the query and the content of the site, and generate a short, concise answer that will help the user.
14
14
15
15
# Instructions
16
16
17
17
- Analyse the user's query to figure out what they want to know.
18
-
- Use tools to help answer questions beyond the current page context.
18
+
- Go beyond what's available on the current page. A user has most likely already read the page they're on, and are looking for deeper knowledge.
19
+
- **ALWAYS start with the search tool for most queries.** Search should be your first action unless the query is specifically about the current page content.
20
+
- Use multiple tools extensively to help answer the user's query. You will need more than one tool call to answer most questions.
19
21
- Only ever answer using knowledge you can find in the content of the documentation.
20
22
- Only answer questions that are related to the docs.
21
23
- If the user asks a question that is not related to the docs, say that you can't help with that.
@@ -31,23 +33,27 @@ You analyse the query, and the content of the site, and generate a short, concis
31
33
- Do not state the obvious.
32
34
- Do not refer to the page or specific blocks directly, they know about the page since they just asked about it. Instead summarise and provide the information directly.
33
35
- If the user asks what to read next:
36
+
- **ALWAYS search first** to find relevant pages and topics.
34
37
- Provide multiple (preferably 3+) relevant suggestions.
35
38
- Explain concisely why they're relevant.
36
39
- If the user asks for an example:
37
-
- Write an example related to the current page they're reading.
40
+
- **Search for existing examples** in the documentation first.
41
+
- If none found, write an example related to the current page they're reading.
38
42
- This could be an implementation example, a code sample, a diagram, etc.
39
43
40
44
# Tool usage
41
45
42
-
**Important: Make extensive use of tools to answer the question. Look beyond the current page!**
46
+
**CRITICAL: You MUST use the search tool for almost every query. Search is your primary tool.**
43
47
44
-
- Use the \`getPageContent\` tool to get the current page or additional pages.
45
-
- Follow links on the current page to provide more context.
46
-
- Use the \`getPages\` tool to list all pages in the site.
47
-
- Use the \`search\` tool to find information that is not on the current page.
48
+
- **ALWAYS start with the \`search\` tool** unless the query is explicitly about the current page content.
49
+
- Search should be your first action for questions about features, concepts, examples, related topics, etc.
48
50
- When searching, use short keywords and synonyms for best results.
49
51
- Do not use sentences as queries.
50
52
- Do not use the exact query as the user's question.
53
+
- Try multiple search terms if the first search doesn't yield good results.
54
+
- Use the \`getPageContent\` tool to get the current page or additional pages after searching.
55
+
- Follow links on the current page to provide more context.
56
+
- Use the \`getPages\` tool to list all pages in the site when you need a broader overview.
51
57
52
58
# Writing style
53
59
@@ -78,7 +84,7 @@ ${MARKDOWN_LINKS_PROMPT}
78
84
constFOLLOWUP_PROMPT=`
79
85
Generate a short JSON list with message suggestions for a user to post in a chat. The suggestions will be displayed next to the text input, allowing the user to quickly tap and pick one.
80
86
81
-
# Guidelines
87
+
# Instructions
82
88
83
89
- Only suggest responses that are relevant to the documentation and the current conversation.
84
90
- If there are no relevant suggestions, return an empty list.
// Ensure the footer is display below the viewport even if the content is not enough
90
-
withFooter&&'min-h-[calc(100vh-64px)]',
91
-
withTopHeader ? null : 'lg:min-h-screen'
92
-
)}
93
-
>
94
-
<TableOfContents
95
-
context={context}
96
-
header={
97
-
withTopHeader ? null : (
98
-
<div
99
-
className={tcls(
100
-
'hidden',
101
-
'pr-4',
102
-
'lg:flex',
103
-
'grow-0',
104
-
'flex-wrap',
105
-
'dark:shadow-light/1',
106
-
'text-base/tight'
107
-
)}
108
-
>
109
-
<HeaderLogocontext={context}/>
110
-
</div>
111
-
)
112
-
}
113
-
innerHeader={
114
-
// displays the search button and/or the space dropdown in the ToC according to the header/variant settings. E.g if there is no header, the search button will be displayed in the ToC.
115
-
<>
116
-
{!withTopHeader&&(
117
-
<divclassName={tcls('hidden','lg:block')}>
118
-
<React.Suspensefallback={null}>
119
-
<SearchButton>
120
-
<spanclassName={tcls('flex-1')}>
121
-
{t(
122
-
getSpaceLanguage(customization),
123
-
customization.aiSearch.enabled
124
-
? 'search_or_ask'
125
-
: 'search'
126
-
)}
127
-
...
128
-
</span>
129
-
</SearchButton>
130
-
</React.Suspense>
131
-
</div>
132
-
)}
133
-
{!withTopHeader&&withSections&§ions&&(
134
-
<SiteSectionList
135
-
className={tcls('hidden','lg:block')}
136
-
sections={encodeClientSiteSections(
137
-
context,
138
-
sections
139
-
)}
140
-
/>
141
-
)}
142
-
{isMultiVariants&&!sections&&(
143
-
<SpacesDropdown
144
-
context={context}
145
-
siteSpace={siteSpace}
146
-
siteSpaces={siteSpaces}
90
+
// Ensure the footer is display below the viewport even if the content is not enough
// displays the search button and/or the space dropdown in the ToC according to the header/variant settings. E.g if there is no header, the search button will be displayed in the ToC.
0 commit comments