Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Thank you for contributing to the Cohere Toolkit!
PR title: "area: description"
PR message: Delete this entire checklist and replace with
Add tests and docs: Please include testing and documentation for your changes
Lint and test: Run
make lint
andmake run-tests
AI Description
The PR makes changes to the backend of a chat application.
Summary
The changes introduce a new feature that allows users to generate a title for a conversation and update the conversation with the generated title. This feature is available through a new API endpoint,
/upload_file
, and a new function,generate_title
. The PR also includes updates to the ChatMessage class, adding a new attribute, ChatRole, and modifying the add_files_to_chat_history function to use this new attribute.Code Changes
src/backend/chat/collate.py
: Modified theRELEVANCE_THRESHOLD
constant from0.3
to0.1
.src/backend/chat/custom/custom.py
: Imported the ChatRole class frombackend.schemas.chat
and updated the add_files_to_chat_history function to use the new ChatRole attribute in the ChatMessage class.src/backend/routers/conversation.py
: Added a new API endpoint,/upload_file
, and a new function,generate_title
, to generate a title for a conversation.src/backend/schemas/conversation.py
: Added a new class, GenerateTitle, with a title attribute.src/backend/services/chat.py
: Updated the generate_chat_response, generate_chat_stream, handle_stream_start, and handle_stream_end functions to include optional response_id and generation_id parameters.src/backend/services/conversation.py
: Added a new function, extract_details_from_conversation, to extract details from a conversation object.src/backend/tests/crud/test_agent_tool_metadata.py
: Updated the test_create_agent_tool_metadata, test_create_agent_missing_tool_name, test_create_agent_missing_user_id, test_update_agent_tool_metadata, and other test functions to include a new format for the artifacts parameter.src/backend/tests/routers/test_conversation.py
: Added new test functions, test_generate_title, test_fail_generate_title_missing_user_id, and test_fail_generate_title_nonexistent_conversation, to test the new title generation feature.src/backend/tests/tools/test_collate.py
: Modified the test_rerank function to include additional outputs.