Skip to content
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 #4263: Adds docs for apoc triggers helper functions #4311

Merged
merged 5 commits into from
Dec 19, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Revert "Removed org.apache.commons.collections from OpenAI (#4304)" (#…
…4305)

This reverts commit 7e3bfb7.
vga91 authored Dec 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit d453d5ec401b34a0cf66daf1e22a299e67650530
4 changes: 2 additions & 2 deletions extended/src/main/java/apoc/ml/OpenAI.java
Original file line number Diff line number Diff line change
@@ -3,11 +3,11 @@
import apoc.ApocConfig;
import apoc.Extended;
import apoc.result.MapResult;
import apoc.util.ExtendedMapUtils;
import apoc.util.ExtendedUtil;
import apoc.util.JsonUtil;
import apoc.util.Util;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.neo4j.graphdb.security.URLAccessChecker;
import org.neo4j.procedure.Context;
@@ -225,7 +225,7 @@ public Stream<MapResult> completion(@Name("prompt") String prompt, @Name("api_ke
public Stream<MapResult> chatCompletion(@Name("messages") List<Map<String, Object>> messages, @Name("api_key") String apiKey, @Name(value = "configuration", defaultValue = "{}") Map<String, Object> configuration) throws Exception {
boolean failOnError = isFailOnError(configuration);
if (checkNullInput(messages, failOnError)) return Stream.empty();
messages = messages.stream().filter(ExtendedMapUtils::isNotEmpty).toList();
messages = messages.stream().filter(MapUtils::isNotEmpty).toList();
if (checkEmptyInput(messages, failOnError)) return Stream.empty();
configuration.putIfAbsent("model", GPT_4O_MODEL);
return executeRequest(apiKey, configuration, "chat/completions", (String) configuration.get("model"), "messages", messages, "$", apocConfig, urlAccessChecker)
4 changes: 0 additions & 4 deletions extended/src/main/java/apoc/util/ExtendedMapUtils.java
Original file line number Diff line number Diff line change
@@ -11,8 +11,4 @@ public static int size(final Map<?, ?> map) {
public static boolean isEmpty(final Map<?,?> map) {
return map == null || map.isEmpty();
}

public static boolean isNotEmpty(final Map<?,?> map) {
return !isEmpty(map);
}
}