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

Updating provider documentation and small fixes in providers #2469

Merged
merged 27 commits into from
Dec 9, 2024

Conversation

kqlio67
Copy link
Contributor

@kqlio67 kqlio67 commented Dec 8, 2024

No description provided.

kqlio67 added 19 commits December 7, 2024 23:51
- Add hidden_models set to exclude specific models
- Add evil alias for uncensored model handling
- Extend filtering for model-specific response tokens
- Add response buffering for streamed content
- Update model fetching with error handling
- Add caching system for validated values with file-based storage
- Rename 'flux' model to 'ImageGeneration' and update references
- Add temperature, top_p and max_tokens parameters to generator
- Simplify HTTP headers and remove redundant options
- Add model alias mapping for ImageGeneration
- Add file system utilities for cache management
- Add file-based caching system for access tokens and sessions
- Add robust error handling with specific error messages
- Add automatic dialog continuation on resource limits
- Add HTML parsing with BeautifulSoup for token extraction
- Add debug logging for error tracking
- Add timeout configuration for API requests
…ases

- Change default model from llama-3-405b to llama-3-70b
- Remove llama-3-405b from supported models list
- Remove llama-3.1-405b from model aliases
- Add image model 'flux' with dedicated API endpoint
- Refactor generator to support both text and image outputs
- Extract headers into reusable static method
- Add type hints for AsyncGenerator return type
- Split generation logic into _generate_text and _generate_image methods
- Add ImageResponse handling for image generation results

BREAKING CHANGE: create_async_generator now returns AsyncGenerator instead of AsyncResult
…tion

- Update models list to include gpt-3.5-turbo
- Remove chatgpt-4o-latest from supported models
- Remove model_aliases mapping for gpt-4o
- Add Accept-Language header for internationalization
- Maintain existing header configuration
- Improve request compatibility with language preferences
…nheritance

- Add ProviderModelMixin to class inheritance
- Import ProviderModelMixin from base_provider
- Move BaseConversation import to base_provider imports
- Add version suffix to o1 model IDs
- Update model aliases for o1-preview and o1-mini
- Standardize version format across model definitions
…eneration

- Split generation logic into dedicated image/text methods
- Add additional text models including sur and claude
- Add width/height parameters for image generation
- Add model existence validation
- Add hasattr checks for model lists initialization
- Add g4f/Provider/.cache to gitignore patterns
- Update default model to gemma-2b-it
- Add default_image_model configuration
- Remove llava-13b from supported models
- Simplify request headers
- Add new providers DarkAI and PollinationsAI
- Add new models for Mistral, Flux and image generation
- Update provider lists for existing models
- Add P1 and Evil models with experimental providers

BREAKING CHANGE: Remove llava-13b model support
- Change return type of  from  to  for consistency with import.
- Maintain overall functionality and structure of the  class.
- Ensure compatibility with type hinting standards in Python.
…e return

- Change return type of 'split_message' from 'list[str]' to 'List[str]' for consistency with import.
- Maintain overall functionality and structure of the 'Airforce' class.
- Ensure compatibility with type hinting standards in Python.
…ulSoup dependency

- Introduce a check for the BeautifulSoup library and handle its absence gracefully.
- Raise a  if BeautifulSoup is not installed, prompting the user to install it.
- Remove direct import of BeautifulSoup to avoid import errors when the library is missing.
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.

Review for Pull Request: Updating provider documentation and small fixes in providers

Summary

Thank you for your contribution to the project! This pull request includes updates to the provider documentation and some small fixes in the provider implementations.

Changes

  1. Documentation Updates:

    • The documentation for various AI providers and models has been updated to provide clearer information and organization.
    • New sections have been added, such as "Providers Free" and "Providers Needs Auth," which enhance the usability of the documentation.
  2. Code Fixes:

    • Minor adjustments in the provider classes, including updates to model aliases and default models.
    • Improved the structure of the provider classes to ensure better readability and maintainability.

Suggestions

  • Consider adding examples or use cases in the documentation to help users understand how to utilize the different providers effectively.
  • Ensure that all links in the documentation are functional and lead to the correct resources.

Conclusion

Overall, this is a great improvement to the documentation and the provider implementations. Thank you for your hard work and dedication to enhancing the project!

Keep up the great work! 😊

# G4F - Providers and Models

This document provides an overview of various AI providers and models, including text generation, image generation, and vision capabilities. It aims to help users navigate the diverse landscape of AI services and choose the most suitable option for their needs.

## Table of Contents
- [Providers](#providers)
- [Free](#providers-free)
- [Needs Auth](#providers-needs-auth)
- [Models](#models)
- [Text Models](#text-models)
- [Image Models](#image-models)
Copy link

Choose a reason for hiding this comment

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

  • The line - - [Vision Models](#vision-models) has an extra hyphen that should be removed to maintain consistency with the other entries.

### Providers Free
| Website | Provider | Text Models | Image Models | Vision Models | Stream | Status | Auth |
|----------|-------------|--------------|---------------|--------|--------|------|------|
|[api.airforce](https://api.airforce)|`g4f.Provider.Airforce`|`phi-2, gpt-4o-mini, gpt-4o, gpt-4-turbo, o1-mini, openchat-3.5, deepseek-coder, hermes-2-dpo, hermes-2-pro, openhermes-2.5, lfm-40b, german-7b, llama-2-7b, llama-3.1-70b, neural-7b, zephyr-7b, evil,`|`sdxl, flux-pro, flux, flux-realism, flux-anime, flux-3d, flux-disney, flux-pixel, flux-4o, any-dark`|❌|✔|![](https://img.shields.io/badge/Active-brightgreen)|❌+✔|
Copy link

Choose a reason for hiding this comment

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

  • The entry for g4f.Provider.Blackbox2 appears to be duplicated from the previous entry for g4f.Provider.Blackbox. Ensure that each provider is listed only once to avoid confusion.

|[console.upstage.ai/playground/chat](https://console.upstage.ai/playground/chat)|`g4f.Provider.Upstage`|`solar-pro, solar-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
|[whiterabbitneo.com](https://www.whiterabbitneo.com)|`g4f.Provider.WhiteRabbitNeo`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
|[you.com](https://you.com)|`g4f.Provider.You`|✔|✔|✔|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|❌+✔|
|[bing.com/images/create](https://www.bing.com/images/create)|`g4f.Provider.BingCreateImages`|❌|`dall-e-3`|❌|❌|![](https://img.shields.io/badge/Active-brightgreen)|✔|
Copy link

Choose a reason for hiding this comment

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

  • The entry for g4f.Provider.BingCreateImages has a missing model name in the Model column. Please provide the appropriate model name to maintain clarity.

|dalle-2|OpenAI|1+ Providers|[openai.com](https://openai.com/index/dall-e-2/)|
|emi||1+ Providers|[]()|
|any-dark||1+ Providers|[]()|
|dall-e-3|OpenAI|5+ Providers|[openai.com](https://openai.com/index/dall-e/)|
Copy link

Choose a reason for hiding this comment

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

  • The entry for dall-e-3 should be checked for consistency in the number of providers listed. Ensure that it matches the format used in other entries.

"llama-2-7b": "llama-2-7b-chat-int8",
"llama-3.1-70b": "llama-3.1-70b-turbo",
"neural-7b": "neural-chat-7b-v3-1",
"zephyr-7b": "zephyr-7b-beta",
"evil": "any-uncensored",
"sdxl": "stable-diffusion-xl-lightning",
"sdxl": "stable-diffusion-xl-base",
Copy link

Choose a reason for hiding this comment

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

The key "sdxl" is duplicated. Please ensure that each key is unique to avoid potential conflicts.



class RobocodersAPI(AsyncGeneratorProvider, ProviderModelMixin):
label = "API Robocoders AI"
url = "https://api.robocoders.ai/docs"
api_endpoint = "https://api.robocoders.ai/chat"
working = True
working = False
Copy link

Choose a reason for hiding this comment

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

The variable working is set to False, which may indicate that the API is currently not operational. If this is intentional, consider adding a comment explaining the reason for this change to provide clarity for future maintainers.

@@ -5,10 +5,13 @@
from .AIUncensored import AIUncensored
from .Aura import Aura
from .Chatgpt4o import Chatgpt4o
Copy link

Choose a reason for hiding this comment

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

The class name Chatgpt4o should be consistent with PEP 8 naming conventions. Consider renaming it to ChatGPT4o for clarity and consistency.

@@ -5,10 +5,13 @@
from .AIUncensored import AIUncensored
from .Aura import Aura
from .Chatgpt4o import Chatgpt4o
from .Chatgpt4Online import Chatgpt4Online
Copy link

Choose a reason for hiding this comment

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

The class name Chatgpt4Online should be consistent with PEP 8 naming conventions. Consider renaming it to ChatGPT4Online for clarity and consistency.

from .ChatgptFree import ChatgptFree
from .FlowGpt import FlowGpt
from .FreeNetfly import FreeNetfly
from .GPROChat import GPROChat
from .Koala import Koala
from .MagickPen import MagickPen
Copy link

Choose a reason for hiding this comment

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

The class name MagickPen should be consistent with PEP 8 naming conventions. Consider renaming it to MagicPen for clarity and consistency.

@@ -294,7 +294,7 @@ <h3>Settings</h3>
<option value="OpenaiChat">OpenAI ChatGPT</option>
<option value="Copilot">Microsoft Copilot</option>
<option value="Gemini">Google Gemini</option>
<option value="DDG">DuckDuckGo</option>
<option value="DDG">DuckDuckGo AI Chat</option>
Copy link

Choose a reason for hiding this comment

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

The option value 'DuckDuckGo AI Chat' should be consistent with the naming conventions used for other options. Consider whether 'DuckDuckGo' or 'DuckDuckGo AI Chat' is more appropriate for clarity and consistency.

@hlohaus
Copy link
Collaborator

hlohaus commented Dec 8, 2024

Thank you. I have updated the model list in models.py too.
I added a unittest to check the model s are in the provider's model list.

Copy link

github-actions bot commented Dec 8, 2024

Review by g4f copilot

Thank you for your contribution to the project! Here are some thoughts and suggestions:

General Comments:

  • Documentation Update: The update to the documentation is comprehensive and well-organized. The new structure with sections for free and auth-needed providers is very helpful.
  • Model and Provider Updates: The addition and correction of models and their respective providers enhance the clarity and utility of the documentation.

Specific Changes:

  1. Documentation Structure:

    • The introduction of separate sections for Free Providers and Providers Needing Authentication is a great improvement. It makes it easier for users to find relevant information based on their access rights.
  2. Model Updates:

    • The list of models has been updated to reflect current offerings and capabilities. This is crucial for maintaining accuracy.
    • Suggestions:
      • Consider adding a brief description or use-case for each model to help users decide which one to use for their specific needs.
  3. Provider Information:

    • The provider tables are now more detailed, providing status, streaming support, and authentication requirements which are vital for user decision-making.
    • Suggestions:
      • Include a column or section for known limitations or common issues users might encounter with each provider.
  4. Code Changes:

    • Several providers have been moved to not_working or renamed for clarity. This is beneficial for maintenance and user experience.
    • Suggestions:
      • Ensure there's a way for users to report when providers start/stop working to keep the documentation up-to-date.
  5. New Providers:

    • Introduction of new providers like Mhystical, PollinationsAI, etc., expands the scope of available options for users.

Code Review:

  • The diff shows careful attention to detail in updating the Provider and Model classes. Here are some points:
    • Renaming and Moving:
      • HuggingFace2 renamed to HuggingFaceAPI for clarity.
      • Moving Reka to needs_auth directory makes sense for authentication purposes.
    • Model Aliases:
      • The update in model aliases for various providers (Blackbox, Gemini, etc.) helps in standardization and reduces confusion.

Suggestions for Improvement:

  • Error Handling and Logging:
    • Ensure that the code includes proper error handling, especially for API calls that might fail due to rate limiting or authentication issues.
  • Testing:
    • It would be beneficial to add or update unit tests to cover new functionalities and provider interactions.
  • Documentation for Developers:
    • The documentation seems focused on end-users. Adding developer-oriented documentation explaining how to contribute new providers or models would be valuable.

Conclusion:

Your pull request has significantly enhanced the documentation and functionality of the project. With a few minor additions and clarifications, this update will be even more useful for both users and contributors. Thank you for your hard work!

Copy link

github-actions bot commented Dec 8, 2024

Review by g4f copilot:

Thank you for your contributions to the project! Here's my review:

Documentation Changes

  • Updated Provider Documentation: The documentation for various AI providers and models has been significantly updated. The new structure categorizes providers into "Free" and "Needs Auth" which makes it easier for users to find appropriate services. This change is highly appreciated as it enhances user experience.

  • Model Aliases and Best Providers: The introduction of model aliases and the specification of best providers for each model will help users in selecting the most suitable options for their needs. This clarity in documentation will certainly aid in better utilization of the services.

Code Changes

  • Provider Updates:

    • Airforce.py: New model aliases have been added, and some models have been updated. The change from discolm-german-7b to german-7b simplifies naming.
    • AmigoChat.py: Removal of mistral-tiny model suggests a cleanup or deprecation of less-used models.
    • Blackbox.py: Updated to include newer versions of models like gpt-4o and claude-3.5-sonnet, keeping the provider up to date with latest offerings.
  • New Providers:

    • The introduction of Flux provider for image generation with a new flux-dev model alias is a great addition, expanding the capabilities of the project.
  • Provider Renaming and Refactoring:

    • Renaming HuggingFace2.py to HuggingFaceAPI.py makes the purpose of the file clearer, and refactoring is evident in how the providers are now structured under needs_auth and not_working directories, which helps in maintaining the codebase.
  • Model Updates in models.py:

    • The reorganization of models, updating best providers, and removing or renaming models like gpt-4o and gpt-4o-mini to better reflect current standards or available models is commendable.

Suggestions:

  • Documentation Consistency: Ensure that all model names and provider names are consistent throughout the documentation. For instance, there might be minor discrepancies in model naming like gpt-4o vs gpt_4o.

  • Testing: Given the extensive changes in provider listings and model aliases, comprehensive testing should be conducted to ensure all new aliases work as expected.

  • Comments and Documentation: Although the documentation has been updated, additional inline comments explaining the choice of best providers or the reasoning behind model alias changes could be beneficial for future contributors or users.

  • Old Providers: Consider if there's a way to archive or mark providers that are no longer working rather than removing them entirely, to keep a historical record.

Thank you again for your efforts in updating and refining our documentation and codebase! Your contributions significantly enhance the project's usability and maintainability.

@kqlio67
Copy link
Contributor Author

kqlio67 commented Dec 8, 2024

Thank you so much for your valuable input and feedback @hlohaus! Your contributions to this project are truly appreciated.

I'm particularly impressed with the unit test you've added to check if all the models we use are present in the provider's model list. This is an excellent addition that will significantly enhance our ability to verify the consistency between our code and the provider's available models. It's a great step towards improving the overall reliability of our system.

Your work on updating the model list in models.py is also very helpful in keeping our codebase up-to-date. These changes will undoubtedly make our project more robust and easier to maintain.

I have a suggestion that I think could further improve the user experience in our GUI. Have you considered adding a "Continue generating" function, similar to what ChatGPT offers? This feature could be incredibly useful when the model hasn't fully completed generating code or text. Users could simply click a button to continue the generation process. I believe this would be a valuable addition, but I'm not entirely confident in implementing it correctly myself. If you have some free time in the future, it would be fantastic to see such a feature or enhancement in the GUI.

Once again, thank you for your outstanding contributions to this project. Your work is making a real difference!

@TheFirstNoob
Copy link

TheFirstNoob commented Dec 9, 2024

@kqlio67 Hi.
I had a similar idea with "Continue" in my test form as "Send text: Continue + last line of text". This is not very stable because the model can either correctly continue or, on the contrary, repeat some part of the answer from the previous text, but as a fast function it works quite well.
I think something similar can be implemented.

Copy link

github-actions bot commented Dec 9, 2024

g4f Copilot Review of "Updating provider documentation and small fixes in providers"

Thank you for your contributions to the g4f project! This pull request makes significant improvements to the provider documentation and includes helpful fixes in several provider files.

Here's a breakdown of my review:

Positive Aspects:

  • Improved Documentation: The providers-and-models.md file is much better organized now with the separation of free and authentication-required providers. The tables are clear, concise, and include helpful links and status indicators. This greatly enhances the user experience and makes it easier to understand the available options.
  • Model Alias Updates: The updates to model aliases in various provider files ensure better compatibility and functionality across different models. These small changes can prevent unexpected errors and improve the overall robustness of the system.
  • New Providers and Models: The addition of new providers and models keeps the g4f project up-to-date with the ever-evolving AI landscape, enhancing its capability and coverage.
  • Provider Categorization: The new separation into "Providers Free" and "Providers Needs Auth" categories greatly improves the readability and usability of the documentation.
  • Clear Status Indicators: The use of shields to display the status of each provider is highly effective in conveying at-a-glance information about their availability.

Areas for Potential Improvement:

  • Inconsistency in models.py: While the documentation is greatly improved, there seems to be a few inconsistencies that need to be addressed in g4f/models.py. The best_provider for some models might need to be updated according to the latest functional providers and the current status. Also ensure consistent naming for model aliases across documentation and provider scripts.
  • "Not Working" Directory: I see that some provider files have been moved into a not_working directory. Consider adding a section in providers-and-models.md that briefly notes these providers and why they are currently inactive, with a note of potential future support (if applicable). This proactive communication is good for transparency.
  • Testing: It's important to thoroughly test the updated providers and the changes to the model aliases to ensure everything is functioning as intended. Please add information about the testing process you've used (or plans for further testing) to this PR.
  • Missing description: The pull request description is missing. Please add a description summarising the changes included in this pull request.

Overall:

This pull request is a valuable contribution to the project. The improvements to the documentation and the fixes in the provider files are significant and greatly enhance the user experience. Addressing the points mentioned above will further improve this already excellent contribution. I recommend merging this pull request after the suggested changes have been implemented and thoroughly tested.

Copy link

github-actions bot commented Dec 9, 2024

Review for Pull Request: Updating provider documentation and small fixes in providers

Overview

Thank you for your contribution to the project! This pull request provides updates to the provider documentation and includes several small fixes in the provider implementations.

Changes

  1. Documentation Updates:

    • Enhanced the documentation for various AI providers, including the addition of new sections like "Providers Free" and "Providers Needs Auth". This makes it easier for users to navigate and understand the different options available.
    • Improved the layout and organization of the documentation, which enhances readability.
  2. Code Fixes:

    • Added new models to the additional_models_imagine list for the Airforce provider.
    • Removed deprecated models and fixed model aliases in several provider files, ensuring that they reflect the current state of available models.
    • Updated the label for the DDG provider to "DuckDuckGo AI Chat" for clarity.
    • Made adjustments to multiple provider classes to improve consistency and maintainability.

Suggestions

  • Ensure that all changes are thoroughly tested to prevent any regressions or issues in the functionality of the providers.
  • Consider adding examples or usage tips in the documentation to further assist users in understanding how to utilize the providers effectively.

Overall, this is a great update that improves both the documentation and the codebase. Thank you for your hard work and dedication to enhancing the project!

Copy link

github-actions bot commented Dec 9, 2024

Pull Request Review for "Updating provider documentation and small fixes in providers"

Summary

Thank you for your contribution to the project! This pull request includes updates to the provider documentation and some small fixes in the provider implementations.

Changes

  • Documentation Updates: The documentation for various AI providers and models has been improved, making it easier for users to navigate and understand the available options.
  • Code Fixes: Minor adjustments have been made in the provider code, including updates to model aliases and the addition of new models.

Review

  • The changes in the documentation are clear and enhance the overall usability of the project. The new structure with sections for free providers and those requiring authentication is particularly helpful.
  • The code fixes appear to be well-implemented, ensuring that the model aliases are correctly mapped and that the providers are functioning as intended.

Suggestions

  • Consider adding examples or usage tips in the documentation to further assist users in understanding how to utilize the different providers effectively.
  • Ensure that all new models added are thoroughly tested to confirm they work as expected.

Conclusion

Overall, this pull request is a valuable addition to the project. Thank you for your hard work and dedication! Looking forward to seeing more contributions from you in the future.

Best regards,
g4f copilot

Copy link

github-actions bot commented Dec 9, 2024

g4f copilot's Review of "Updating provider documentation and small fixes in providers"

Thank you for your contributions to the G4F project! This pull request makes significant improvements to the provider documentation and includes several helpful fixes.

Here are my comments:

Overall:

The updated documentation is much clearer and easier to navigate. The separation of free and auth-required providers is a great addition. The use of shields.io badges for status is visually appealing and informative. The tables are well-organized and easy to read.

Specific Comments:

  • .gitignore changes: The removal of g4f/Provider/.cache from the .gitignore is a good change, ensuring that cached files are not committed.
  • Documentation: The documentation is significantly improved, but could benefit from a section explaining how to choose the best provider for the given model.
  • Provider updates: The individual provider updates seem sensible and aimed at improved functionality. Some providers have been moved to the not_working directory (RobocodersAPI, MagickPen, Upstage), which is a good practice for managing outdated or problematic providers. It might be worthwhile adding a comment explaining why a provider is in not_working.

Minor suggestions:

  • Consider adding a column to the provider tables indicating the rate limit of each provider to help users manage expectations.
  • Review the status badges on each provider. Some providers list a status as "Error" or "Unknown", where a clear "Inactive", "Rate Limited", "Maintenance", or other relevant status would be more informative.
  • The models list needs another review. There are some repeated models and some that no longer work, consider removing some to simplify this part of the documentation. The descriptions of the models could also be improved.

Overall, this is a high-quality pull request that improves both the code and the documentation. I recommend merging this PR after addressing the minor suggestions above.

Copy link

github-actions bot commented Dec 9, 2024

Review for Pull Request: Updating provider documentation and small fixes in providers

Summary

Thank you for your contribution to the project! This pull request includes updates to the provider documentation and some small fixes in the provider implementations.

Changes

  • Documentation Updates: The documentation for various AI providers and models has been improved, making it easier for users to navigate and understand the available options.
  • Code Fixes: Minor adjustments have been made in the provider code, including updates to model aliases and the addition of new models.

Highlights

  • The addition of new models in the Airforce and PollinationsAI providers enhances the functionality and options available to users.
  • The documentation now includes a clearer structure with sections for free providers, providers that require authentication, and detailed model descriptions.

Suggestions

  • Consider adding examples of how to use the new models in the documentation to further assist users.
  • Ensure that all links in the documentation are functional and lead to the correct resources.

Conclusion

Overall, this pull request significantly improves the clarity and usability of the provider documentation. Great job on the updates!

Looking forward to seeing more contributions from you in the future!

Best regards,
g4f Copilot

@hlohaus hlohaus merged commit bb9132b into xtekky:main Dec 9, 2024
1 check passed
@hlohaus
Copy link
Collaborator

hlohaus commented Dec 9, 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.

3 participants