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
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ public Response createMessage(@Context HttpServletRequest request, @Context Http

List<Map<String, Object>> messagesList = (List<Map<String, Object>>) messages;

room = RoomUtils.createRoomIfNotExists(roomId, insight, engine, null);
boolean appendFullPrompt = Boolean
.parseBoolean(String.valueOf(dataMap.remove(AbstractModelEngine.APPEND_FULL_PROMPT)));
room = appendFullPrompt ? RoomUtils.createRoomIfNotExists(roomId, insight, engine, null)
: RoomUtils.createRoomForStatelessAsk(roomId, insight, engine, null);

Object tools = dataMap.remove("tools");

Expand All @@ -277,7 +280,7 @@ public Response createMessage(@Context HttpServletRequest request, @Context Http

List<Map<String, Object>> openAIMessages = (List<Map<String, Object>>) openAIFormat.get("messages");
dataMap.put(AbstractModelEngine.FULL_PROMPT, openAIMessages);
dataMap.put("append_full_prompt", true);
dataMap.put(AbstractModelEngine.APPEND_FULL_PROMPT, appendFullPrompt);
classLogger.info("Anthropic-normalized-prompt::{}::messages={} chars={}", JOB_ID, openAIMessages.size(),
GSON.toJson(openAIMessages).length());

Expand All @@ -296,6 +299,7 @@ public Response createMessage(@Context HttpServletRequest request, @Context Http

List<Map<String, Object>> openAIMessages = (List<Map<String, Object>>) openAIFormat.get("messages");
dataMap.put(AbstractModelEngine.FULL_PROMPT, openAIMessages);
dataMap.put(AbstractModelEngine.APPEND_FULL_PROMPT, appendFullPrompt);
Gson gson = new GsonBuilder().setPrettyPrinting().create();
String openAIJson = gson.toJson(openAIMessages);
classLogger.info("Anthropic-normalized-prompt::{}::messages={} chars={}", JOB_ID, openAIMessages.size(),
Expand Down
14 changes: 9 additions & 5 deletions src/prerna/semoss/web/services/local/OpenAIEndpoints.java
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ public Response runModelChatCompletion(@Context HttpServletRequest request) {
if (roomId == null) {
roomId = (String) request.getAttribute("roomId");
}
// room name gets updated during parsing of full prompt
room = RoomUtils.createRoomIfNotExists(roomId, insight, engine, null);
// this is if you are passing full prompt but want us to maintain the history
boolean appendFullPrompt = Boolean
.parseBoolean(WebUtility.inputSanitizer((String) dataMap.remove("append_full_prompt")) + "");
.parseBoolean(String.valueOf(dataMap.remove(AbstractModelEngine.APPEND_FULL_PROMPT)));
// room name gets updated during parsing of full prompt
room = appendFullPrompt ? RoomUtils.createRoomIfNotExists(roomId, insight, engine, null)
: RoomUtils.createRoomForStatelessAsk(roomId, insight, engine, null);

ModelPixelExecutor.initializeThreadStore(insight, SESSION_ID, JOB_ID);

Expand Down Expand Up @@ -569,11 +569,15 @@ public Response runResponses(@Context HttpServletRequest request) {
if (roomId == null) {
roomId = resolveRoomIdFromCodexHeaders(request);
}
room = RoomUtils.createRoomIfNotExists(roomId, insight, engine, null);
boolean appendFullPrompt = Boolean
.parseBoolean(String.valueOf(dataMap.remove(AbstractModelEngine.APPEND_FULL_PROMPT)));
room = appendFullPrompt ? RoomUtils.createRoomIfNotExists(roomId, insight, engine, null)
: RoomUtils.createRoomForStatelessAsk(roomId, insight, engine, null);

ModelPixelExecutor.initializeThreadStore(insight, SESSION_ID, JOB_ID);

dataMap.put(AbstractModelEngine.FULL_PROMPT, messages);
dataMap.put(AbstractModelEngine.APPEND_FULL_PROMPT, appendFullPrompt);

if (!isStreamingRequest) {
try {
Expand Down
Loading