diff --git a/.changeset/nasty-dingos-approve.md b/.changeset/nasty-dingos-approve.md new file mode 100644 index 000000000..e79507947 --- /dev/null +++ b/.changeset/nasty-dingos-approve.md @@ -0,0 +1,5 @@ +--- +"create-llama": patch +--- + +Bump chat-ui and improve citation prompt diff --git a/helpers/env-variables.ts b/helpers/env-variables.ts index aa6103339..cf557695d 100644 --- a/helpers/env-variables.ts +++ b/helpers/env-variables.ts @@ -483,11 +483,12 @@ const getSystemPromptEnv = ( }); } if (tools?.length == 0 && (dataSources?.length ?? 0 > 0)) { - const citationPrompt = `'You have provided information from a knowledge base that has been passed to you in nodes of information. -Each node has useful metadata such as node ID, file name, page, etc. -Please add the citation to the data node for each sentence or paragraph that you reference in the provided information. -The citation format is: . [citation:]() -Where the is the unique identifier of the data node. + const citationPrompt = `'You have provided information from a knowledge base that separates the information into multiple nodes. +Always add a citation to each sentence or paragraph that you reference in the provided information using the node_id field in the header of each node. + +The citation format is: [citation:] +Where the is the node_id field in the header of each node. +Always separate the citation by a space. Example: We have two nodes: @@ -497,11 +498,9 @@ We have two nodes: node_id: abc file_name: animal.pdf -User question: Tell me a fun fact about Llama. -Your answer: -A baby llama is called "Cria" [citation:xyz](). -It often live in desert [citation:abc](). -It\\'s cute animal. +Your answer with citations: +A baby llama is called "Cria" [citation:xyz] +It often lives in desert [citation:abc] [citation:xyz] '`; systemPromptEnv.push({ name: "SYSTEM_CITATION_PROMPT", diff --git a/templates/types/streaming/nextjs/package.json b/templates/types/streaming/nextjs/package.json index 48c43c122..bf494d052 100644 --- a/templates/types/streaming/nextjs/package.json +++ b/templates/types/streaming/nextjs/package.json @@ -17,7 +17,7 @@ "@radix-ui/react-select": "^2.1.1", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tabs": "^1.1.0", - "@llamaindex/chat-ui": "0.0.14", + "@llamaindex/chat-ui": "0.0.16", "ai": "^4.0.3", "ajv": "^8.12.0", "class-variance-authority": "^0.7.1",