Include chat messages in solution instead of last user prompt

This commit is contained in:
Brian Hackett
2025-02-11 06:07:57 -08:00
parent bb82c56958
commit ce94bf7fcf
4 changed files with 16 additions and 16 deletions

View File

@@ -74,12 +74,6 @@ setInterval(async () => {
}
}, 1000);
let gLastUserPrompt: string | undefined = "app goes blank getting directions";
export function getLastUserPrompt(): string | undefined {
return gLastUserPrompt;
}
export function Chat() {
renderLogger.trace('Chat');
@@ -351,8 +345,6 @@ export const ChatImpl = memo(
return;
}
gLastUserPrompt = _input;
const anthropicApiKey = Cookies.get(anthropicApiKeyCookieName);
if (!anthropicApiKey) {
const numFreeUses = +(Cookies.get(anthropicNumFreeUsesCookieName) || 0);

View File

@@ -2,11 +2,10 @@ import { toast } from "react-toastify";
import ReactModal from 'react-modal';
import { useState } from "react";
import { workbenchStore } from "~/lib/stores/workbench";
import { BoltProblemStatus, getProblemsUsername, updateProblem } from "~/lib/replay/Problems";
import { BoltProblemStatus, updateProblem } from "~/lib/replay/Problems";
import type { BoltProblemInput } from "~/lib/replay/Problems";
import { getLastLoadedProblem } from "../chat/LoadProblemButton";
import { getLastUserSimulationData } from "~/lib/replay/SimulationPrompt";
import { getLastUserPrompt } from "../chat/Chat.client";
import { getLastUserSimulationData, getLastChatMessages } from "~/lib/replay/SimulationPrompt";
ReactModal.setAppElement('#root');
@@ -52,8 +51,8 @@ export function SaveSolution() {
return;
}
const userPrompt = getLastUserPrompt();
if (!userPrompt) {
const messages = getLastChatMessages();
if (!messages) {
toast.error('No user prompt found');
return;
}
@@ -71,7 +70,7 @@ export function SaveSolution() {
status: BoltProblemStatus.Solved,
solution: {
simulationData,
userPrompt,
messages,
evaluator: formData.evaluator,
},
};

View File

@@ -2,6 +2,7 @@
import { toast } from "react-toastify";
import { sendCommandDedicatedClient } from "./ReplayProtocolClient";
import type { ProtocolMessage } from "./SimulationPrompt";
import Cookies from 'js-cookie';
export interface BoltProblemComment {
@@ -12,7 +13,7 @@ export interface BoltProblemComment {
export interface BoltProblemSolution {
simulationData: any;
userPrompt: string;
messages: ProtocolMessage[];
evaluator: string;
}

View File

@@ -15,7 +15,7 @@ function createRepositoryContentsPacket(contents: string): SimulationPacket {
};
}
type ProtocolMessage = {
export type ProtocolMessage = {
role: "user" | "assistant" | "system";
type: "text";
content: string;
@@ -200,6 +200,12 @@ export async function getSimulationRecording(): Promise<string> {
return gChatManager.recordingIdPromise;
}
let gLastChatMessages: ProtocolMessage[] | undefined;
export function getLastChatMessages(): ProtocolMessage[] | undefined {
return gLastChatMessages;
}
const SystemPrompt = `
The following user message describes a bug or other problem on the page which needs to be fixed.
You must respond with a useful explanation that will help the user understand the source of the problem.
@@ -232,6 +238,8 @@ export async function getSimulationEnhancedPrompt(
},
];
gLastChatMessages = messages;
console.log("ChatSendMessage", messages);
return gChatManager.sendChatMessage(messages);