-
Notifications
You must be signed in to change notification settings - Fork 495
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
$path configuration parameter adds terminating slash #4169
Labels
Comments
The error is in OpenAIRequestHandler: public String getFullUrl(String method, Map<String, Object> procConfig, ApocConfig apocConfig) {
return Stream.of(getEndpoint(procConfig, apocConfig), method, getApiVersion(procConfig, apocConfig))
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining("/"));
} It will always terminate with an "/", which is wrong. |
This is how a quick fix could look like: diff --git a/extended/src/main/java/apoc/ml/OpenAIRequestHandler.java b/extended/src/main/java/apoc/ml/OpenAIRequestHandler.java
index cca7bcd54..13c1b767e 100644
--- a/extended/src/main/java/apoc/ml/OpenAIRequestHandler.java
+++ b/extended/src/main/java/apoc/ml/OpenAIRequestHandler.java
@@ -31,6 +31,7 @@ abstract class OpenAIRequestHandler {
public String getEndpoint(Map<String, Object> procConfig, ApocConfig apocConfig) {
String url = (String) procConfig.getOrDefault(ENDPOINT_CONF_KEY,
apocConfig.getString(APOC_ML_OPENAI_URL, System.getProperty(APOC_ML_OPENAI_URL)));
+
if (url == null) {
return getDefaultUrl();
}
@@ -40,7 +41,8 @@ abstract class OpenAIRequestHandler {
public String getFullUrl(String method, Map<String, Object> procConfig, ApocConfig apocConfig) {
return Stream.of(getEndpoint(procConfig, apocConfig), method, getApiVersion(procConfig, apocConfig))
.filter(StringUtils::isNotBlank)
- .collect(Collectors.joining("/"));
+ .collect(Collectors.joining("/"))
+ .replaceAll("/\\?", "?"); // fix broken endpoint |
vga91
added a commit
that referenced
this issue
Sep 18, 2024
vga91
added a commit
that referenced
this issue
Sep 18, 2024
vga91
added a commit
that referenced
this issue
Oct 4, 2024
RobertoSannino
pushed a commit
that referenced
this issue
Oct 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected Behavior (Mandatory)
When I add a 'path' parameter (e.g. "text-embedding-ada-002/embeddings") I expect this actual path to be called without an additional "/" at the end.
Actual Behavior (Mandatory)
'apoc.ml.openai.embedding' adds an additional slash ('/') to the parameter, so the endpoint "text-embedding-ada-002/embeddings/?api-version=2023-12-01-preview" is called instead which causes the call to fail
Steps (Mandatory)
Screenshots (where it's possibile)
Specifications (Mandatory)
https://neo4j.com/labs/apoc/5/ml/openai/
Currently used versions
5.20.0
Versions
The text was updated successfully, but these errors were encountered: