Skip to content

Conversation

@Chenglong-MS
Copy link
Collaborator

fix the openai endpoint issue with custom api_base and api_keys

@Chenglong-MS Chenglong-MS requested a review from Copilot April 24, 2025 20:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the OpenAI endpoint issue by updating how custom API base and API keys are managed. Key changes include:

  • Changing newApiKey, newApiBase, and newApiVersion state initialization from undefined to empty strings.
  • Removing certain field error validations and default effect logic in ModelSelectionDialog.
  • Adding debug print statements in the OpenAI client creation and additional logging in agent_routes.
  • Bumping the project version in pyproject.toml.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/views/ModelSelectionDialog.tsx Updates state initialization and input validations for API key, base, and version fields.
pyproject.toml Bumps version from 0.2 to 0.2.1.
py-src/data_formulator/agents/client_utils.py Adds temporary debug print statements in get_completion for OpenAI endpoint details.
py-src/data_formulator/agent_routes.py Adds an extra print statement for error handling in test endpoint.
Comments suppressed due to low confidence (3)

src/views/ModelSelectionDialog.tsx:287

  • The removal of the error prop for the api_base input could impact validation for endpoints that require it. Please verify if this change is intentional or if validation feedback should still be provided.
                  placeholder="api_base"

py-src/data_formulator/agents/client_utils.py:69

  • Debug print statements have been introduced in the production code for the OpenAI client configuration. It is recommended to use a logging mechanism (like logger.debug) or remove these prints before merging.
            print(f"self.params: {self.params}")

py-src/data_formulator/agent_routes.py:161

  • The print statement for error output duplicates the logger output and may lead to inconsistent logging. Consider removing the print statement or standardizing error reporting using the logger.
            print(f"Error: {e}")

error={!(newEndpoint == "azure" || newEndpoint == "ollama" || newEndpoint == "") && !newApiKey}
value={newApiKey} onChange={(event: any) => { setNewApiKey(event.target.value); }}
value={newApiKey}
onChange={(event: any) => { setNewApiKey(event.target.value); }}
Copy link

Copilot AI Apr 24, 2025

Choose a reason for hiding this comment

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

Removing the error prop from the API key field may lead to users not receiving feedback when an API key is required. Consider reinstating validation for newApiKey based on the endpoint conditions.

Suggested change
onChange={(event: any) => { setNewApiKey(event.target.value); }}
onChange={(event: any) => { setNewApiKey(event.target.value); }}
error={newEndpoint !== "" && !newApiKey}
helperText={newEndpoint !== "" && !newApiKey ? "API key is required for this endpoint." : ""}

Copilot uses AI. Check for mistakes.
@Chenglong-MS Chenglong-MS merged commit 9363049 into main Apr 24, 2025
7 checks passed
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.

2 participants