-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fixes 3611: ML API procedures handle null values being passed in better #439
Conversation
6f1ee94
to
549038f
Compare
Map<Boolean, List<String>> collect = texts.stream() | ||
.collect(Collectors.groupingBy(Objects::nonNull)); | ||
|
||
List<String> nonNullTexts = collect.get(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qui non servirebbe vedere se la collezione è nulla di modo da poter lanciare un eccezione prima di fare la richiesta?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sì in effetti è meglio, ho aggiunto il check con l'eccezione sopra.
Questa parte l'ho lasciata cosi perché è richiesto dalla issue:
But we should probably just filter those out in the embeddings call and don't forward them and return the result row with a null value for embedding.
@@ -132,13 +147,19 @@ public Stream<MapResult> completion(@Name("prompt") String prompt, @Name("api_ke | |||
"usage": { "prompt_tokens": 5, "completion_tokens": 7, "total_tokens": 12 } | |||
} | |||
*/ | |||
if (prompt == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qui ugualmente non sarebbe meglio fallire prima di fare la richiesta?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cambiato
LGTM |
Fixes
https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/3611
vertexai and openai embeddings return null rows with null list values
embeddings, chat completion, completion and image procedures return null if the input parameter is null
not implemented null check in apoc.ml..custom procedures, since we can potentially pass a null parameter (e.g. to call this RestAPI)
TODO: open Trello Card for the following note?
Additional notes
Would be great to handle errors like these, but we cannot implement it since is part of APOC Core:
CALL apoc.ml.openai.chat([ {role:"user", content:null}], $apiKey, $conf)
We should do something like this: