[EAGLE-6237]: update code snippets for MCP/OpenAI and make env vars take precedence #607
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces enhancements to the configuration handling, URL generation, and client script generation in the Clarifai codebase. The changes improve flexibility by introducing new default values, methods for constructing URLs for specific endpoints, and updated logic for generating client scripts based on context and method signatures.
Configuration Enhancements:
DEFAULT_UI
andDEFAULT_BASE
) in theContext
class when environment variables are not set. This ensures a more robust configuration handling process.__getattr__
inContext
to prioritize environment variables over configuration values and provide detailed error messages for missing attributes.URL Generation Improvements:
mcp_api_url
andopenai_api_url
methods inClarifaiUrlHelper
to generate URLs for MCP-hosted models and OpenAI-compatible models, respectively. These methods streamline URL creation for specific use cases.Client Script Generation Updates:
generate_client_script
to support context-based URL generation usingConfig
andClarifaiUrlHelper
. This allows dynamic selection of API endpoints based on the context.Constants and Utilities:
MCP_TRANSPORT_NAME
andOPENAI_TRANSPORT_NAME
toclarifai/utils/constants.py
for identifying specific transport methods.has_signature_method
to check for the existence of specific method signatures in a list.These changes collectively enhance the configurability, extensibility, and usability of the Clarifai codebase.