neo4j-apoc-procedures icon indicating copy to clipboard operation
neo4j-apoc-procedures copied to clipboard

apoc.ml.openai.completion adding extra / after completions

Open Anunayth opened this issue 1 year ago • 4 comments

Hello,

I am trying to call apoc.ml.openai.completion and i am getting error

procedure call : call apoc.ml.openai.completion("can neo4j handle openAI. one word answer only", $apiKey,{endpoint:'https://my-resource-url/openai/deployments/deployment-id',temperature:0,max_tokes:-1})

error : Failed to invoke procedure apoc.ml.openai.completion: Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://my-resource-url/openai/deployments/deployment-id/completions/?api-version=2024-02-01

why is an extra slash getting added after completions /deployment-id/completions/?api-version=2024-02-01 . what should i do to remove it .

Anunayth avatar Oct 04 '24 11:10 Anunayth

Hey! A slash before query parameters is not invalid syntax for a url, it is added by frameworks and browsers, so I don't think that is the issue here :)

Also, just to double check, is that the actual URL you're using? Because I believe that is just an example, try leaving out the endpoint, if you're using and openAI key then it will default to the normal openAI endpoint.

gem-neo4j avatar Oct 07 '24 07:10 gem-neo4j

The URL is a dummy URL which i have put to hide the actual URL over internet. I have to use endpoint which is provided by my organization and cannot connect to the default endpoint provided by the neo4j.

Using the same URL which my organization has provided, other people are able to connect and use OpenAI through other tools or code. But i am unable to connect using neo4j and getting this error.

Anunayth avatar Oct 07 '24 08:10 Anunayth

Okay, great, and just to rule out any other potential client issues, are you aware you misspelled max_tokens?

gem-neo4j avatar Oct 07 '24 08:10 gem-neo4j

Thanks for pointing that out.. I had missed out on the max_tokens . I haved fixed that one and still getting the exact same error. Also as per my understanding, since max_tokens was not mentioned in the config (as it was misspelt), neo4j should have taken a default value for it instead of throwing the error. And the error is on the URL as per the message.

Anunayth avatar Oct 07 '24 08:10 Anunayth

@Anunayth The slash issue should be solved in this PR, and the fix has been present since 5.24.0 version.

I'm closing the issue, please feel free to reopen in case you still have problems

vga91 avatar Nov 19 '24 11:11 vga91