Skip to content

Commit c444032

Browse files
authored
Merge pull request #720 from OmarElKadri/master
feat(search): add optional systemInstructions to API request body
2 parents 09661ae + 64e2d45 commit c444032

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

docs/API/SEARCH.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ The API accepts a JSON object in the request body, where you define the focus mo
3333
["human", "Hi, how are you?"],
3434
["assistant", "I am doing well, how can I help you today?"]
3535
],
36+
"systemInstructions": "Focus on providing technical details about Perplexica's architecture.",
3637
"stream": false
3738
}
3839
```
@@ -63,6 +64,8 @@ The API accepts a JSON object in the request body, where you define the focus mo
6364

6465
- **`query`** (string, required): The search query or question.
6566

67+
- **`systemInstructions`** (string, optional): Custom instructions provided by the user to guide the AI's response. These instructions are treated as user preferences and have lower priority than the system's core instructions. For example, you can specify a particular writing style, format, or focus area.
68+
6669
- **`history`** (array, optional): An array of message pairs representing the conversation history. Each pair consists of a role (either 'human' or 'assistant') and the message content. This allows the system to use the context of the conversation to refine results. Example:
6770

6871
```json

src/app/api/search/route.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ interface ChatRequestBody {
3434
query: string;
3535
history: Array<[string, string]>;
3636
stream?: boolean;
37+
systemInstructions?: string;
3738
}
3839

3940
export const POST = async (req: Request) => {
@@ -125,7 +126,7 @@ export const POST = async (req: Request) => {
125126
embeddings,
126127
body.optimizationMode,
127128
[],
128-
'',
129+
body.systemInstructions || '',
129130
);
130131

131132
if (!body.stream) {

0 commit comments

Comments
 (0)