Persistable history and Context Integration#22
Conversation
Pull Request Test Coverage Report for Build 18267397354Details
💛 - Coveralls |
There was a problem hiding this comment.
Review by Korbit AI
Korbit automatically attempts to detect when you fix issues in new commits.
| Category | Issue | Status |
|---|---|---|
| Redundant file uploads without caching ▹ view | ✅ Fix detected | |
| Missing directory existence check in upload_base_knowledge_files ▹ view | ||
| Unclear Comment Purpose ▹ view | ✅ Fix detected |
Files scanned
| File Path | Reviewed |
|---|---|
| resumax_backend/resumax_api/views.py | ✅ |
| resumax_backend/resumax_algo/gemini_model.py | ✅ |
Explore our documentation to understand the languages and file types we support and the files we ignore.
Check out our docs on how you can make Korbit work best for you and your team.
| def upload_base_knowledge_files(): | ||
| """Upload all files in the base_knowledge folder to Gemini and return their URIs.""" | ||
| base_knowledge_dir = os.path.join(settings.BASE_DIR, 'base_knowledge') | ||
| client = _get_genai_client() | ||
| context_file_uris = [] | ||
| for filename in os.listdir(base_knowledge_dir): | ||
| file_path = os.path.join(base_knowledge_dir, filename) | ||
| if os.path.isfile(file_path): | ||
| try: | ||
| uploaded = client.files.upload(file=pathlib.Path(file_path)) | ||
| context_file_uris.append(uploaded.uri) | ||
| except Exception as e: | ||
| print(f"Error uploading {filename}: {e}") | ||
| return context_file_uris |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| # You can add a clarifying text part if you want | ||
| context_parts.append(types.Part.from_text(text="These are reference documents for best practices. Use them as guidelines.")) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| base_knowledge_dir = os.path.join(settings.BASE_DIR, 'base_knowledge') | ||
| client = _get_genai_client() | ||
| context_file_uris = [] | ||
| for filename in os.listdir(base_knowledge_dir): |
There was a problem hiding this comment.
Missing directory existence check in upload_base_knowledge_files 
Tell me more
What is the issue?
The function attempts to list directory contents without checking if the base_knowledge directory exists first.
Why this matters
This will raise a FileNotFoundError when the base_knowledge directory doesn't exist, causing the chat session creation to fail and preventing users from having conversations.
Suggested change ∙ Feature Preview
Add directory existence check:
base_knowledge_dir = os.path.join(settings.BASE_DIR, 'base_knowledge')
if not os.path.exists(base_knowledge_dir):
return []
client = _get_genai_client()
context_file_uris = []
for filename in os.listdir(base_knowledge_dir):Provide feedback to improve future suggestions
💬 Looking for more details? Reply to this comment to chat with Korbit.
|
Great job! Work on the suggestions from Korbit, then I'll merge the changes. |
Added Chat Session tracking through dictionary and threading, as well as uploading Loeb Center context documents on chat creation.
Description by Korbit AI
What change is being made?
Persist chat sessions per user with persistent history, add context integration from base knowledge files, optimize history retrieval and file uploads, and wire user-aware session handling into the API.
Why are these changes being made?
To enable long-running, context-aware conversations per user while avoiding repeated uploads and reducing latency, by caching base knowledge, organizing session state, and improving performance and reliability in chat generation.