`chat` does not work with `documents` parameter
d-e-h-i-o opened this issue · 6 comments
I'm using the library with Deno (1.36.4
) and calling the chat function with documents produces the following error:
error: Uncaught (in promise) Error: Status code: 400
Body: {
"message": "invalid request: document at index 0 cannot be empty"
}
This is a reproducible example:
import "https://deno.land/x/xhr@0.1.0/mod.ts"; // this is a XMLHttpRequest polyfill for Deno
import { CohereClient } from "https://esm.sh/cohere-ai@7.2.0";
export const cohere = new CohereClient({
token: "<token>",
});
const res = await cohere.chat({
message: "Where do the tallest penguins live?",
model: "command",
promptTruncation: "AUTO",
documents: [
{
"title": "Tall penguins",
"snippet": "Emperor penguins are the tallest."
},
{
"title": "Penguin habitats",
"snippet": "Emperor penguins only live in Antarctica."
},
{
"title": "What are animals?",
"snippet": "Animals are different from plants."
}
],
});
Just replace <token>
and run with deno run <filename>
Thanks @d-e-h-i-o, we're looking into this!
Thanks @d-e-h-i-o, we're looking into this!
Thank you! I also noticed that the types for the documents are wrong (they only contain the field id
).
Also running into this in node v21. Any workarounds?
Also running into this in node v21. Any workarounds?
You can make a http request with axios
or so, it just a litte more code.
The documents
parameter should accept any key-value pairs, as described in the documentation at https://docs.cohere.com/docs/retrieval-augmented-generation-rag
Hey all, thanks for reporting! This issue should be fixed with 7.4.0. Let us know if you have any further problems