Skip to content

wrong pr#113

Closed
teetangh wants to merge 2 commits into
mainfrom
migrate/pydantic_ai
Closed

wrong pr#113
teetangh wants to merge 2 commits into
mainfrom
migrate/pydantic_ai

Conversation

@teetangh

Copy link
Copy Markdown
Contributor

No description provided.

…iable management

- Added execution counts and outputs to code cells for better tracking.
- Improved package installation commands for consistency and clarity.
- Integrated dotenv for environment variable management to streamline configuration.
- Updated import statements to include necessary modules for functionality.
- Enhanced error handling and logging for better debugging and user feedback.
@teetangh

teetangh commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

wrong files. closing this one

@teetangh teetangh closed this Feb 10, 2026
@github-actions

Copy link
Copy Markdown

Caution

Notebooks or Frontmatter Files Have Been Modified

  • Please ensure that a frontmatter.md file is accompanying the notebook file, and that the frontmatter is up to date.
  • These changes will be published to the developer portal tutorials only if frontmatter.md is included.
  • Proofread all changes before merging, as changes to notebook and frontmatter content will update the developer tutorial.

2 Notebook Files Modified:

Notebook File Frontmatter Included?
llamaindex/query_based/RAG_with_Couchbase_Capella_and_OpenAI.ipynb
llamaindex/search_based/RAG_with_Couchbase_Capella_and_OpenAI.ipynb

1 Frontmatter Files Modified:

Frontmatter File
llamaindex/search_based/frontmatter.md
Note: frontmatter will be checked and tested in the Test Frontmatter workflow.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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 significantly improves the maintainability and user experience of the LlamaIndex RAG notebooks by updating core dependencies, standardizing configuration loading through environment variables, and implementing more thorough error handling and logging. These changes aim to make the notebooks more reliable and easier to set up and debug for users interacting with Couchbase Capella and OpenAI services.

Highlights

  • Dependency Updates: Updated Python package versions for datasets, llama-index, llama-index-llms-openai, and python-dotenv across both Jupyter notebooks to ensure compatibility and leverage the latest features.
  • Configuration Management Refactor: Refactored the handling of configuration variables (e.g., Couchbase connection details, OpenAI API key) to utilize python-dotenv and environment variables, providing more robust and flexible setup options with sensible defaults and interactive prompts.
  • Improved Logging and Error Handling: Enhanced logging throughout the notebooks to provide clearer execution feedback and added comprehensive try-except blocks to critical operations, improving the robustness and debuggability of the RAG pipelines.
  • Couchbase Search Index Management: Refined the Couchbase Search Index creation logic in the search_based notebook to correctly update existing indexes by preserving their UUID, preventing recreation errors.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • llamaindex/query_based/RAG_with_Couchbase_Capella_and_OpenAI.ipynb
    • Updated Python package installations to newer versions.
    • Refactored configuration variable loading to use load_dotenv() and os.getenv().
    • Added hashlib, json, os, dotenv, CreateBucketSettings, VectorStoreIndex, and MetadataMode to imports.
    • Introduced logging.getLogger("httpx").setLevel(logging.WARNING) to suppress verbose HTTPX logs.
    • Changed CB_CONNECTION_STRING to CB_HOST for Couchbase cluster connection.
    • Wrapped data preparation, embedding model testing, vector store creation, ingestion pipeline, LLM setup, and index creation in try-except blocks with logging.
    • Updated Python kernel version metadata from 3.13.2 to 3.12.12.
  • llamaindex/search_based/RAG_with_Couchbase_Capella_and_OpenAI.ipynb
    • Updated Python package installations to newer versions.
    • Refactored configuration variable loading to use load_dotenv() and os.getenv().
    • Added hashlib, json, os, dotenv, CreateBucketSettings, VectorStoreIndex, and MetadataMode to imports.
    • Introduced logging.getLogger("httpx").setLevel(logging.WARNING) to suppress verbose HTTPX logs.
    • Changed CB_CONNECTION_STRING to CB_HOST for Couchbase cluster connection.
    • Improved search index upsert logic to handle existing indexes by copying their UUID.
    • Wrapped data preparation, embedding model testing, vector store creation, ingestion pipeline, LLM setup, and index creation in try-except blocks with logging.
    • Broadened error handling for semantic search from RecursionError to Exception.
    • Updated Python kernel display_name from base to .venv and version from 3.11.7 to 3.12.12.
  • llamaindex/search_based/frontmatter.md
    • Corrected a typo from 'search vector search' to 'Search Vector Index'.
    • Corrected a typo from 'Llamaindex' to 'LlamaIndex'.
