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

DDG Provider - 429 ERR_INPUT_LIMIT #2586

Open
BlyZeDev opened this issue Jan 20, 2025 · 8 comments
Open

DDG Provider - 429 ERR_INPUT_LIMIT #2586

BlyZeDev opened this issue Jan 20, 2025 · 8 comments
Assignees
Labels
bug Something isn't working stale

Comments

@BlyZeDev
Copy link

Bug description

{"error": {"message": "ResponseStatusError: Response 429: {\"action\":\"error\",\"status\":429,\"type\":\"ERR_INPUT_LIMIT\"}"}, "model": "gpt-4o-mini", "provider": "DDG"}

How can I find out the max conversation history character limit?

Environment

  • Python 3.11.2
  • Germany
@BlyZeDev BlyZeDev added the bug Something isn't working label Jan 20, 2025
@hlohaus
Copy link
Collaborator

hlohaus commented Jan 24, 2025

Hey, you could check message lengths in Python like this, see? import json; print(f"Len: {len(json.dumps(messages))}")

@BlyZeDev

@BlyZeDev
Copy link
Author

I'm calling the API from C#.
But I just need the length of all messages together.

Btw the issue is very inconsistent.
Sometimes it happens with small message sizes and sometimes it works with very big message sizes. Kinda weird.
I'll update to the newest version and send the length asap when the next error occurs.

@hlohaus
Copy link
Collaborator

hlohaus commented Jan 25, 2025

@BlyZeDev It gives is an approximate number of the characters. However, models usually rely more on the number of tokens in their language model.

Please note that the models add and process all previous messages to the input length. If you do not want this, you must omit the old messages in your request. Or you start simply a new conversation.

@BlyZeDev
Copy link
Author

I'm currently doing it like this. Without specifying conversation or conversation_id a new conversation is created?

var model = _config.GetAIChatModel();
var provider = _config.GetAIChatProvider();
HttpResponseMessage? response = null;
try
{
    var messages = new List<AIChatMessage>
    {
        new AIChatMessage
        {
            Role = "system",
            Content = SystemMessage
        }
    };
    
    await foreach (var message in history)
    {
        messages.Add(message);
    }

    messages.Add(new AIChatMessage
    {
        Role = "user",
        Content = prompt
    });
    
    var postJson = JsonConvert.SerializeObject(new AIChatRequest
    {
        Messages = messages,
        Model = model,
        Provider = provider,
        WebSearch = true,
        Temperature = 0.5f,
        HistoryDisabled = true,
        Stream = false,
        MaxTokens = 400,
        AutoContinue = true,
        Timeout = (int)(_http.Timeout.TotalSeconds * 0.75)
    });

@hlohaus
Copy link
Collaborator

hlohaus commented Jan 27, 2025

Yes, some providers offer an internal conversation instance. Conversation reuse is facilitated by including the conversation_id and provider in API requests; the API subsequently manages the conversation. Alternatively, setting return_conversation=True enables the retrieval of the conversation instance in subsequent requests. @BlyZeDev

@BlyZeDev
Copy link
Author

How do I know which providers offer this.
Can I just use conversation_id instead of passing the whole message context in, for providers that do support it?
return_conversation wouldn't work if I have multiple conversations running at the same time right?

@hlohaus
Copy link
Collaborator

hlohaus commented Jan 27, 2025

Hey, I don't have a list of providers that support return_conversation. But you can check get_paramters:

if "return_conversation" in g4f.Provider.Gemini.get_paramters():
supports = True

Yeah, the RetryProvider doesn't support it yet.

@BlyZeDev

Copy link

github-actions bot commented Feb 4, 2025

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 github-actions bot added the stale label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants