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

feat: Add Multi-Model Provider Support to Agent Component #4416

Merged
merged 8 commits into from
Nov 6, 2024

Conversation

edwinjosechittilappilly
Copy link
Collaborator

Changes Made

  • Integrated model provider constants from model_input_constants.py into the Agent component to support multiple LLM providers
  • Added dynamic field management for different model providers (OpenAI, Azure, Groq, Anthropic, NVIDIA)
  • Implemented a dropdown for model provider selection with automatic input field updates

Technical Details

  1. Model Provider Integration:

    • Used MODEL_PROVIDERS_DICT from model_input_constants.py to manage provider-specific configurations
    • Each provider entry contains fields, inputs, prefix, and component class information
    • Allows seamless switching between different LLM providers
  2. Dynamic Field Management:

    • When a provider is selected, the agent automatically:
      • Adds provider-specific input fields (e.g., API keys, model names)
      • Removes fields from other providers to keep the interface clean
      • Handles "Custom" option for user-provided LLM implementations
  3. Provider-Specific Model Building:

    • Implemented get_llm() and _build_llm_model() methods to construct the appropriate LLM instance
    • Uses provider prefixes to correctly map input fields to model parameters

This update makes the Agent component more flexible by supporting multiple LLM providers while maintaining a clean and intuitive interface.


This pull request refactors the model components and their associated constants, improving the organization and maintainability of the code. The changes include the removal of the ModelConstants class, the introduction of a new module for model input constants, and updates to the agent component to utilize the new constants.

Refactoring of model components and constants:

  • Removed the ModelConstants class and its initialization logic from model_constants.py.
  • Introduced model_input_constants.py to define model input constants and utility functions for filtering and creating input fields.
  • Removed the get_model_info function from model_utils.py as its functionality is now covered by the new constants module.

Updates to agent components:

  • Updated agent.py to use the new MODEL_PROVIDERS_DICT and ALL_PROVIDER_FIELDS from model_input_constants.py for managing model provider inputs and fields.
  • Simplified the AgentComponent class to dynamically handle model provider inputs using the new constants, enhancing flexibility and reducing redundancy [1] [2].
Screenshot 2024-11-05 at 3 58 49 PM

- Integrated model provider constants from `model_input_constants.py` into the Agent component to support multiple LLM providers
- Added dynamic field management for different model providers (OpenAI, Azure, Groq, Anthropic, NVIDIA)
- Implemented a dropdown for model provider selection with automatic input field updates
making custom separate from sort
@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request python Pull requests that update Python code labels Nov 5, 2024
@github-actions github-actions bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 5, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Nov 6, 2024
Copy link

codspeed-hq bot commented Nov 6, 2024

CodSpeed Performance Report

Merging #4416 will improve performances by 17.29%

Comparing add_llm_simple_agent (e20292f) with main (ed69253)

Summary

⚡ 1 improvements
✅ 15 untouched benchmarks

Benchmarks breakdown

Benchmark main add_llm_simple_agent Change
test_successful_run_with_input_type_any 528.3 ms 450.4 ms +17.29%

@edwinjosechittilappilly edwinjosechittilappilly merged commit ae7d037 into main Nov 6, 2024
27 of 28 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the add_llm_simple_agent branch November 6, 2024 16:15
joaoguilhermeS pushed a commit that referenced this pull request Nov 7, 2024
* Add Multi-Model Provider Support to Agent Component

- Integrated model provider constants from `model_input_constants.py` into the Agent component to support multiple LLM providers
- Added dynamic field management for different model providers (OpenAI, Azure, Groq, Anthropic, NVIDIA)
- Implemented a dropdown for model provider selection with automatic input field updates

* sorted list

* Update agent.py

making custom separate from sort

* chore: remove unit test

---------

Co-authored-by: italojohnny <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer python Pull requests that update Python code size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants