Models supported by Cohere return citations if you add a documents variable in the completion request (both stream=True, and stream=False) In response, chat completion returns citations.
See example of DEBUG output from liteLLM:
PROCESSED CHUNK PRE CHUNK CREATOR: b'{"is_finished":false,"event_type":"citation-generation","citations":[{"start":92,"end":99,"text":"popcorn","document_ids":["1"]}]}'; custom_llm_provider: cohere_chat
chunk: {"is_finished":false,"event_type":"citation-generation","citations":[{"start":92,"end":99,"text":"popcorn","document_ids":["1"]}]}
PROCESSED CHUNK POST CHUNK CREATOR: None
The citations are returned by the Cohere API, but ignored when liteLLM creates the chunks, and are thus not accessible when iterating through the chunks.
Update the chunk creation function for Cohere models to read the citations from the Cohere API, and provide them in the chunks. Possibly in the same way that already seems to be working in the Perplexity liteLLM completions.
Motivation, pitch
Many people use the Cohere API for their RAG use cases, as provides these citations. But, migration to liteLLM, is now not possible when using the completion API.
@krrishdholakia Glad to see you're picking this up. I can't wait to get started with liteLLM. Let me know if I can help out with a more detailed description if necessary.
The Feature
Models supported by Cohere return
citations
if you add adocuments
variable in the completion request (bothstream=True
, andstream=False
) In response, chat completion returns citations.See example of DEBUG output from liteLLM:
The citations are returned by the Cohere API, but ignored when liteLLM creates the chunks, and are thus not accessible when iterating through the chunks.
Update the chunk creation function for Cohere models to read the citations from the Cohere API, and provide them in the chunks. Possibly in the same way that already seems to be working in the Perplexity liteLLM completions.
Motivation, pitch
Many people use the Cohere API for their RAG use cases, as provides these citations. But, migration to liteLLM, is now not possible when using the completion API.
Twitter / LinkedIn details
No response