xtekky / gpt4free

The official gpt4free repository | various collection of powerful language models
https://g4f.ai
GNU General Public License v3.0
61.09k stars 13.31k forks source link

Getting model not found when using Completion with prompt attribute? #2230

Closed unical1988 closed 1 month ago

unical1988 commented 1 month ago

The exception is: Model not found: code-davinci-002

The code I use which from here (https://github.com/xtekky/gpt4free/blob/cc80f2d3159ca0b6f6bfa2c36c4be87bc96209b2/docs/legacy.md) is:

`import g4f

allowed_models = [ 'code-davinci-002', 'text-ada-001', 'text-babbage-001', 'text-curie-001', 'text-davinci-002', 'text-davinci-003' ]

response = g4f.Completion.create( model='text-davinci-003', prompt='say this is a test' )

print(response)`

any idea why?

TheFirstNoob commented 1 month ago

Hey! Thats model is not actucal and very old. Please use this list: https://github.com/xtekky/gpt4free/blob/main/g4f/models.py#L622

kqlio67 commented 1 month ago

The exception is: Model not found: code-davinci-002

The code I use which from here (https://github.com/xtekky/gpt4free/blob/cc80f2d3159ca0b6f6bfa2c36c4be87bc96209b2/docs/legacy.md) is:

`import g4f

allowed_models = [ 'code-davinci-002', 'text-ada-001', 'text-babbage-001', 'text-curie-001', 'text-davinci-002', 'text-davinci-003' ]

response = g4f.Completion.create( model='text-davinci-003', prompt='say this is a test' )

print(response)`

any idea why?

Hey @unical1988,

The models you're trying to use (code-davinci-002, text-ada-001, etc.) are outdated and no longer supported by the g4f API. As @TheFirstNoob mentioned, you should refer to the updated list of available models: https://github.com/xtekky/gpt4free/blob/main/g4f/models.py#L622

Currently, the Nexra provider supports both older and newer models GPT. Here's a list of the available text models:

'gpt-4', 'gpt-4-0613', 'gpt-4-32k', 'gpt-4-0314', 'gpt-4-32k-0314',
'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo-16k-0613', 'gpt-3.5-turbo-0301',
'gpt-3', 'text-davinci-003', 'text-davinci-002', 'code-davinci-002',
'text-curie-001', 'text-babbage-001', 'text-ada-001',
'davinci', 'curie', 'babbage', 'ada', 'babbage-002', 'davinci-002',

I noticed that you're using the old g4f interaction syntax. You can try the new OpenAI library syntax (e.g., Openai() class) or the g4f.client.Client approach.

Here's an example code to interact with the older code-davinci-002 model:

import g4f
import g4f.debug
g4f.debug.logging = True
g4f.debug.version_check = False

from g4f.client import Client

allowed_models = [
    'gpt-4', 'gpt-4-0613', 'gpt-4-32k', 'gpt-4-0314', 'gpt-4-32k-0314',
    'gpt-3.5-turbo', 'gpt-3.5-turbo-16k', 'gpt-3.5-turbo-0613', 'gpt-3.5-turbo-16k-0613', 'gpt-3.5-turbo-0301',
    'gpt-3', 'text-davinci-003', 'text-davinci-002', 'code-davinci-002',
    'text-curie-001', 'text-babbage-001', 'text-ada-001',
    'davinci', 'curie', 'babbage', 'ada', 'babbage-002', 'davinci-002',
]

client = Client()
response = client.chat.completions.create(
    model="code-davinci-002",
    provider=g4f.Provider.Nexra,
    messages=[{"role": "user", "content": "say this is a test"}],
)
print(response.choices[0].message.content)

While the older models GPT are still available, they are combined into the gpt-3 model. However, if you want to use the specific code-davinci-002 model, you can try the code example I provided.

github-actions[bot] commented 1 month ago

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