-
Notifications
You must be signed in to change notification settings - Fork 383
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
backend: upload + chat with compass #569
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
such a well detailed PR! this was a pleasure and excellent written code 🙏 thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #569 +/- ##
==========================================
- Coverage 77.10% 76.25% -0.85%
==========================================
Files 238 238
Lines 10455 10591 +136
==========================================
+ Hits 8061 8076 +15
- Misses 2394 2515 +121 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - good to merge after/if you've tested this logic
This PR introduces using Compass as a storage solution for files. Here are some of the key changes:
AI Description
This PR introduces changes related to file handling and storage in the backend of an application. Here's a summary of the modifications:
conversation_id
to thecall_tools
function.use_compass_file_storage
, in theFeatureFlags
class.ToolName
class:filenames
field tofiles
, now a list of tuples containing the filename and file ID.ReadFileTool
parameter definition to use the newfile
field instead offilename
.RequestFile
,UploadFile
, andSettings
fromfastapi
.ToolName
frombackend.config.tools
andDeleteFileResponse
,UploadFileResponse
frombackend.schemas.file
.batch_upload_file
: Allows uploading multiple files and returns a list ofUploadFileResponse
.delete_file
: Deletes a file by its ID.file_paths
from thechat_stream
andchat
functions.Settings
frombackend.config.settings
andCompass
frombackend.services.compass
.delete_conversation
function to use thevalidate_conversation
function and updated file deletion logic.upload_file
function to check if Compass file storage is enabled before validating file size.batch_upload_file
function to use thectx
parameter and updated the file creation process.update_file
function.conversation_id
optional in theFile
class.file_content
, in theFile
class.get_file_service
import.file_paths
from theprocess_chat
andcreate_message
functions.handle_file_retrieval
function._raw_parsing
function to include a new parameter,custom_context
.uuid
,datetime
,Settings
,Context
,Compass
, andget_context
.get_file_service
andget_compass
functions to initialize instances ofFileService
andCompass
.FileService
class:is_compass_enabled
, to check if Compass is enabled for file storage.create_conversation_files
and introduced thecreate_agent_files
function to support Compass file storage.get_files_by_agent_id
function to importToolName
frombackend.config.tools
.get_files_by_conversation_id
function to support Compass file storage.delete_conversation_file_by_id
anddelete_agent_file_by_id
functions to handle file deletion.get_file_by_id
,get_files_by_ids
,update_file
, andbulk_delete_files
functions.delete_file_in_compass
,get_files_in_compass
,consolidate_agent_files_in_compass
, andinsert_files_in_compass
.validate_file
function to support Compass file storage.insert_files_in_db
function to insert files into the database.attach_conversation_id_to_files
function to attach a conversation ID to files.mock_compass_settings
, to mock Compass-related settings.test_list_files
function to use themock_compass_settings
fixture and updated file handling.test_upload_file_existing_conversation
function to usemock_compass_settings
and updated file retrieval logic.test_batch_upload_file_existing_conversation
function to usemock_compass_settings
and modified file handling.test_batch_upload_file_nonexistent_conversation_creates_new_conversation
function to usemock_compass_settings
and updated file handling.test_delete_file
function to usemock_compass_settings
and modified file retrieval.SearchFilter
,Settings
,Compass
,get_compass
, andget_file_service
.compass_file_search
function to search for files in Compass.ReadFileTool
andSearchFileTool
classes to support Compass file storage and introduced aSEARCH_LIMIT
attribute.