gpt4free
gpt4free copied to clipboard
Model Selection Error with Direct Provider Specification
Certain models throw an error when a provider is specified directly, despite functioning correctly when the same model is executed randomly via the RetryProvider.
To reproduce the issue, consider the following example:
from g4f.client import Client
import g4f
client = Client()
response = client.chat.completions.create(
messages=[{'role':'user', 'content': 'test'}],
model=g4f.models.mistral_7b,
provider=g4f.Provider.HuggingChat,
stream=True,
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content or "", end="")
This code snippet yields the following error:
g4f.errors.ModelNotSupportedError: Model is not supported: mistralai/Mistral-7B-Instruct-v0.1 in: HuggingChat
However, when we comment out the provider=g4f.Provider.HuggingChat line and run the code multiple times, allowing the RetryProvider to randomly select the HuggingChat provider, the model functions as expected.
You can only use the models that the provider supports. If you want to run a provider with its default model, you can pass g4f.models.default.
Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.
Closing due to inactivity.