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

Chat: title generation #331

Merged
merged 4 commits into from
Jul 2, 2024
Merged

Chat: title generation #331

merged 4 commits into from
Jul 2, 2024

Conversation

lusmoura
Copy link
Collaborator

@lusmoura lusmoura commented Jul 1, 2024

Thank you for contributing to the Cohere Toolkit!

  • PR title: "area: description"

    • Where "area" is whichever of interface, frontend, model, tools, backend, etc. is being modified. Use "docs: ..." for purely docs changes, "infra: ..." for CI changes.
    • Example: "deployment: add Azure model option"
  • PR message: Delete this entire checklist and replace with

    • Description: a description of the change
    • Issue: the issue # it fixes, if applicable
    • Dependencies: any dependencies required for this change
  • Add tests and docs: Please include testing and documentation for your changes

  • Lint and test: Run make lint and make 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 the RELEVANCE_THRESHOLD constant from 0.3 to 0.1.
  • src/backend/chat/custom/custom.py: Imported the ChatRole class from backend.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.

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 85.52632% with 11 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@64dd521). Learn more about missing BASE report.

Files Patch % Lines
src/backend/services/conversation.py 65.00% 7 Missing ⚠️
src/backend/routers/conversation.py 88.88% 3 Missing ⚠️
src/backend/chat/custom/custom.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #331   +/-   ##
=======================================
  Coverage        ?   86.05%           
=======================================
  Files           ?      174           
  Lines           ?     6495           
  Branches        ?        0           
=======================================
  Hits            ?     5589           
  Misses          ?      906           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tomtobac tomtobac merged commit ff74df2 into main Jul 2, 2024
4 checks passed
@tomtobac tomtobac deleted the luisa/title_gen branch July 2, 2024 09:01
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

Successfully merging this pull request may close these issues.

3 participants