Skip to content

Commit cfa71c2

Browse files
committed
add format instructions
1 parent 9e1e37a commit cfa71c2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ export const DEFAULT_MODEL_ON_ENABLE = 'gpt-5'
5555

5656
export const DEFAULT_ASSISTANT_INSTRUCTIONS = '' // 11th August 2025 we decided it should be empty
5757
export const DEFAULT_MODEL_TEMPERATURE = 0.5
58+
59+
export const formatInstructions = `
60+
Always format responses in plain Markdown.
61+
Use Markdown headings (#, ##, ###) for structure, even for normal text.
62+
Use lists, tables, and blockquotes where useful.
63+
Put math in $$ ... $$ for LaTeX rendering.
64+
Wrap code in triple backticks with the correct language tag (js, ts, py, etc.) so syntax highlighting and rendering work.
65+
`

src/server/services/langchain/chat.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { Runnable } from '@langchain/core/runnables'
55
import type { StructuredTool } from '@langchain/core/tools'
66
import { concat } from '@langchain/core/utils/stream'
77
import { AzureChatOpenAI } from '@langchain/openai'
8-
import { ValidModelName, validModels } from '../../../config'
8+
import { formatInstructions, ValidModelName, validModels } from '../../../config'
99
import type { ChatEvent } from '../../../shared/chat'
1010
import type { ChatMessage } from '../../../shared/chat'
1111
import type { ChatToolDef, ChatToolOutput } from '../../../shared/tools'
@@ -68,6 +68,10 @@ export const streamChat = async ({
6868
const chatModel = getChatModel(model, tools, temperature)
6969

7070
const messages: BaseMessageLike[] = [
71+
{
72+
role: 'system',
73+
content: formatInstructions,
74+
},
7175
{
7276
role: 'system',
7377
content: systemMessage,

0 commit comments

Comments
 (0)