mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-06-20 16:58:30 +00:00
Compare commits
8 Commits
v1.10.1
...
086b8abdf4
Author | SHA1 | Date | |
---|---|---|---|
086b8abdf4 | |||
8097610baf | |||
09661ae11d | |||
a8d410bc2f | |||
7d52fbb368 | |||
4b8e0ea1aa | |||
5b1055e8c9 | |||
4b2a7916fd |
5
.github/workflows/docker-build.yaml
vendored
5
.github/workflows/docker-build.yaml
vendored
@ -114,6 +114,11 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Extract version from release tag
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
id: version
|
||||||
|
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Create and push multi-arch manifest for main
|
- name: Create and push multi-arch manifest for main
|
||||||
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
||||||
run: |
|
run: |
|
||||||
|
@ -29,6 +29,7 @@ type Message = {
|
|||||||
messageId: string;
|
messageId: string;
|
||||||
chatId: string;
|
chatId: string;
|
||||||
content: string;
|
content: string;
|
||||||
|
userSessionId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ChatModel = {
|
type ChatModel = {
|
||||||
@ -49,6 +50,7 @@ type Body = {
|
|||||||
files: Array<string>;
|
files: Array<string>;
|
||||||
chatModel: ChatModel;
|
chatModel: ChatModel;
|
||||||
embeddingModel: EmbeddingModel;
|
embeddingModel: EmbeddingModel;
|
||||||
|
systemInstructions: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEmitterEvents = async (
|
const handleEmitterEvents = async (
|
||||||
@ -137,6 +139,7 @@ const handleHistorySave = async (
|
|||||||
where: eq(chats.id, message.chatId),
|
where: eq(chats.id, message.chatId),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let currentDate = new Date();
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
await db
|
await db
|
||||||
.insert(chats)
|
.insert(chats)
|
||||||
@ -146,6 +149,8 @@ const handleHistorySave = async (
|
|||||||
createdAt: new Date().toString(),
|
createdAt: new Date().toString(),
|
||||||
focusMode: focusMode,
|
focusMode: focusMode,
|
||||||
files: files.map(getFileDetails),
|
files: files.map(getFileDetails),
|
||||||
|
userSessionId: message.userSessionId,
|
||||||
|
timestamp: currentDate.toISOString(),
|
||||||
})
|
})
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
@ -278,6 +283,7 @@ export const POST = async (req: Request) => {
|
|||||||
embedding,
|
embedding,
|
||||||
body.optimizationMode,
|
body.optimizationMode,
|
||||||
body.files,
|
body.files,
|
||||||
|
body.systemInstructions,
|
||||||
);
|
);
|
||||||
|
|
||||||
const responseStream = new TransformStream();
|
const responseStream = new TransformStream();
|
||||||
|
@ -1,10 +1,47 @@
|
|||||||
import db from '@/lib/db';
|
import db from '@/lib/db';
|
||||||
|
import { chats } from '@/lib/db/schema';
|
||||||
|
import { eq, sql} from 'drizzle-orm';
|
||||||
|
|
||||||
export const GET = async (req: Request) => {
|
export const GET = async (req: Request) => {
|
||||||
try {
|
try {
|
||||||
let chats = await db.query.chats.findMany();
|
// get header from request
|
||||||
chats = chats.reverse();
|
const headers = await req.headers;
|
||||||
return Response.json({ chats: chats }, { status: 200 });
|
let userSessionId = headers.get('user-session-id')?.toString() ?? '';
|
||||||
|
|
||||||
|
if (userSessionId == '') {
|
||||||
|
return Response.json({ chats: {} }, { status: 200 });
|
||||||
|
}
|
||||||
|
|
||||||
|
let chatsRes = await db.query.chats.findMany({
|
||||||
|
where: eq(chats.userSessionId, userSessionId),
|
||||||
|
});
|
||||||
|
|
||||||
|
chatsRes = chatsRes.reverse();
|
||||||
|
// Keep only the latest 20 records in the database. Delete older records.
|
||||||
|
let maxRecordLimit = 20;
|
||||||
|
if (chatsRes.length > maxRecordLimit) {
|
||||||
|
const deleteChatsQuery = sql`DELETE FROM chats
|
||||||
|
WHERE userSessionId = ${userSessionId} AND (
|
||||||
|
timestamp IS NULL OR
|
||||||
|
timestamp NOT in (
|
||||||
|
SELECT timestamp FROM chats
|
||||||
|
WHERE userSessionId = ${userSessionId}
|
||||||
|
ORDER BY timestamp DESC
|
||||||
|
LIMIT ${maxRecordLimit}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
`;
|
||||||
|
await db.run(deleteChatsQuery);
|
||||||
|
// Delete messages that no longer link with the chat from the database.
|
||||||
|
const deleteMessagesQuery = sql`DELETE FROM messages
|
||||||
|
WHERE chatId NOT IN (
|
||||||
|
SELECT id FROM chats
|
||||||
|
)
|
||||||
|
`;
|
||||||
|
await db.run(deleteMessagesQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Response.json({ chats: chatsRes }, { status: 200 });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error in getting chats: ', err);
|
console.error('Error in getting chats: ', err);
|
||||||
return Response.json(
|
return Response.json(
|
||||||
|
@ -125,6 +125,7 @@ export const POST = async (req: Request) => {
|
|||||||
embeddings,
|
embeddings,
|
||||||
body.optimizationMode,
|
body.optimizationMode,
|
||||||
[],
|
[],
|
||||||
|
'',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!body.stream) {
|
if (!body.stream) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import crypto from 'crypto';
|
||||||
import DeleteChat from '@/components/DeleteChat';
|
import DeleteChat from '@/components/DeleteChat';
|
||||||
import { cn, formatTimeDifference } from '@/lib/utils';
|
import { cn, formatTimeDifference } from '@/lib/utils';
|
||||||
import { BookOpenText, ClockIcon, Delete, ScanEye } from 'lucide-react';
|
import { BookOpenText, ClockIcon, Delete, ScanEye } from 'lucide-react';
|
||||||
@ -21,10 +22,17 @@ const Page = () => {
|
|||||||
const fetchChats = async () => {
|
const fetchChats = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
|
let userSessionId = localStorage.getItem('userSessionId');
|
||||||
|
if (!userSessionId) {
|
||||||
|
userSessionId = crypto.randomBytes(20).toString('hex');
|
||||||
|
localStorage.setItem('userSessionId', userSessionId)
|
||||||
|
}
|
||||||
|
|
||||||
const res = await fetch(`/api/chats`, {
|
const res = await fetch(`/api/chats`, {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
'user-session-id': userSessionId!,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -54,6 +54,38 @@ const Input = ({ className, isSaving, onSave, ...restProps }: InputProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface TextareaProps extends React.InputHTMLAttributes<HTMLTextAreaElement> {
|
||||||
|
isSaving?: boolean;
|
||||||
|
onSave?: (value: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Textarea = ({
|
||||||
|
className,
|
||||||
|
isSaving,
|
||||||
|
onSave,
|
||||||
|
...restProps
|
||||||
|
}: TextareaProps) => {
|
||||||
|
return (
|
||||||
|
<div className="relative">
|
||||||
|
<textarea
|
||||||
|
placeholder="Any special instructions for the LLM"
|
||||||
|
className="placeholder:text-sm text-sm w-full flex items-center justify-between p-3 bg-light-secondary dark:bg-dark-secondary rounded-lg hover:bg-light-200 dark:hover:bg-dark-200 transition-colors"
|
||||||
|
rows={4}
|
||||||
|
onBlur={(e) => onSave?.(e.target.value)}
|
||||||
|
{...restProps}
|
||||||
|
/>
|
||||||
|
{isSaving && (
|
||||||
|
<div className="absolute right-3 top-3">
|
||||||
|
<Loader2
|
||||||
|
size={16}
|
||||||
|
className="animate-spin text-black/70 dark:text-white/70"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const Select = ({
|
const Select = ({
|
||||||
className,
|
className,
|
||||||
options,
|
options,
|
||||||
@ -111,6 +143,7 @@ const Page = () => {
|
|||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [automaticImageSearch, setAutomaticImageSearch] = useState(false);
|
const [automaticImageSearch, setAutomaticImageSearch] = useState(false);
|
||||||
const [automaticVideoSearch, setAutomaticVideoSearch] = useState(false);
|
const [automaticVideoSearch, setAutomaticVideoSearch] = useState(false);
|
||||||
|
const [systemInstructions, setSystemInstructions] = useState<string>('');
|
||||||
const [savingStates, setSavingStates] = useState<Record<string, boolean>>({});
|
const [savingStates, setSavingStates] = useState<Record<string, boolean>>({});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -172,6 +205,8 @@ const Page = () => {
|
|||||||
localStorage.getItem('autoVideoSearch') === 'true',
|
localStorage.getItem('autoVideoSearch') === 'true',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setSystemInstructions(localStorage.getItem('systemInstructions')!);
|
||||||
|
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -328,6 +363,8 @@ const Page = () => {
|
|||||||
localStorage.setItem('embeddingModelProvider', value);
|
localStorage.setItem('embeddingModelProvider', value);
|
||||||
} else if (key === 'embeddingModel') {
|
} else if (key === 'embeddingModel') {
|
||||||
localStorage.setItem('embeddingModel', value);
|
localStorage.setItem('embeddingModel', value);
|
||||||
|
} else if (key === 'systemInstructions') {
|
||||||
|
localStorage.setItem('systemInstructions', value);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Failed to save:', err);
|
console.error('Failed to save:', err);
|
||||||
@ -473,6 +510,19 @@ const Page = () => {
|
|||||||
</div>
|
</div>
|
||||||
</SettingsSection>
|
</SettingsSection>
|
||||||
|
|
||||||
|
<SettingsSection title="System Instructions">
|
||||||
|
<div className="flex flex-col space-y-4">
|
||||||
|
<Textarea
|
||||||
|
value={systemInstructions}
|
||||||
|
isSaving={savingStates['systemInstructions']}
|
||||||
|
onChange={(e) => {
|
||||||
|
setSystemInstructions(e.target.value);
|
||||||
|
}}
|
||||||
|
onSave={(value) => saveConfig('systemInstructions', value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</SettingsSection>
|
||||||
|
|
||||||
<SettingsSection title="Model Settings">
|
<SettingsSection title="Model Settings">
|
||||||
{config.chatModelProviders && (
|
{config.chatModelProviders && (
|
||||||
<div className="flex flex-col space-y-4">
|
<div className="flex flex-col space-y-4">
|
||||||
|
@ -95,6 +95,12 @@ const checkConfig = async (
|
|||||||
if (!embeddingModel || !embeddingModelProvider) {
|
if (!embeddingModel || !embeddingModelProvider) {
|
||||||
const embeddingModelProviders = providers.embeddingModelProviders;
|
const embeddingModelProviders = providers.embeddingModelProviders;
|
||||||
|
|
||||||
|
let userSessionId = localStorage.getItem('userSessionId');
|
||||||
|
if (!userSessionId) {
|
||||||
|
userSessionId = crypto.randomBytes(20).toString('hex');
|
||||||
|
localStorage.setItem('userSessionId', userSessionId!)
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!embeddingModelProviders ||
|
!embeddingModelProviders ||
|
||||||
Object.keys(embeddingModelProviders).length === 0
|
Object.keys(embeddingModelProviders).length === 0
|
||||||
@ -342,6 +348,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||||||
let added = false;
|
let added = false;
|
||||||
|
|
||||||
messageId = messageId ?? crypto.randomBytes(7).toString('hex');
|
messageId = messageId ?? crypto.randomBytes(7).toString('hex');
|
||||||
|
let userSessionId = localStorage.getItem('userSessionId');
|
||||||
|
|
||||||
setMessages((prevMessages) => [
|
setMessages((prevMessages) => [
|
||||||
...prevMessages,
|
...prevMessages,
|
||||||
@ -466,6 +473,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||||||
messageId: messageId,
|
messageId: messageId,
|
||||||
chatId: chatId!,
|
chatId: chatId!,
|
||||||
content: message,
|
content: message,
|
||||||
|
userSessionId: userSessionId,
|
||||||
},
|
},
|
||||||
chatId: chatId!,
|
chatId: chatId!,
|
||||||
files: fileIds,
|
files: fileIds,
|
||||||
@ -480,6 +488,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
|
|||||||
name: embeddingModelProvider.name,
|
name: embeddingModelProvider.name,
|
||||||
provider: embeddingModelProvider.provider,
|
provider: embeddingModelProvider.provider,
|
||||||
},
|
},
|
||||||
|
systemInstructions: localStorage.getItem('systemInstructions'),
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -25,4 +25,6 @@ export const chats = sqliteTable('chats', {
|
|||||||
files: text('files', { mode: 'json' })
|
files: text('files', { mode: 'json' })
|
||||||
.$type<File[]>()
|
.$type<File[]>()
|
||||||
.default(sql`'[]'`),
|
.default(sql`'[]'`),
|
||||||
|
userSessionId: text('userSessionId'),
|
||||||
|
timestamp: text('timestamp'),
|
||||||
});
|
});
|
||||||
|
@ -51,6 +51,10 @@ export const academicSearchResponsePrompt = `
|
|||||||
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
||||||
- You are set on focus mode 'Academic', this means you will be searching for academic papers and articles on the web.
|
- You are set on focus mode 'Academic', this means you will be searching for academic papers and articles on the web.
|
||||||
|
|
||||||
|
### User instructions
|
||||||
|
These instructions are shared to you by the user and not by the system. You will have to follow them but give them less priority than the above instructions. If the user has provided specific instructions or preferences, incorporate them into your response while adhering to the overall guidelines.
|
||||||
|
{systemInstructions}
|
||||||
|
|
||||||
### Example Output
|
### Example Output
|
||||||
- Begin with a brief introduction summarizing the event or query topic.
|
- Begin with a brief introduction summarizing the event or query topic.
|
||||||
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
||||||
|
@ -51,6 +51,10 @@ export const redditSearchResponsePrompt = `
|
|||||||
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
||||||
- You are set on focus mode 'Reddit', this means you will be searching for information, opinions and discussions on the web using Reddit.
|
- You are set on focus mode 'Reddit', this means you will be searching for information, opinions and discussions on the web using Reddit.
|
||||||
|
|
||||||
|
### User instructions
|
||||||
|
These instructions are shared to you by the user and not by the system. You will have to follow them but give them less priority than the above instructions. If the user has provided specific instructions or preferences, incorporate them into your response while adhering to the overall guidelines.
|
||||||
|
{systemInstructions}
|
||||||
|
|
||||||
### Example Output
|
### Example Output
|
||||||
- Begin with a brief introduction summarizing the event or query topic.
|
- Begin with a brief introduction summarizing the event or query topic.
|
||||||
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
export const webSearchRetrieverPrompt = `
|
export const webSearchRetrieverPrompt = `
|
||||||
You are an AI question rephraser. You will be given a conversation and a follow-up question, you will have to rephrase the follow up question so it is a standalone question and can be used by another LLM to search the web for information to answer it.
|
You are an AI question rephraser. You will be given a conversation and a follow-up question, you will have to rephrase the follow up question so it is a standalone question and can be used by another LLM to search the web for information to answer it.
|
||||||
If it is a smple writing task or a greeting (unless the greeting contains a question after it) like Hi, Hello, How are you, etc. than a question then you need to return \`not_needed\` as the response (This is because the LLM won't need to search the web for finding information on this topic).
|
If it is a simple writing task or a greeting (unless the greeting contains a question after it) like Hi, Hello, How are you, etc. than a question then you need to return \`not_needed\` as the response (This is because the LLM won't need to search the web for finding information on this topic).
|
||||||
If the user asks some question from some URL or wants you to summarize a PDF or a webpage (via URL) you need to return the links inside the \`links\` XML block and the question inside the \`question\` XML block. If the user wants to you to summarize the webpage or the PDF you need to return \`summarize\` inside the \`question\` XML block in place of a question and the link to summarize in the \`links\` XML block.
|
If the user asks some question from some URL or wants you to summarize a PDF or a webpage (via URL) you need to return the links inside the \`links\` XML block and the question inside the \`question\` XML block. If the user wants to you to summarize the webpage or the PDF you need to return \`summarize\` inside the \`question\` XML block in place of a question and the link to summarize in the \`links\` XML block.
|
||||||
You must always return the rephrased question inside the \`question\` XML block, if there are no links in the follow-up question then don't insert a \`links\` XML block in your response.
|
You must always return the rephrased question inside the \`question\` XML block, if there are no links in the follow-up question then don't insert a \`links\` XML block in your response.
|
||||||
|
|
||||||
@ -92,6 +92,10 @@ export const webSearchResponsePrompt = `
|
|||||||
- If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search.
|
- If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search.
|
||||||
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
||||||
|
|
||||||
|
### User instructions
|
||||||
|
These instructions are shared to you by the user and not by the system. You will have to follow them but give them less priority than the above instructions. If the user has provided specific instructions or preferences, incorporate them into your response while adhering to the overall guidelines.
|
||||||
|
{systemInstructions}
|
||||||
|
|
||||||
### Example Output
|
### Example Output
|
||||||
- Begin with a brief introduction summarizing the event or query topic.
|
- Begin with a brief introduction summarizing the event or query topic.
|
||||||
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
||||||
|
@ -51,6 +51,10 @@ export const wolframAlphaSearchResponsePrompt = `
|
|||||||
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
||||||
- You are set on focus mode 'Wolfram Alpha', this means you will be searching for information on the web using Wolfram Alpha. It is a computational knowledge engine that can answer factual queries and perform computations.
|
- You are set on focus mode 'Wolfram Alpha', this means you will be searching for information on the web using Wolfram Alpha. It is a computational knowledge engine that can answer factual queries and perform computations.
|
||||||
|
|
||||||
|
### User instructions
|
||||||
|
These instructions are shared to you by the user and not by the system. You will have to follow them but give them less priority than the above instructions. If the user has provided specific instructions or preferences, incorporate them into your response while adhering to the overall guidelines.
|
||||||
|
{systemInstructions}
|
||||||
|
|
||||||
### Example Output
|
### Example Output
|
||||||
- Begin with a brief introduction summarizing the event or query topic.
|
- Begin with a brief introduction summarizing the event or query topic.
|
||||||
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
||||||
|
@ -7,6 +7,10 @@ You have to cite the answer using [number] notation. You must cite the sentences
|
|||||||
Place these citations at the end of that particular sentence. You can cite the same sentence multiple times if it is relevant to the user's query like [number1][number2].
|
Place these citations at the end of that particular sentence. You can cite the same sentence multiple times if it is relevant to the user's query like [number1][number2].
|
||||||
However you do not need to cite it using the same number. You can use different numbers to cite the same sentence multiple times. The number refers to the number of the search result (passed in the context) used to generate that part of the answer.
|
However you do not need to cite it using the same number. You can use different numbers to cite the same sentence multiple times. The number refers to the number of the search result (passed in the context) used to generate that part of the answer.
|
||||||
|
|
||||||
|
### User instructions
|
||||||
|
These instructions are shared to you by the user and not by the system. You will have to follow them but give them less priority than the above instructions. If the user has provided specific instructions or preferences, incorporate them into your response while adhering to the overall guidelines.
|
||||||
|
{systemInstructions}
|
||||||
|
|
||||||
<context>
|
<context>
|
||||||
{context}
|
{context}
|
||||||
</context>
|
</context>
|
||||||
|
@ -51,6 +51,10 @@ export const youtubeSearchResponsePrompt = `
|
|||||||
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
|
||||||
- You are set on focus mode 'Youtube', this means you will be searching for videos on the web using Youtube and providing information based on the video's transcrip
|
- You are set on focus mode 'Youtube', this means you will be searching for videos on the web using Youtube and providing information based on the video's transcrip
|
||||||
|
|
||||||
|
### User instructions
|
||||||
|
These instructions are shared to you by the user and not by the system. You will have to follow them but give them less priority than the above instructions. If the user has provided specific instructions or preferences, incorporate them into your response while adhering to the overall guidelines.
|
||||||
|
{systemInstructions}
|
||||||
|
|
||||||
### Example Output
|
### Example Output
|
||||||
- Begin with a brief introduction summarizing the event or query topic.
|
- Begin with a brief introduction summarizing the event or query topic.
|
||||||
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
- Follow with detailed sections under clear headings, covering all aspects of the query if possible.
|
||||||
|
@ -33,6 +33,7 @@ export interface MetaSearchAgentType {
|
|||||||
embeddings: Embeddings,
|
embeddings: Embeddings,
|
||||||
optimizationMode: 'speed' | 'balanced' | 'quality',
|
optimizationMode: 'speed' | 'balanced' | 'quality',
|
||||||
fileIds: string[],
|
fileIds: string[],
|
||||||
|
systemInstructions: string,
|
||||||
) => Promise<eventEmitter>;
|
) => Promise<eventEmitter>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,9 +237,11 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
|||||||
fileIds: string[],
|
fileIds: string[],
|
||||||
embeddings: Embeddings,
|
embeddings: Embeddings,
|
||||||
optimizationMode: 'speed' | 'balanced' | 'quality',
|
optimizationMode: 'speed' | 'balanced' | 'quality',
|
||||||
|
systemInstructions: string,
|
||||||
) {
|
) {
|
||||||
return RunnableSequence.from([
|
return RunnableSequence.from([
|
||||||
RunnableMap.from({
|
RunnableMap.from({
|
||||||
|
systemInstructions: () => systemInstructions,
|
||||||
query: (input: BasicChainInput) => input.query,
|
query: (input: BasicChainInput) => input.query,
|
||||||
chat_history: (input: BasicChainInput) => input.chat_history,
|
chat_history: (input: BasicChainInput) => input.chat_history,
|
||||||
date: () => new Date().toISOString(),
|
date: () => new Date().toISOString(),
|
||||||
@ -468,6 +471,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
|||||||
embeddings: Embeddings,
|
embeddings: Embeddings,
|
||||||
optimizationMode: 'speed' | 'balanced' | 'quality',
|
optimizationMode: 'speed' | 'balanced' | 'quality',
|
||||||
fileIds: string[],
|
fileIds: string[],
|
||||||
|
systemInstructions: string,
|
||||||
) {
|
) {
|
||||||
const emitter = new eventEmitter();
|
const emitter = new eventEmitter();
|
||||||
|
|
||||||
@ -476,6 +480,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
|
|||||||
fileIds,
|
fileIds,
|
||||||
embeddings,
|
embeddings,
|
||||||
optimizationMode,
|
optimizationMode,
|
||||||
|
systemInstructions,
|
||||||
);
|
);
|
||||||
|
|
||||||
const stream = answeringChain.streamEvents(
|
const stream = answeringChain.streamEvents(
|
||||||
|
Reference in New Issue
Block a user