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

New RobocodersAPI provider with providers enhancement and client updates #2388

Merged
merged 8 commits into from
Nov 20, 2024

Conversation

kqlio67
Copy link
Contributor

@kqlio67 kqlio67 commented Nov 19, 2024

# g4f/Provider/

(g4f/Provider/Airforce.py):

Enhance Airforce provider with dynamic model fetching

  • Replace hardcoded model lists with dynamic model fetching methods
  • Add fetch_completions_models() and fetch_imagine_models() class methods to retrieve available models
  • Expand model_aliases dictionary with more comprehensive mappings for text and image models
  • Introduce default_image_model and additional_models_imagine for increased flexibility
  • Remove imported AirforceChat and AirforceImage dependencies
  • Update API endpoints and base URL to reflect current configuration
  • Add SSL warning suppression for requests to handle potential certificate issues
  • Dynamically populate text_models, image_models, and models lists at runtime

(g4f/Provider/Blackbox.py):

Enhance Blackbox AI provider configuration and streamline code

  • Modify default_image_model to use 'Image Generation' instead of 'generate_image'
  • Restructure vision_models to include more specific model variants
  • Introduce new userSelectedModel list to replace previous text_models configuration
  • Add a new static method generate_id() to replace get_random_string() for generating message IDs
  • Simplify models attribute by using dict.fromkeys() to remove duplicates
  • Update image generation handling in create_async_generator() to include an alt text for image responses
  • Optimize response processing by directly using response.text() instead of streaming content
  • Remove unnecessary imports and clean up code structure

Enhance model prefix handling for Blackbox AI

  • Add additional_prefixes dictionary to support more specific model prefixes
  • Extend model_prefixes to incorporate both existing trending agent modes and new additional prefixes
  • Improve model prefix generation with a more flexible approach
  • Include specific prefixes for models like 'gpt-4o', 'gemini-pro', and 'claude-sonnet-3.5'

#2384


(g4f/Provider/RobocodersAPI.py):

Add RobocodersAPI new async chat provider

  • Implement new asynchronous chat provider for Robocoders AI
  • Add support for multiple AI agents including GeneralCodingAgent, RepoAgent, and FrontEndAgent
  • Implement custom authentication and session management with methods for obtaining access token and creating session
  • Use aiohttp for async HTTP requests and streaming response handling
  • Include support for proxy configuration and message history
  • Utilize format_prompt for message preprocessing
  • Handle JSON response parsing and error scenarios

# g4f/client

(g4f/client/init.py):

Improve provider handling in async_generate method

  • Modify provider resolution logic in async_generate method
  • Add explicit handling for different provider input types
  • Simplify provider selection and instantiation
  • Ensure consistent provider handling for image generation
  • Improve type checking and error handling for providers

#2385


# g4f/

(g4f/models.py):

Update provider configurations for multiple models

  • Reorder and adjust best_provider for gemini_pro (GeminiPro now comes after Blackbox)
  • Update wizardlm_2_8x22b best_provider to use DeepInfraChat directly instead of IterListProvider
  • Modify sonar_online and sonar_chat to use PerplexityLabs as single provider instead of IterListProvider
  • Adjust provider ordering for some models to optimize provider selection

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

  • Add error handling for API calls in fetch_completions_models() and fetch_imagine_models().

g4f/Provider/Airforce.py Show resolved Hide resolved
g4f/Provider/Airforce.py Show resolved Hide resolved
g4f/Provider/Airforce.py Show resolved Hide resolved
g4f/Provider/Airforce.py Show resolved Hide resolved
g4f/Provider/Airforce.py Show resolved Hide resolved
@@ -254,6 +254,8 @@
provider_handler = self.models.get(model, provider or self.provider or BingCreateImages)
elif isinstance(provider, str):
provider_handler = convert_to_provider(provider)
else:

Choose a reason for hiding this comment

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

Consider adding a type hint to provider_handler for better clarity.

g4f/models.py Show resolved Hide resolved
g4f/models.py Show resolved Hide resolved
g4f/models.py Show resolved Hide resolved
g4f/models.py Show resolved Hide resolved
Copy link

Pull Request Review: New RobocodersAPI Provider with Enhancements

Changes Overview

Thank you for contributing to the project by enhancing the provider functionalities and adding the new RobocodersAPI provider! Your work will significantly improve the flexibility and efficiency of the codebase. Here are some specific points about the changes:

Provider Enhancements

Airforce Provider

  • Great job on replacing hardcoded model lists with dynamic fetching methods. This change brings increased flexibility and ensures that the models are always up-to-date.
  • The addition of fetch_completions_models() and fetch_imagine_models() methods is a fantastic improvement for better maintainability.
  • The comprehensive expansion of the model_aliases dictionary is also appreciated, making it easier to manage different model names.

Blackbox Provider

  • Excellent restructuring of the vision_models and introduction of the userSelectedModel list. This optimizes configuration and enhances usability.
  • The code simplifications like removing unnecessary imports and using dict.fromkeys() to strip duplicates show good coding practices.
  • The enhancements in model prefix handling improve the overall flexibility of handling various models.

New RobocodersAPI Provider

  • The implementation of a new asynchronous chat provider is well executed. The support for multiple AI agents adds versatility.
  • The custom authentication and session management methods are well thought out, ensuring secure and effective communication with the API.
  • Using aiohttp for async HTTP requests is a great choice, enhancing performance in asynchronous operations.

Client Updates

  • Improvements in the async_generate method demonstrate an understanding of provider handling, making it robust against various input types.
  • The updates make it easier to add or modify providers in the future.

Code Quality

  • The overall code is clean and follows good practices, ensuring readability and maintainability.
  • Good use of type hints and consistent comments enhances the understandability of the code.

Suggestions

  • Ensure that there are adequate unit tests for the new methods and providers implemented. This can help in maintaining the robustness of the code in future modifications.
  • It might be helpful to add documentation on how to use the new RobocodersAPI provider for better guidance to other developers.

Thank you once again for your excellent contributions to the project! Keep up the great work!

@hlohaus hlohaus merged commit ea34697 into xtekky:main Nov 20, 2024
1 check passed
@hlohaus
Copy link
Collaborator

hlohaus commented Nov 20, 2024

Thank you

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