Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when using documents parameter with co.chat() #603

Open
ai-yann opened this issue Nov 22, 2024 · 1 comment
Open

TypeError when using documents parameter with co.chat() #603

ai-yann opened this issue Nov 22, 2024 · 1 comment

Comments

@ai-yann
Copy link

ai-yann commented Nov 22, 2024

SDK Version (required): 5.11.4

Describe the bug
When trying to use the documents parameter with co.chat() method in the Cohere Python SDK v5.11.4, receiving a TypeError indicating that documents is an unexpected keyword argument.

The error occurs when trying to use the chat endpoint with RAG:

chat_response = co.chat(
    model="command-r-plus-08-2024",
    messages=chat_messages,
    documents=[{
        "data": {"text": doc["text"]}
    } for doc in context_docs],
    temperature=0.2
)

Error Message

TypeError: V2Client.chat() got an unexpected keyword argument 'documents'

Expected Behavior

Based on the Cohere documentation, the chat endpoint should accept a documents parameter for RAG functionality.

Actual Behavior

The SDK throws a TypeError when attempting to use the documents parameter.

Steps to Reproduce

  1. Initialize Cohere client with V2 endpoint (co = cohere.ClientV2(...)
  2. Prepare chat messages and context documents
  3. Call co.chat() with documents parameter
@ai-yann
Copy link
Author

ai-yann commented Nov 22, 2024

The solution: I had to cast id of the documents to be of type string, which the documentation does say. The error message should indicate that document IDs must be strings, like:

'TypeError: Document IDs must be of type string in the documents parameter. Please ensure all document IDs are properly cast to strings before making the chat request.'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant