-
-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Add new provider, enhance functionality, and update docs #2304
Conversation
… and improved chat completions example
There was a problem hiding this 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: Add new provider, enhance functionality, and update docs
Summary
Thank you for your contributions to the project! This pull request adds a new provider (GizAI
), enhances functionalities related to system prompts, and improves the documentation significantly. These changes enhance both the internal structure of the project and user interaction.
Highlights
- New Provider: Introduced
GizAI
with a variety of models for text and image generation. This is a great addition and expands the range of capabilities available to users. - System Prompt Enhancement: The addition of system prompt support in the
Completions
class is valuable. It follows best practices and aligns with other modern API interfaces. - Image Handling Improvements: The enhancements for image handling in the GUI are user-friendly and improve maintainability of the image features.
- Documentation Updates: Comprehensive updates to the README and various documentation files improve clarity for users. This ensures that they can easily understand how to use new functionalities like the system prompts and new models.
Detailed Comments
- Code Quality: The new provider implementation in
GizAI.py
follows good coding standards, maintaining readability and structure. - Performance Considerations: The async handling appears effective, leveraging non-blocking calls appropriately. The decision to manage images in a dedicated directory helps in organization.
- UI Improvements: The changes in the GUI for image handling make it consistent and enhance the user experience significantly. Adding controls for image navigation and display is commendable.
- Documentation: The updates to the various documentation files, including the client API and guides, provide clear examples and enhance understanding. The corrections in the README concerning links and formatting also improve navigation.
Suggestions
- Unit Tests: If not already included, it would be good to see unit tests for the new provider and new features added to ensure they work as expected under different conditions.
- Error Handling: It might be beneficial to add more robust error handling in the image handling features, especially for scenarios where images fail to load.
Overall, this is an impressive contribution that significantly enhances the project. Thank you once again for your hard work! Keep it up!
@@ -10,7 +10,7 @@ | |||
class AI365VIP(AsyncGeneratorProvider, ProviderModelMixin): | |||
url = "https://chat.ai365vip.com" | |||
api_endpoint = "/api/chat" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The 'working' attribute was changed from True to False. It's best to provide a clear reason or explanation for this change for better understanding and maintenance.
messages: Messages, | ||
proxy: str = None, | ||
**kwargs | ||
) -> AsyncResult: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider providing more descriptive variable names instead of using general kwargs in the method signature.
# Image generation | ||
prompt = messages[-1]["content"] | ||
data = { | ||
"model": model, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure input parameters like width, height, steps, output_format, etc., are properly validated for valid values to prevent potential errors.
# Chat completion | ||
data = { | ||
"model": model, | ||
"input": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding input validation for messages structure to ensure it aligns with the expected format.
@@ -14,36 +14,38 @@ | |||
from fastapi.encoders import jsonable_encoder | |||
from fastapi.middleware.cors import CORSMiddleware | |||
from pydantic import BaseModel | |||
from typing import Union, Optional | |||
from typing import Union, Optional, Iterator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider removing the unused import Iterator
if it is not used elsewhere in the code.
g4f/gui/server/backend.py
Outdated
@@ -1,5 +1,6 @@ | |||
import json | |||
from flask import request, Flask | |||
import os | |||
from flask import request, Flask, jsonify, send_from_directory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure consistent formatting of import statements.
g4f/gui/server/backend.py
Outdated
@@ -54,6 +55,10 @@ | |||
'/images/<path:name>': { | |||
'function': self.serve_images, | |||
'methods': ['GET'] | |||
}, | |||
'/images': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a docstring to describe the purpose of the get_images function.
g4f/gui/server/backend.py
Outdated
@@ -54,6 +55,10 @@ | |||
'/images/<path:name>': { | |||
'function': self.serve_images, | |||
'methods': ['GET'] | |||
}, | |||
'/images': { | |||
'function': self.get_images, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding type hints for better code documentation and understanding.
g4f/gui/server/backend.py
Outdated
}, | ||
'/images': { | ||
'function': self.get_images, | ||
'methods': ['GET'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure alignment of method attributes for clarity.
g4f/gui/server/backend.py
Outdated
@@ -110,4 +115,19 @@ | |||
Returns: | |||
str: A JSON formatted string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider providing more detailed description in the docstring for clarity.
@kqlio67 Hello. Glad to see you with new changes :)
I will also assume that after this problem all flux models began to generate images of poor quality, but here the problem is not with the provider, but with flux itself. Also for NexraGPT4o the answer occurs:
|
Also don't forget about the o1 issue with amigochat in #2289 |
After previous async update, code might need an AsyncClient definition for legacy script compatibility. And appropriate deprecation warning. Also is this line still correct? |
…g4f/client/client.py)
We definitely need to reimplement |
Hi @xtekky! I'd like to get your input on reimplementing AsyncClient. Before proceeding, I'd appreciate your guidance on the preferred approach:
I'll include the previous AsyncClient documentation as well. I noticed the PR was already merged - I'll create a new one with these changes once you confirm the direction. Looking forward to your feedback! |
Hi @UX0l0l! Thanks for bringing this up. Regarding amigochat, I'm not sure if we'll keep this provider due to ongoing Cloudflare-related issues. It might be temporarily disabled until we find a stable solution. As for the o1 models, I'm actively looking for providers that support these models. I'll definitely add new providers with o1 support once I find reliable options |
# New provider added
gemini-flash, gemini-pro, gpt-4o-mini, gpt-4o, claude-3.5-sonnet, claude-3-haiku, llama-3.1-70b, llama-3.1-8b, mistral-large
sdxl, sd-1.5, sd-3.5, flux-schnell
G4F update
(docs/providers-and-models.md): add GizAI provider with multiple models
(g4f/gui/server/api.py): enhance image handling and directory management
(g4f/gui/server/website.py): add redirect for /images/ endpoint
(g4f/gui/client/index.html): enhance model/provider options
# G4F improvements
(g4f/api/init.py): refactor API structure and improve async handling
create_app
to accept an optionalg4f_api_key
parameter.ChatCompletionsForm
toChatCompletionsConfig
andImagesGenerateForm
toImageGenerationConfig
.chat_completions
andgenerate_image
endpoints./v1/images/generate
.list_ignored_providers
and related setter method.(g4f/models.py): add new provider GizAI and update best providers
Add GizAI as a new provider for various models and update best provider lists
- Add GizAI to the imports and update best provider lists for several models
- Update
default
model's best providers- Adjust
gpt-4o
,gpt-4o-mini
,gpt-4
,o1-mini
,llama-3.1-8b
,llama-3.1-70b
,mistral-large
,claude-3-haiku
,claude-3.5-sonnet
,gemini-pro
,gemini-flash
,sd-1.5
,sd-3.5
, andflux-schnell
to include GizAI# Updating documentation and improving G4F
(README.md): update README with badges and links
Add new badges for commits, issues, and license at the top for improved visibility
Enhance author attribution with centered formatting
Correct various internal links within the Table of Contents
Fix broken link to the Interference API documentation
Adjust formatting for better readability and consistency throughout the file
Correct typo in the "Latest version" note and update internal links
(docs/async_client.md): update guide compatibility and improved chat completions example
(docs/async_client.md): update G4F async client API guide
dall-e-3
withflux
in image generation examples. ((Add new provider, enhance functionality, and update docs #2304 (comment)))flux
flux
flux
for image generation(docs/client.md): update G4F Client API guide
Creating Chat Completions
(docs/client.md): add base64 response format for image generation
(docs/interference-api.md): update Interference API usage guide
(docs/interference-api.md): update image generation model in usage guide