Activity
  • The pull request was opened by teetangh with the title "wrong pr", indicating a potential misnaming or placeholder title.
  • The Jupyter notebooks were executed, and their outputs, including installation logs, connection messages, and search results, were committed, suggesting that the changes have been tested and verified to run successfully.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces several improvements to the Jupyter notebooks, including using environment variables for configuration, more robust error handling, and standardizing on the logging module. A critical security finding is a high-severity N1QL injection vulnerability due to direct string interpolation of user-controlled variables into a database query, and medium-severity hardcoded default credentials (using 'password' for the Couchbase cluster). Additionally, consider making exception handling more specific and organizing imports for better readability.

"OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') or getpass.getpass('Enter your OpenAI API key: ')\n",
"CB_HOST = os.getenv('CB_HOST', 'couchbase://localhost') or input('Enter Couchbase host (default: couchbase://localhost): ') or 'couchbase://localhost'\n",
"CB_USERNAME = os.getenv('CB_USERNAME', 'Administrator') or input('Enter Couchbase username (default: Administrator): ') or 'Administrator'\n",
"CB_PASSWORD = os.getenv('CB_PASSWORD', 'password') or getpass.getpass('Enter Couchbase password (default: password): ') or 'password'\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The variable CB_PASSWORD is assigned a hardcoded default value of 'password'. Hardcoding default credentials, even in a tutorial or cookbook, is a poor security practice that can lead to unauthorized access if users deploy the code without modification.

CB_PASSWORD = os.getenv('CB_PASSWORD') or getpass.getpass('Enter Couchbase password: ')

"OPENAI_API_KEY = os.getenv('OPENAI_API_KEY') or getpass.getpass('Enter your OpenAI API key: ')\n",
"CB_HOST = os.getenv('CB_HOST', 'couchbase://localhost') or input('Enter Couchbase host (default: couchbase://localhost): ') or 'couchbase://localhost'\n",
"CB_USERNAME = os.getenv('CB_USERNAME', 'Administrator') or input('Enter Couchbase username (default: Administrator): ') or 'Administrator'\n",
"CB_PASSWORD = os.getenv('CB_PASSWORD', 'password') or getpass.getpass('Enter Couchbase password (default: password): ') or 'password'\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The variable CB_PASSWORD is assigned a hardcoded default value of 'password'. Hardcoding default credentials, even in a tutorial or cookbook, is a poor security practice that can lead to unauthorized access if users deploy the code without modification.

CB_PASSWORD = os.getenv('CB_PASSWORD') or getpass.getpass('Enter Couchbase password: ')

Comment on lines 124 to +148
"import getpass\n",
"import base64\n",
"import hashlib\n",
"import json\n",
"import logging\n",
"import os\n",
"import sys\n",
"import time\n",
"from datetime import timedelta\n",
"from dotenv import load_dotenv\n",
"\n",
"from couchbase.auth import PasswordAuthenticator\n",
"from couchbase.cluster import Cluster\n",
"from couchbase.exceptions import CouchbaseException\n",
"from couchbase.management.buckets import CreateBucketSettings\n",
"from couchbase.options import ClusterOptions, KnownConfigProfiles, QueryOptions\n",
"\n",
"from datasets import load_dataset\n",
"\n",
"from llama_index.core import Settings, Document\n",
"from llama_index.core import Settings, Document, VectorStoreIndex\n",
"from llama_index.core.ingestion import IngestionPipeline\n",
"from llama_index.core.node_parser import SentenceSplitter\n",
"from llama_index.vector_stores.couchbase import CouchbaseQueryVectorStore\n",
"from llama_index.core.schema import MetadataMode\n",
"from llama_index.vector_stores.couchbase import CouchbaseQueryVectorStore, QueryVectorSearchSimilarity, QueryVectorSearchType\n",
"from llama_index.embeddings.openai import OpenAIEmbedding\n",
"from llama_index.llms.openai import OpenAI\n",
"from llama_index.vector_stores.couchbase import CouchbaseQueryVectorStore, QueryVectorSearchSimilarity, QueryVectorSearchType\n"
"from llama_index.llms.openai import OpenAI"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The imports in this cell are not sorted alphabetically, which goes against PEP 8 guidelines. Sorting imports improves code readability and maintainability. Consider organizing them into standard library, third-party, and local application groups, with each group sorted alphabetically.

import getpass
import hashlib
import json
import logging
import os
import sys
import time
from datetime import timedelta

from couchbase.auth import PasswordAuthenticator
from couchbase.cluster import Cluster
from couchbase.exceptions import CouchbaseException
from couchbase.management.buckets import CreateBucketSettings
from couchbase.options import ClusterOptions, KnownConfigProfiles, QueryOptions
from datasets import load_dataset
from dotenv import load_dotenv
from llama_index.core import Document, Settings, VectorStoreIndex
from llama_index.core.ingestion import IngestionPipeline
from llama_index.core.node_parser import SentenceSplitter
from llama_index.core.schema import MetadataMode
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.llms.openai import OpenAI
from llama_index.vector_stores.couchbase import (
    CouchbaseQueryVectorStore,
    QueryVectorSearchSimilarity,
    QueryVectorSearchType,
)

Comment on lines 118 to +143
"import getpass\n",
"import base64\n",
"import hashlib\n",
"import json\n",
"import logging\n",
"import os\n",
"import sys\n",
"import time\n",
"from datetime import timedelta\n",
"from dotenv import load_dotenv\n",
"\n",
"from couchbase.auth import PasswordAuthenticator\n",
"from couchbase.cluster import Cluster\n",
"from couchbase.exceptions import CouchbaseException\n",
"from couchbase.management.buckets import CreateBucketSettings\n",
"from couchbase.management.search import SearchIndex\n",
"from couchbase.options import ClusterOptions\n",
"\n",
"from datasets import load_dataset\n",
"\n",
"from llama_index.core import Settings, Document\n",
"from llama_index.core import Settings, Document, VectorStoreIndex\n",
"from llama_index.core.ingestion import IngestionPipeline\n",
"from llama_index.core.node_parser import SentenceSplitter\n",
"from llama_index.core.schema import MetadataMode\n",
"from llama_index.vector_stores.couchbase import CouchbaseSearchVectorStore\n",
"from llama_index.embeddings.openai import OpenAIEmbedding\n",
"from llama_index.llms.openai import OpenAI\n"
"from llama_index.llms.openai import OpenAI"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The imports in this cell are not sorted alphabetically, which goes against PEP 8 guidelines. Sorting imports improves code readability and maintainability. Consider organizing them into standard library, third-party, and local application groups, with each group sorted alphabetically.

import getpass
import hashlib
import json
import logging
import os
import sys
import time
from datetime import timedelta

from couchbase.auth import PasswordAuthenticator
from couchbase.cluster import Cluster
from couchbase.exceptions import CouchbaseException
from couchbase.management.buckets import CreateBucketSettings
from couchbase.management.search import SearchIndex
from couchbase.options import ClusterOptions
from datasets import load_dataset
from dotenv import load_dotenv
from llama_index.core import Document, Settings, VectorStoreIndex
from llama_index.core.ingestion import IngestionPipeline
from llama_index.core.node_parser import SentenceSplitter
from llama_index.core.schema import MetadataMode
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.llms.openai import OpenAI
from llama_index.vector_stores.couchbase import CouchbaseSearchVectorStore

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.

1 participant