AI does not recognize numbers within a valid range

Hello
I am using the API, and the AI is supposed to ask the user for a value (which must be within a range of 50-5000). My issue arises when I provide values higher than 1000; the AI indicates that the number is invalid and states that it must be within the range. When I insist, it keeps saying it is not within the range. Only when I explicitly state (for example) that 1200 is less than 5000 does it finally accept it. Or if I say 1199, it also accepts it.

What could I do?

I am using the gpt-4o-mini model.

2 Likes

Hi,

I’m unsure why you are checking a number with an llm on API?

Could you not check in code?

Maybe I misunderstood your task?

1 Like

hi, I am using API functions (which also include the maximum and minimum range) to retrieve this data. In the context, I specify that the range is 50-5000, but when the user provides the number 1200 (for example), the assistant recognizes it as a number greater than 5000.

1 Like

That sounds like an issue with the model not understanding the context of your prompt correctly.

Without knowing the context of your call it’s hard to tell what is wrong.

Asking the model to count is not a good method, remember it can hallucinate.

I have given an example in ChatGPT but it should return the same in API

I did have one error but below is how I solved it:

Return 1 or 0:
50>1500
AND
1500<5000

Don’t expect this method to ALWAYS work though…

It seems to me that when the User replies the response will go first through your code before the model where you could check the number logically in code.

If (50<1500 && 1500<5000) Proceed to next AI step supplying number
else Error Fallback

2 Likes