Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 10 additions & 2 deletions src/prerna/semoss/web/services/local/AnthropicEndpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import prerna.auth.User;
import prerna.auth.utils.SecurityEngineUtils;
import prerna.engine.api.IModelEngine;
import prerna.engine.api.ModelTypeEnum;
import prerna.engine.impl.model.AbstractModelEngine;
import prerna.engine.impl.model.ModelPixelInvoker;
import prerna.engine.impl.model.Room;
Expand Down Expand Up @@ -288,9 +289,16 @@ public Response createMessage(@Context HttpServletRequest request, @Context Http
// can re-attach them to replayed tool_use blocks. Empty map for non-Vertex
// paths (no file written) - no-op then.
Map<String, String> thoughtSigMap = ThoughtSignatureSidecar.load(room.getRoomFolderPath());
boolean interactionReplay = engine.keepInputOutput() && engine.keepsConversationHistory()
// Google Interactions replay is a Vertex-only feature. Only set the flag and
// run the sidecar for Vertex engines; any other engine must not get the
// parameter, or it leaks to that provider's API through the compatibility
// endpoint and the request is rejected.
boolean isVertex = engine.getModelType() == ModelTypeEnum.VERTEX;
boolean interactionReplay = isVertex && engine.keepInputOutput() && engine.keepsConversationHistory()
&& !"false".equalsIgnoreCase(String.valueOf(dataMap.get("use_history")));
dataMap.put("google_interactions_replay_available", interactionReplay);
if (isVertex) {
dataMap.put("google_interactions_replay_available", interactionReplay);
}

// HANDLE NON-STREAMING REQUESTS THROUGH THE LLM PIXEL
if (!isStreamingRequest) {
Expand Down
17 changes: 15 additions & 2 deletions src/prerna/semoss/web/services/local/OpenAIEndpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
import prerna.auth.User;
import prerna.auth.utils.SecurityEngineUtils;
import prerna.engine.api.IModelEngine;
import prerna.engine.api.ModelTypeEnum;
import prerna.engine.impl.model.AbstractModelEngine;
import prerna.engine.impl.model.ModelPixelInvoker;
import prerna.engine.impl.model.Room;
Expand Down Expand Up @@ -447,9 +448,16 @@ private static List<Map<String, Object>> restoreInteractions(IModelEngine engine
message.remove(GoogleInteractionsState.KEY);
messages.add(message);
}
boolean replay = engine.keepInputOutput() && engine.keepsConversationHistory()
// Google Interactions replay is a Vertex-only feature. Only set the flag and
// run the sidecar for Vertex engines; any other engine (OpenAI, Anthropic, ...)
// must not get the parameter, or it leaks to that provider's API through the
// OpenAI-compatibility endpoint and the request is rejected.
boolean isVertex = engine.getModelType() == ModelTypeEnum.VERTEX;
boolean replay = isVertex && engine.keepInputOutput() && engine.keepsConversationHistory()
&& !"false".equalsIgnoreCase(String.valueOf(parameters.get("use_history")));
parameters.put("google_interactions_replay_available", replay);
if (isVertex) {
parameters.put("google_interactions_replay_available", replay);
}
if (replay) {
ThoughtSignatureSidecar.restoreInteractions(room.getRoomFolderPath(), messages);
}
Expand All @@ -471,6 +479,11 @@ private static void preserveInteractions(Room room, Map<String, Object> paramete
@SuppressWarnings("unchecked")
private static void preserveInteractions(Room room, Map<String, Object> parameters,
Map<String, Object> assistant, Object state) throws IOException {
// Non-Vertex engines never carry this flag (restoreInteractions only sets it for
// Vertex), so there is nothing to preserve: skip cleanly rather than error.
if (!parameters.containsKey("google_interactions_replay_available")) {
return;
}
if (!Boolean.TRUE.equals(parameters.get("google_interactions_replay_available"))) {
throw new IOException("Room retention settings prevent preserving Google Interactions history");
}
Expand Down
Loading