-
Notifications
You must be signed in to change notification settings - Fork 3
Fix bugs, improve code quality, and refactor shared utilities #32
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
base: main
Are you sure you want to change the base?
Conversation
- Fix SQL syntax error in chat_message_histories.py clear() method (missing space before WHERE) - Fix mutable default arguments in search_vector_store.py (4 locations) - Fix logger.error() calls to use proper f-string formatting (5 locations) - Add default value to row.pop() in query_vector_store.py to prevent KeyError - Remove redundant exception re-raising patterns (5 locations) - Fix type hints in cache.py (kwargs type, Union vs Optional) - Fix docstring in base_vector_store.py (remove non-existent parameters) - Fix missing space in error message in search_vector_store.py - Fix line-too-long lint errors in query_vector_store.py (2 locations)
Summary of ChangesHello @teetangh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on a comprehensive set of bug fixes and code quality improvements across various Python files. The changes enhance the robustness of the codebase by addressing common programming pitfalls like mutable default arguments and redundant exception handling. It also improves code readability and maintainability through updated type hints, corrected docstrings, better logging practices, and adherence to linting standards. The overall aim is to make the code more reliable and easier to understand for future development. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
- Create langchain_couchbase/utils.py with shared validation functions: - check_bucket_exists() - check_scope_and_collection_exists() with early-exit optimization - validate_ttl() - Update cache.py, chat_message_histories.py, base_vector_store.py to use utils - Remove 117 lines of duplicated code across 3 files - Clean up unused imports
Summary
This PR addresses bugs, code quality issues, and extracts shared utilities to reduce code duplication.
Bug Fixes
clear()method (missing space before WHERE)**kwargs: Any,OptionalvsUnion)Code Quality Improvements
logger.exception()for better error tracebacks (9 locations)__file__→__name__)Refactoring
langchain_couchbase/utils.pywith shared validation functions:check_bucket_exists()- validates bucket existencecheck_scope_and_collection_exists()- with optimized early-exit patternvalidate_ttl()- validates time-to-live settingscache.py,chat_message_histories.py,base_vector_store.pyto use shared utilitiesFiles Changed
langchain_couchbase/utils.pylangchain_couchbase/cache.pylangchain_couchbase/chat_message_histories.pylangchain_couchbase/vectorstores/base_vector_store.pylangchain_couchbase/vectorstores/query_vector_store.pylangchain_couchbase/vectorstores/search_vector_store.pyTesting