Skip to content
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

bugfix: openai models not discoverable #64

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

haesleinhuepf
Copy link
Contributor

@haesleinhuepf haesleinhuepf commented Jan 27, 2025

Hi @royerloic ,

a student of mine reported that openai models are not discoverable by napari-chatgpt, with an error message in the terminal. I found the error online, tested the proposed solution of downgrading httpx to 0.27.2 and it worked. Hence, you find this solution here as PR.

closes #62

Best,
Robert

Full error message:

|\ Enumerating all OpenAI ChatGPT models:
||\ Setting API key: 'OpenAI':
|||-> API key name: 'OPENAI_API_KEY'
|||-> API key is already set as an environment variable!
||-<< 0.00 microseconds
||
||-> Error: TypeError with message: 'Client.__init__() got an unexpected keyword argument 'proxies'' occured while trying to get the list of OpenAI models.
Traceback (most recent call last):
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\napari_chatgpt\utils\openai\model_list.py", line 39, in get_openai_model_list
    client = OpenAI()
             ^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\openai\_client.py", line 123, in __init__
    super().__init__(
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\openai\_base_client.py", line 844, in __init__
    self._client = http_client or SyncHttpxClientWrapper(
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\openai\_base_client.py", line 742, in __init__
    super().__init__(**kwargs)
TypeError: Client.__init__() got an unexpected keyword argument 'proxies'
|-<< 1.42 milliseconds
|
|-> Setting up model selection UI.
|\ Enumerating all OpenAI ChatGPT models:
||\ Setting API key: 'OpenAI':
|||-> API key name: 'OPENAI_API_KEY'
|||-> API key is already set as an environment variable!
||-<< 0.00 microseconds
||
||-> Error: TypeError with message: 'Client.__init__() got an unexpected keyword argument 'proxies'' occured while trying to get the list of OpenAI models.
Traceback (most recent call last):
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\napari_chatgpt\utils\openai\model_list.py", line 39, in get_openai_model_list
    client = OpenAI()
             ^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\openai\_client.py", line 123, in __init__
    super().__init__(
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\openai\_base_client.py", line 844, in __init__
    self._client = http_client or SyncHttpxClientWrapper(
                                  ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\rober\miniforge3\envs\nap-gpt\Lib\site-packages\openai\_base_client.py", line 742, in __init__
    super().__init__(**kwargs)
TypeError: Client.__init__() got an unexpected keyword argument 'proxies'

Summary by CodeRabbit

  • Dependencies
    • Added httpx library version 0.27.2 as a project dependency

Copy link
Contributor

coderabbitai bot commented Jan 27, 2025

Walkthrough

The pull request introduces a new dependency by adding the httpx library, version 0.27.2, to the project's setup.cfg file. This change involves updating the install_requires section to include the specific version of the HTTP client library, which may be intended to support network-related functionality in the project.

Changes

File Change Summary
setup.cfg Added httpx==0.27.2 to install_requires section

Assessment against linked issues

Objective Addressed Explanation
Resolve ChatGPT model selection issue [#62] Unable to determine direct connection between adding httpx and resolving model selection problem

Poem

🐰 A rabbit's dependency dance,
HTTPX joins with a glance,
Version point-two-seven-point-two,
Bringing network magic anew,
Hopping libraries with glee! 🌐


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
setup.cfg (1)

69-69: Consider this a temporary fix and monitor for updates.

While this fixes the immediate issue, pinning to an older version of httpx might need to be revisited when:

  1. OpenAI client releases updates that resolve the compatibility issue
  2. Security updates become available for httpx

Consider:

  1. Adding a comment explaining why this specific version is required
  2. Creating an issue to track the need to upgrade httpx when possible
  3. Setting up dependency scanning to alert on security updates
     # needed because lxml has spun out this code out of its main repo:
     lxml_html_clean
-    httpx==0.27.2
+    # Pinned to 0.27.2 to fix TypeError with OpenAI client (see PR #64)
+    httpx==0.27.2
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59b996a and 5b5575a.

📒 Files selected for processing (1)
  • setup.cfg (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: macos-latest py3.11
  • GitHub Check: macos-latest py3.10
  • GitHub Check: macos-latest py3.9
  • GitHub Check: windows-latest py3.11
  • GitHub Check: windows-latest py3.10
  • GitHub Check: windows-latest py3.9
  • GitHub Check: ubuntu-latest py3.11
  • GitHub Check: ubuntu-latest py3.10
  • GitHub Check: ubuntu-latest py3.9
🔇 Additional comments (1)
setup.cfg (1)

69-69: Verify httpx version compatibility and security implications.

While pinning httpx to 0.27.2 resolves the TypeError with OpenAI client, we should verify this version's compatibility and security status.

Let's check the compatibility and security implications:

✅ Verification successful

✓ httpx 0.27.2 is compatible and secure

The pinned version satisfies OpenAI's requirements (>=0.23.0,<1) and has no known security vulnerabilities.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check latest versions and security advisories for httpx

# Get latest httpx version from PyPI
echo "Latest httpx version:"
curl -s https://pypi.org/pypi/httpx/json | jq -r '.info.version'

# Check if openai has specific httpx requirements
echo -e "\nOpenAI package requirements:"
curl -s https://pypi.org/pypi/openai/1.42.0/json | jq -r '.info.requires_dist[]' | grep -i httpx

# Check for security advisories
echo -e "\nSecurity advisories for httpx:"
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: PIP, package: "httpx") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}'

Length of output: 931

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.

Problems with chatGPT utilization
1 participant