Skip to content

Commit

Permalink
Change Saia URL to consider Embedding and Chat
Browse files Browse the repository at this point in the history
(cherry picked from commit 27aa4bc)
  • Loading branch information
iroqueta committed Nov 14, 2024
1 parent c560d5d commit c53b855
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions java/src/main/java/com/genexus/util/saia/SaiaService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ public static OpenAIResponse call(OpenAIRequest request, CallResult result) {
public static OpenAIResponse call(OpenAIRequest request, boolean isEmbedding, CallResult result) {
try {
String jsonRequest = new ObjectMapper().writeValueAsString(request);
String providerURL = aiProvider + "/chat";;

HttpClient client = new HttpClient();
client.setSecure(1);
client.addHeader("Content-Type", "application/json");
client.addHeader("Authorization", "Bearer " + apiKey);
if (isEmbedding)
if (isEmbedding) {
client.addHeader("X-Saia-Source", "Embedding");
providerURL = providerURL + "/embedding";
}

client.addString(jsonRequest);
client.execute("POST", aiProvider);
client.execute("POST", providerURL);
if (client.getStatusCode() == 200) {
JSONObject jsonResponse = new JSONObject(client.getString());
return new ObjectMapper().readValue(jsonResponse.toString(), OpenAIResponse.class);
Expand Down

0 comments on commit c53b855

Please sign in to comment.