gpt4free icon indicating copy to clipboard operation
gpt4free copied to clipboard

Model Selection Error with Direct Provider Specification

Open nullstreak opened this issue 1 year ago • 2 comments

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.

nullstreak avatar Apr 21 '24 08:04 nullstreak

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.

hlohaus avatar Apr 23 '24 04:04 hlohaus

Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again.

github-actions[bot] avatar May 01 '24 00:05 github-actions[bot]

Closing due to inactivity.

github-actions[bot] avatar May 11 '24 00:05 github-actions[bot]