fix(api): Allow persona instructions to be passed in the search API
This commit is contained in:
parent
631906da35
commit
6422c5b7e0
1 changed files with 4 additions and 18 deletions
|
|
@ -13,7 +13,7 @@ import {
|
||||||
getCustomOpenaiModelName,
|
getCustomOpenaiModelName,
|
||||||
} from '@/lib/config';
|
} from '@/lib/config';
|
||||||
import { searchHandlers } from '@/lib/search';
|
import { searchHandlers } from '@/lib/search';
|
||||||
import { getSystemInstructionsOnly } from '@/lib/utils/prompts';
|
import { getSystemPrompts } from '@/lib/utils/prompts';
|
||||||
import { ChatOllama } from '@langchain/ollama';
|
import { ChatOllama } from '@langchain/ollama';
|
||||||
|
|
||||||
interface chatModel {
|
interface chatModel {
|
||||||
|
|
@ -128,22 +128,7 @@ export const POST = async (req: Request) => {
|
||||||
const abortController = new AbortController();
|
const abortController = new AbortController();
|
||||||
const { signal } = abortController;
|
const { signal } = abortController;
|
||||||
|
|
||||||
// Process system prompts from database if provided, otherwise use direct instructions
|
const promptData = await getSystemPrompts(body.selectedSystemPromptIds || []);
|
||||||
let systemInstructions = '';
|
|
||||||
if (
|
|
||||||
body.selectedSystemPromptIds &&
|
|
||||||
body.selectedSystemPromptIds.length > 0
|
|
||||||
) {
|
|
||||||
try {
|
|
||||||
const promptInstructions = await getSystemInstructionsOnly(
|
|
||||||
body.selectedSystemPromptIds,
|
|
||||||
);
|
|
||||||
systemInstructions = promptInstructions || systemInstructions;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching system prompts:', error);
|
|
||||||
// Continue with fallback systemInstructions
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const emitter = await searchHandler.searchAndAnswer(
|
const emitter = await searchHandler.searchAndAnswer(
|
||||||
body.query,
|
body.query,
|
||||||
|
|
@ -152,8 +137,9 @@ export const POST = async (req: Request) => {
|
||||||
embeddings,
|
embeddings,
|
||||||
body.optimizationMode,
|
body.optimizationMode,
|
||||||
[],
|
[],
|
||||||
systemInstructions,
|
promptData.systemInstructions,
|
||||||
signal,
|
signal,
|
||||||
|
promptData.personaInstructions
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!body.stream) {
|
if (!body.stream) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue