# Project export: Bhartee AI

This document was generated by HackStack to give an AI agent context about a hackathon project. Sections are labeled with their provenance; content marked as truncated was cut to keep this document small.

## Project metadata

- Hackathon: Cal Hacks 11.0
- Tagline: A Comprehensive AI-Driven Solution for Hiring Top-Notch Candidates.
- Devpost: https://devpost.com/software/bhartee-ai
- GitHub: https://github.com/sahiljagtap08/main-calhacks-bhartee
- Team: 0 GitHub contributor(s) — 

## Devpost submission (written by the team)

### Inspiration

In today's fast-paced tech world, finding the right talent efficiently is crucial. Traditional hiring processes are time-consuming and often biased. We created BharteeAI to revolutionize technical hiring, making it faster, fairer, and more effective.

### What it does

BharteeAI is an end-to-end AI-powered interview platform that: Screens resumes using advanced NLP and vector search Conducts real-time video interviews with an AI interviewer Assesses coding skills with an in-browser IDE Generates comprehensive candidate evaluations Provides a seamless experience for both employers and candidates

### How we built it

We leveraged cutting-edge technologies to create a robust, scalable solution: Frontend: Reflex (Python-based reactive framework) Backend: Reflex (FastAPI) Database: SingleStore for lightning-fast queries Vector Database: ChromaDB for efficient similarity search AI/ML: Groq for natural language processing Voice Processing: VAPI (Cartesia for TTS, Deepgram for STT) Video Integration: Agora Cloud Storage: AWS S3 Deployment: DigitalOcean App Platform

### Challenges we ran into

Integrating multiple AI services seamlessly Ensuring real-time performance for video and coding assessments Balancing AI automation with a human-like interview experience

### Accomplishments we're proud of

Created a fully automated yet personalized interview process Developed a scalable architecture capable of handling high-volume hiring Implemented bias-reduction techniques in candidate evaluation

### What we learned

The intricacies of AI-human interaction in high-stakes scenarios Optimizing performance in distributed systems Balancing technical assessment with soft skills evaluation

### What's next

for BharteeAI Expanding language support for global hiring Integrating more specialized technical assessments Developing an AI training module for interviewers Join us in reshaping the future of technical hiring with BharteeAI!

## README (from the GitHub repository)

# BharteeAI

BharteeAI is an AI-powered interview platform that helps companies streamline their hiring process by conducting automated technical interviews.

## Features

- AI-driven interview questions generation
- Real-time code execution during interviews
- Resume screening and matching
- Video and voice integration for remote interviews
- Comprehensive interview analysis and reporting

## Installation

1. Clone the repository:
   ```
   git clone https://github.com/yourusername/bharteeai.git
   cd bharteeai
   ```

2. Create a virtual environment and activate it:
   ```
   python -m venv venv
   source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
   ```

3. Install the required packages:
   ```
   pip install -r requirements.txt
   ```

4. Set up your environment variables:
   Copy the `.env.example` file to `.env` and fill in your API keys and other configuration details.

5. Run the application:
   ```
   reflex run
   ```

## Testing

Run the test suite using pytest:
```
pytest
```

## Deployment

Follow the deployment instructions in the documentation to deploy BharteeAI to your preferred hosting platform.

## Contributing

Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.

## Detected evidence (automated analysis)

Indexed codebase: 1063 recognized source files, 11074 KB.
- Python (language) — detected in the code
- SQL (language) — detected in the code
- FastAPI (technology) — claimed on Devpost, not found in the code

## Codebase structure (from repository index)

### Files (120 of 1218)

```
.gitignore
ai/groq_integration.py
ai/interview_assistant.py
ai/resume_screening.py
app.yaml
bharteeai/__init__.py
bharteeai/bharteeai.py
bharteeai/components/__init__.py
bharteeai/components/auth.py
bharteeai/components/consent_form.py
bharteeai/components/interview_results.py
bharteeai/components/interview.py
bharteeai/components/job_form.py
bharteeai/components/navbar.py
bharteeai/pages/__init__.py
bharteeai/pages/candidate.py
bharteeai/pages/client.py
bharteeai/pages/home.py
bharteeai/pages/interview.py
bharteeai/server/__init__.py
bharteeai/server/api.py
bharteeai/server/auth.py
bharteeai/state.py
bharteeai/styles.py
bharteeai/utils/__init__.py
bharteeai/utils/helpers.py
bharteeai/utils/jdoodle.py
chroma-env/bin/activate
chroma-env/bin/activate.csh
chroma-env/bin/activate.fish
chroma-env/bin/Activate.ps1
chroma-env/bin/pip
chroma-env/bin/pip3
chroma-env/bin/pip3.12
chroma-env/bin/python
chroma-env/bin/python3
chroma-env/bin/python3.12
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/AUTHORS.txt
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/entry_points.txt
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/INSTALLER
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/LICENSE.txt
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/METADATA
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/RECORD
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/REQUESTED
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/top_level.txt
chroma-env/lib/python3.12/site-packages/pip-24.2.dist-info/WHEEL
chroma-env/lib/python3.12/site-packages/pip/__init__.py
chroma-env/lib/python3.12/site-packages/pip/__main__.py
chroma-env/lib/python3.12/site-packages/pip/__pip-runner__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/build_env.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cache.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/autocompletion.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/base_command.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/cmdoptions.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/command_context.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/index_command.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/main_parser.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/main.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/parser.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/progress_bars.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/req_command.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/spinners.py
chroma-env/lib/python3.12/site-packages/pip/_internal/cli/status_codes.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/cache.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/check.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/completion.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/configuration.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/debug.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/download.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/freeze.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/hash.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/help.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/index.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/inspect.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/install.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/list.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/search.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/show.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/uninstall.py
chroma-env/lib/python3.12/site-packages/pip/_internal/commands/wheel.py
chroma-env/lib/python3.12/site-packages/pip/_internal/configuration.py
chroma-env/lib/python3.12/site-packages/pip/_internal/distributions/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/distributions/base.py
chroma-env/lib/python3.12/site-packages/pip/_internal/distributions/installed.py
chroma-env/lib/python3.12/site-packages/pip/_internal/distributions/sdist.py
chroma-env/lib/python3.12/site-packages/pip/_internal/distributions/wheel.py
chroma-env/lib/python3.12/site-packages/pip/_internal/exceptions.py
chroma-env/lib/python3.12/site-packages/pip/_internal/index/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/index/collector.py
chroma-env/lib/python3.12/site-packages/pip/_internal/index/package_finder.py
chroma-env/lib/python3.12/site-packages/pip/_internal/index/sources.py
chroma-env/lib/python3.12/site-packages/pip/_internal/locations/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/locations/_distutils.py
chroma-env/lib/python3.12/site-packages/pip/_internal/locations/_sysconfig.py
chroma-env/lib/python3.12/site-packages/pip/_internal/locations/base.py
chroma-env/lib/python3.12/site-packages/pip/_internal/main.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/_json.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/base.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/importlib/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_compat.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_dists.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/importlib/_envs.py
chroma-env/lib/python3.12/site-packages/pip/_internal/metadata/pkg_resources.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/__init__.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/candidate.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/direct_url.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/format_control.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/index.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/installation_report.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/link.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/scheme.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/search_scope.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/selection_prefs.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/target_python.py
chroma-env/lib/python3.12/site-packages/pip/_internal/models/wheel.py
chroma-env/lib/python3.12/site-packages/pip/_internal/network/__init__.py
[1098 more files omitted for size]
```

### Dependencies

- requirements.txt: agora-token-builder@==1.0.0, boto3@==1.26.142, chromadb, clerk_backend_api, groq@==0.4.0, httpx, pytest@==7.3.1, pytest-asyncio@==0.21.0, python-dotenv@==0.19.2, reflex@==0.6.3, singlestoredb@==0.8.1, uvicorn@==0.22.0

### Recent commits (newest first)

- fixedd
- fix
- fix
- fix
- fix
- done
- fixed
- fixed rxconfig
- fixed yaml
- fixed dependencies 3
- fixed dependencies 2
- fixed dependencies
- bhartee-do-deploy-error-fixed

## Key source files (fetched from GitHub, selected and truncated for size)

### singlestore-env/lib/python3.12/site-packages/idna-3.10.dist-info/LICENSE.md

```markdown
BSD 3-Clause License

Copyright (c) 2013-2024, Kim Davies and contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

```

### requirements.txt

```
reflex==0.6.3
uvicorn==0.22.0
httpx
clerk_backend_api
singlestoredb==0.8.1
chromadb
groq==0.4.0
python-dotenv==0.19.2
boto3==1.26.142
agora-token-builder==1.0.0
pytest==7.3.1
pytest-asyncio==0.21.0
```

### chroma-env/lib/python3.12/site-packages/pip/_internal/main.py

```python
from typing import List, Optional


def main(args: Optional[List[str]] = None) -> int:
    """This is preserved for old console scripts that may still be referencing
    it.

    For additional details, see https://github.com/pypa/pip/issues/7498.
    """
    from pip._internal.utils.entrypoints import _wrapper

    return _wrapper(args)

```

### singlestore-env/lib/python3.12/site-packages/pip/_internal/main.py

```python
from typing import List, Optional


def main(args: Optional[List[str]] = None) -> int:
    """This is preserved for old console scripts that may still be referencing
    it.

    For additional details, see https://github.com/pypa/pip/issues/7498.
    """
    from pip._internal.utils.entrypoints import _wrapper

    return _wrapper(args)

```

### chroma-env/lib/python3.12/site-packages/pip/_internal/models/index.py

```python
import urllib.parse


class PackageIndex:
    """Represents a Package Index and provides easier access to endpoints"""

    __slots__ = ["url", "netloc", "simple_url", "pypi_url", "file_storage_domain"]

    def __init__(self, url: str, file_storage_domain: str) -> None:
        super().__init__()
        self.url = url
        self.netloc = urllib.parse.urlsplit(url).netloc
        self.simple_url = self._url_for_path("simple")
        self.pypi_url = self._url_for_path("pypi")

        # This is part of a temporary hack used to block installs of PyPI
        # packages which depend on external urls only necessary until PyPI can
        # block such packages themselves
        self.file_storage_domain = file_storage_domain

    def _url_for_path(self, path: str) -> str:
        return urllib.parse.urljoin(self.url, path)


PyPI = PackageIndex("https://pypi.org/", file_storage_domain="files.pythonhosted.org")
TestPyPI = PackageIndex(
    "https://test.pypi.org/", file_storage_domain="test-files.pythonhosted.org"
)

```

### singlestore-env/lib/python3.12/site-packages/pip/_internal/models/index.py

```python
import urllib.parse


class PackageIndex:
    """Represents a Package Index and provides easier access to endpoints"""

    __slots__ = ["url", "netloc", "simple_url", "pypi_url", "file_storage_domain"]

    def __init__(self, url: str, file_storage_domain: str) -> None:
        super().__init__()
        self.url = url
        self.netloc = urllib.parse.urlsplit(url).netloc
        self.simple_url = self._url_for_path("simple")
        self.pypi_url = self._url_for_path("pypi")

        # This is part of a temporary hack used to block installs of PyPI
        # packages which depend on external urls only necessary until PyPI can
        # block such packages themselves
        self.file_storage_domain = file_storage_domain

    def _url_for_path(self, path: str) -> str:
        return urllib.parse.urljoin(self.url, path)


PyPI = PackageIndex("https://pypi.org/", file_storage_domain="files.pythonhosted.org")
TestPyPI = PackageIndex(
    "https://test.pypi.org/", file_storage_domain="test-files.pythonhosted.org"
)

```

### chroma-env/lib/python3.12/site-packages/pip/_internal/cli/main.py

```python
"""Primary application entrypoint.
"""

import locale
import logging
import os
import sys
import warnings
from typing import List, Optional

from pip._internal.cli.autocompletion import autocomplete
from pip._internal.cli.main_parser import parse_command
from pip._internal.commands import create_command
from pip._internal.exceptions import PipError
from pip._internal.utils import deprecation

logger = logging.getLogger(__name__)


# Do not import and use main() directly! Using it directly is actively
# discouraged by pip's maintainers. The name, location and behavior of
# this function is subject to change, so calling it directly is not
# portable across different pip versions.

# In addition, running pip in-process is unsupported and unsafe. This is
# elaborated in detail at
# https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program.
# That document also provides suggestions that should work for nearly
# all users that are considering importing and using main() directly.

# However, we know that certain users will still want to invoke pip
# in-process. If you understand and accept the implications of using pip
# in an unsupported manner, the best approach is to use runpy to avoid
# depending on the exact location of this entry point.

# The following example shows how to use runpy to invoke pip in that
# case:
#
#     sys.argv = ["pip", your, args, here]
#     runpy.run_module("pip", run_name="__main__")
#
# Note that this will exit the process after running, unlike a direct
# call to main. As it is not safe to do any processing after calling
# main, this should not be an issue in practice.


def main(args: Optional[List[str]] = None) -> int:
    if args is None:
        args = sys.argv[1:]

    # Suppress the pkg_resources deprecation warning
    # Note - we use a module of .*pkg_resources to cover
    # the normal case (pip._vendor.pkg_resources) and the
    # devendored case (a bare pkg_resources)
    warnings.filterwarnings(
        action="ignore", category=DeprecationWarning, module=".*pkg_resources"
    )

    # Configure our deprecation warnings to be sent through loggers
    deprecation.install_warning_logger()

    autocomplete()

    try:
        cmd_name, cmd_args = parse_command(args)
    except PipError as exc:
        sys.stderr.write(f"ERROR: {exc}")
        sys.stderr.write(os.linesep)
        sys.exit(1)

    # Needed for locale.getpreferredencoding(False) to work
    # in pip._internal.utils.encoding.auto_decode
    try:
        locale.setlocale(locale.LC_ALL, "")
    except locale.Error as e:
        # setlocale can apparently crash if locale are uninitialized
        logger.debug("Ignoring error %s when setting locale", e)
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))

    return command.main(cmd_args)

```

### singlestore-env/lib/python3.12/site-packages/pip/_internal/cli/main.py

```python
"""Primary application entrypoint.
"""

import locale
import logging
import os
import sys
import warnings
from typing import List, Optional

from pip._internal.cli.autocompletion import autocomplete
from pip._internal.cli.main_parser import parse_command
from pip._internal.commands import create_command
from pip._internal.exceptions import PipError
from pip._internal.utils import deprecation

logger = logging.getLogger(__name__)


# Do not import and use main() directly! Using it directly is actively
# discouraged by pip's maintainers. The name, location and behavior of
# this function is subject to change, so calling it directly is not
# portable across different pip versions.

# In addition, running pip in-process is unsupported and unsafe. This is
# elaborated in detail at
# https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-program.
# That document also provides suggestions that should work for nearly
# all users that are considering importing and using main() directly.

# However, we know that certain users will still want to invoke pip
# in-process. If you understand and accept the implications of using pip
# in an unsupported manner, the best approach is to use runpy to avoid
# depending on the exact location of this entry point.

# The following example shows how to use runpy to invoke pip in that
# case:
#
#     sys.argv = ["pip", your, args, here]
#     runpy.run_module("pip", run_name="__main__")
#
# Note that this will exit the process after running, unlike a direct
# call to main. As it is not safe to do any processing after calling
# main, this should not be an issue in practice.


def main(args: Optional[List[str]] = None) -> int:
    if args is None:
        args = sys.argv[1:]

    # Suppress the pkg_resources deprecation warning
    # Note - we use a module of .*pkg_resources to cover
    # the normal case (pip._vendor.pkg_resources) and the
    # devendored case (a bare pkg_resources)
    warnings.filterwarnings(
        action="ignore", category=DeprecationWarning, module=".*pkg_resources"
    )

    # Configure our deprecation warnings to be sent through loggers
    deprecation.install_warning_logger()

    autocomplete()

    try:
        cmd_name, cmd_args = parse_command(args)
    except PipError as exc:
        sys.stderr.write(f"ERROR: {exc}")
        sys.stderr.write(os.linesep)
        sys.exit(1)

    # Needed for locale.getpreferredencoding(False) to work
    # in pip._internal.utils.encoding.auto_decode
    try:
        locale.setlocale(locale.LC_ALL, "")
    except locale.Error as e:
        # setlocale can apparently crash if locale are uninitialized
        logger.debug("Ignoring error %s when setting locale", e)
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))

    return command.main(cmd_args)

```

### chroma-env/lib/python3.12/site-packages/pip/_internal/commands/index.py

```python
import logging
from optparse import Values
from typing import Any, Iterable, List, Optional

from pip._vendor.packaging.version import Version

from pip._internal.cli import cmdoptions
from pip._internal.cli.req_command import IndexGroupCommand
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.commands.search import print_dist_installation_info
from pip._internal.exceptions import CommandError, DistributionNotFound, PipError
from pip._internal.index.collector import LinkCollector
from pip._internal.index.package_finder import PackageFinder
from pip._internal.models.selection_prefs import SelectionPreferences
from pip._internal.models.target_python import TargetPython
from pip._internal.network.session import PipSession
from pip._internal.utils.misc import write_output

logger = logging.getLogger(__name__)


class IndexCommand(IndexGroupCommand):
    """
    Inspect information available from package indexes.
    """

    ignore_require_venv = True
    usage = """
        %prog versions <package>
    """

    def add_options(self) -> None:
        cmdoptions.add_target_python_options(self.cmd_opts)

        self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
        self.cmd_opts.add_option(cmdoptions.pre())
        self.cmd_opts.add_option(cmdoptions.no_binary())
        self.cmd_opts.add_option(cmdoptions.only_binary())

        index_opts = cmdoptions.make_option_group(
            cmdoptions.index_group,
            self.parser,
        )

        self.parser.insert_option_group(0, index_opts)
        self.parser.insert_option_group(0, self.cmd_opts)

    def run(self, options: Values, args: List[str]) -> int:
        handlers = {
            "versions": self.get_available_package_versions,
        }

        logger.warning(
            "pip index is currently an experimental command. "
            "It may be removed/changed in a future release "
            "without prior warning."
        )

        # Determine action
        if not args or args[0] not in handlers:
            logger.error(
                "Need an action (%s) to perform.",
                ", ".join(sorted(handlers)),
            )
            return ERROR

        action = args[0]

        # Error handling happens here, not in the action-handlers.
        try:
            handlers[action](options, args[1:])
        except PipError as e:
            logger.error(e.args[0])
            return ERROR

        return SUCCESS

    def _build_package_finder(
        self,
        options: Values,
        session: PipSession,
        target_python: Optional[TargetPython] = None,
        ignore_requires_python: Optional[bool] = None,
    ) -> PackageFinder:
        """
        Create a package finder appropriate to the index command.
        """
        link_collector = LinkCollector.create(session, options=options)

        # Pass allow_yanked=False to ignore yanked versions.
        selection_prefs = SelectionPreferences(
            allow_yanked=False,
            allow_all_prereleases=options.pre,
            ignore_requires_python=ignore_requires_python,
        )

        return PackageFinder.create(
            link_collector=link_collector,
            selection_prefs=selection_prefs,
            target_python=target_python,
        )

    def get_available_package_versions(self, options: Values, args: List[Any]) -> None:
        if len(args) != 1:
            raise CommandError("You need to specify exactly one argument")

        target_python = cmdoptions.make_target_python(options)
        query = args[0]

        with self._build_session(options) as session:
            finder = self._build_package_finder(
                options=options,
                session=session,
                target_python=target_python,
                ignore_requires_python=options.ignore_requires_python,
            )

            versions: Iterable[Version] = (
                candidate.version for candidate in finder.find_all_candidates(query)
            )

            if not options.pre:
                # Remove prereleases
                versions = (
                    version for version in versions if not version.is_prerelease
                )
            versions = set(versions)

            if not versions:
                raise DistributionNotFound(
                    f"No matching distribution found for {query}"
                )

            formatted_versions = [str(ver) for ver in sorted(versions, reverse=True)]
            latest = formatted_versions[0]

        write_output(f"{query} ({latest})")
        write_output("Available versions: {}".format(", ".join(formatted_versions)))
        print_dist_installation_info(query, latest)

```

### singlestore-env/lib/python3.12/site-packages/pip/_internal/commands/index.py

```python
import logging
from optparse import Values
from typing import Any, Iterable, List, Optional

from pip._vendor.packaging.version import Version

from pip._internal.cli import cmdoptions
from pip._internal.cli.req_command import IndexGroupCommand
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.commands.search import print_dist_installation_info
from pip._internal.exceptions import CommandError, DistributionNotFound, PipError
from pip._internal.index.collector import LinkCollector
from pip._internal.index.package_finder import PackageFinder
from pip._internal.models.selection_prefs import SelectionPreferences
from pip._internal.models.target_python import TargetPython
from pip._internal.network.session import PipSession
from pip._internal.utils.misc import write_output

logger = logging.getLogger(__name__)


class IndexCommand(IndexGroupCommand):
    """
    Inspect information available from package indexes.
    """

    ignore_require_venv = True
    usage = """
        %prog versions <package>
    """

    def add_options(self) -> None:
        cmdoptions.add_target_python_options(self.cmd_opts)

        self.cmd_opts.add_option(cmdoptions.ignore_requires_python())
        self.cmd_opts.add_option(cmdoptions.pre())
        self.cmd_opts.add_option(cmdoptions.no_binary())
        self.cmd_opts.add_option(cmdoptions.only_binary())

        index_opts = cmdoptions.make_option_group(
            cmdoptions.index_group,
            self.parser,
        )

        self.parser.insert_option_group(0, index_opts)
        self.parser.insert_option_group(0, self.cmd_opts)

    def run(self, options: Values, args: List[str]) -> int:
        handlers = {
            "versions": self.get_available_package_versions,
        }

        logger.warning(
            "pip index is currently an experimental command. "
            "It may be removed/changed in a future release "
            "without prior warning."
        )

        # Determine action
        if not args or args[0] not in handlers:
            logger.error(
                "Need an action (%s) to perform.",
                ", ".join(sorted(handlers)),
            )
            return ERROR

        action = args[0]

        # Error handling happens here, not in the action-handlers.
        try:
            handlers[action](options, args[1:])
        except PipError as e:
            logger.error(e.args[0])
            return ERROR

        return SUCCESS

    def _build_package_finder(
        self,
        options: Values,
        session: PipSession,
        target_python: Optional[TargetPython] = None,
        ignore_requires_python: Optional[bool] = None,
    ) -> PackageFinder:
        """
        Create a package finder appropriate to the index command.
        """
        link_collector = LinkCollector.create(session, options=options)

        # Pass allow_yanked=False to ignore yanked versions.
        selection_prefs = SelectionPreferences(
            allow_yanked=False,
            allow_all_prereleases=options.pre,
            ignore_requires_python=ignore_requires_python,
        )

        return PackageFinder.create(
            link_collector=link_collector,
            selection_prefs=selection_prefs,
            target_python=target_python,
        )

    def get_available_package_versions(self, options: Values, args: List[Any]) -> None:
        if len(args) != 1:
            raise CommandError("You need to specify exactly one argument")

        target_python = cmdoptions.make_target_python(options)
        query = args[0]

        with self._build_session(options) as session:
            finder = self._build_package_finder(
                options=options,
                session=session,
                target_python=target_python,
                ignore_requires_python=options.ignore_requires_python,
            )

            versions: Iterable[Version] = (
                candidate.version for candidate in finder.find_all_candidates(query)
            )

            if not options.pre:
                # Remove prereleases
                versions = (
                    version for version in versions if not version.is_prerelease
                )
            versions = set(versions)

            if not versions:
                raise DistributionNotFound(
                    f"No matching distribution found for {query}"
                )

            formatted_versions = [str(ver) for ver in sorted(versions, reverse=True)]
            latest = formatted_versions[0]

        write_output(f"{query} ({latest})")
        write_output("Available versions: {}".format(", ".join(formatted_versions)))
        print_dist_installation_info(query, latest)

```

[984 more indexed source files omitted to keep this export small. The full file list is in the Codebase structure section above.]