neo4j-contrib / neo4j-apoc-procedures

Awesome Procedures On Cypher for Neo4j - codenamed "apoc"                     If you like it, please ★ above ⇧            
https://neo4j.com/labs/apoc
Apache License 2.0
1.71k stars 493 forks source link

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

Open Anunayth opened 1 month ago

Anunayth commented 1 month ago

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 .

gem-neo4j commented 1 month ago

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.

Anunayth commented 1 month ago

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.

gem-neo4j commented 1 month ago

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

Anunayth commented 1 month ago

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.