An issue related to GPT-4 api

So I was working on a Rust based project which involves using OpenAI gpt-4 api. When I test the function, it panicks/shows an error at a point:

"thread ‘models::agents::agent_backend::tests::tests_backend_developer’ panicked at src\helpers\general.rs:207:14:
Failed twice to call OpenAI: reqwest::Error { kind: Decode, source: Error(“missing field choices”, line: 8, column: 1) }
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
test models::agents::agent_backend::tests::tests_backend_developer … FAILED "

The issue here is that when I use the Gpt-3.5 api, it gets tested successfully. So I know the issue is not with the code, it should be with the API. What can that issue be?

1 Like

Reqwest is expecting something that isn’t there. choices is always present in a successful response

I am betting that your incoming payload is not what you’re expecting and you’re not handling it correctly.

Set a breakpoint or print out the incoming payload before attempting to parse it. Then you’ll need to adjust your code to handle different payload structures.

2 Likes

That did the work! Thanks a lot buddy…

2 Likes