Skip to content

Commit

Permalink
fix: better websearch quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Nov 5, 2024
1 parent b477497 commit c9703f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib/components/chat/ChatMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
const indices: number[] = (match.match(/\d+/g) || []).map(Number);
const links: string = indices
.map((index: number) => {
if (index === 0) return " ";
const source = webSearchSources[index - 1];
if (source) {
return `<a href="${source.link}" target="_blank" rel="noreferrer" style="${linkStyle}">${index}</a>`;
Expand Down
3 changes: 2 additions & 1 deletion src/lib/server/endpoints/preprocessMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ function addWebSearchContext(messages: Message[], webSearch: Message["webSearch"
const finalMessage = {
...messages[messages.length - 1],
content: `I searched the web using the query: ${webSearch.searchQuery}.
Today is ${currentDate} and here are the results. When answering the question, if you use a source, cite its index inline like this: [1], [2], etc.
Today is ${currentDate} and here are the results.
When answering the question, you must reference the sources you used inline by wrapping the index in brackets like this: [1]. If multiple sources are used, you must reference each one of them without commas like this: [1][2][3].
=====================
${webSearchContext}
=====================
Expand Down
8 changes: 3 additions & 5 deletions src/lib/server/tools/web/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ const websearch: ConfigTool = {
return {
outputs: [
{
websearch: webSearchContext,
},
{
instructions:
"When answering the question, if you use sources from the websearch results above, cite each index inline individually wrapped like: [1], [2] etc.",
websearch:
webSearchContext +
"\n\nWhen answering the question, you must reference the sources you used inline by wrapping the index in brackets like this: [1]. If multiple sources are used, you must reference each one of them without commas like this: [1][2][3].",
},
],
display: false,
Expand Down

0 comments on commit c9703f4

Please sign in to comment.