Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fix: better websearch quotes
Browse files
src/lib/components/chat/ChatMessage.svelte
CHANGED
@@ -47,6 +47,7 @@
|
|
47 |
const indices: number[] = (match.match(/\d+/g) || []).map(Number);
|
48 |
const links: string = indices
|
49 |
.map((index: number) => {
|
|
|
50 |
const source = webSearchSources[index - 1];
|
51 |
if (source) {
|
52 |
return `<a href="${source.link}" target="_blank" rel="noreferrer" style="${linkStyle}">${index}</a>`;
|
|
|
47 |
const indices: number[] = (match.match(/\d+/g) || []).map(Number);
|
48 |
const links: string = indices
|
49 |
.map((index: number) => {
|
50 |
+
if (index === 0) return " ";
|
51 |
const source = webSearchSources[index - 1];
|
52 |
if (source) {
|
53 |
return `<a href="${source.link}" target="_blank" rel="noreferrer" style="${linkStyle}">${index}</a>`;
|
src/lib/server/endpoints/preprocessMessages.ts
CHANGED
@@ -35,7 +35,8 @@ function addWebSearchContext(messages: Message[], webSearch: Message["webSearch"
|
|
35 |
const finalMessage = {
|
36 |
...messages[messages.length - 1],
|
37 |
content: `I searched the web using the query: ${webSearch.searchQuery}.
|
38 |
-
Today is ${currentDate} and here are the results.
|
|
|
39 |
=====================
|
40 |
${webSearchContext}
|
41 |
=====================
|
|
|
35 |
const finalMessage = {
|
36 |
...messages[messages.length - 1],
|
37 |
content: `I searched the web using the query: ${webSearch.searchQuery}.
|
38 |
+
Today is ${currentDate} and here are the results.
|
39 |
+
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].
|
40 |
=====================
|
41 |
${webSearchContext}
|
42 |
=====================
|
src/lib/server/tools/web/search.ts
CHANGED
@@ -33,11 +33,9 @@ const websearch: ConfigTool = {
|
|
33 |
return {
|
34 |
outputs: [
|
35 |
{
|
36 |
-
websearch:
|
37 |
-
|
38 |
-
|
39 |
-
instructions:
|
40 |
-
"When answering the question, if you use sources from the websearch results above, cite each index inline individually wrapped like: [1], [2] etc.",
|
41 |
},
|
42 |
],
|
43 |
display: false,
|
|
|
33 |
return {
|
34 |
outputs: [
|
35 |
{
|
36 |
+
websearch:
|
37 |
+
webSearchContext +
|
38 |
+
"\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].",
|
|
|
|
|
39 |
},
|
40 |
],
|
41 |
display: false,
|