Skip to content

Commit

Permalink
Merge branch 'v1.0' into mnovich/dark-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelneale authored Nov 27, 2024
2 parents be911c7 + c9c3a0d commit 4813b8b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
11 changes: 11 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,14 @@ copy-binary:
echo "Release binary not found."; \
exit 1; \
fi

# Run UI with latest
run-ui:
@just release
@echo "Running UI..."
cd ui/desktop && npm install && npm start

# Run server
run-server:
@echo "Running server..."
cargo run -p goose-server
5 changes: 3 additions & 2 deletions ui/desktop/src/ChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ function ChatContent({
setWorking(Working.Idle);

const promptTemplates = [
"Take a look at this content, if this looks like it could be asking for a confirmation, return QUESTION. If it looks like it is a list of options or plans to choose from, return OPTIONS. It can't just be a list, but clearly must be asking the user to pick one or more of the plan or option alternatives, otherwise return READY. \n ### Message Content:\n" + message.content + "\nYou must provide a response strictly limited to one of the following three words: QUESTION, OPTIONS, READY. No other words, phrases, or explanations are allowed.",
"If the content is clearly a list of distinct options or plans of action to choose from, and not just a list of things, but clearly a list of things to choose one from from, taking into account the Message Content alone, try to format it in a json array, like this JSON array of objects of the form optionTitle:string, optionDescription:string (markdown).\n If is not a list of options or plans to choose from, then return empty list.\n ### Message Content:\n" + message.content,
"You are a simple classifier that takes content and decides if it is asking for input from a person before continuing, or not. If it is a question very clearly, return QUESTION, otherwise READY. ### Message Content:\n" + message.content + "\nYou must provide a response strictly limited to one of the following two words: QUESTION, READY. No other words, phrases, or explanations are allowed. Response:",
"You are a simple classifier that takes content and decides if it a list of options or plans to choose from, or not a list of options to choose from It is IMPORTANT that you really know this is a choice, just not numbered steps. If it is a list of options and you are 95% sure, return OPTIONS, otherwise return NO. ### Message Content:\n" + message.content + "\nYou must provide a response strictly limited to one of the following two words:OPTIONS, NO. No other words, phrases, or explanations are allowed. Response:",
"If the content is list of distinct options or plans of action to choose from, and not just a list of things, but clearly a list of things to choose one from, taking into account the Message Content alone, try to format it in a json array, like this JSON array of objects of the form optionTitle:string, optionDescription:string (markdown).\n If is not a list of options or plans to choose from, then return empty list.\n ### Message Content:\n" + message.content + "\n\nYou must provide a response strictly as json in the format descriribed. No other words, phrases, or explanations are allowed. Response:",
];

const fetchResponses = await askAi(promptTemplates);
Expand Down
4 changes: 2 additions & 2 deletions ui/desktop/src/components/GooseMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default function GooseMessage({ message, metadata, messages, append }: Go
</div>
)}

{/* TODO - Re-enable once detection logic for when to show is correct */}
{false && metadata && (
{/* append false && to turn this off */}
{metadata && (
<div className="flex mb-[16px]">
<GooseResponseForm
message={message.content}
Expand Down
31 changes: 21 additions & 10 deletions ui/desktop/src/components/GooseResponseForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,33 @@ export default function GooseResponseForm({ message, metadata, append }: GooseRe
const [selectedOption, setSelectedOption] = useState(null);
const prevStatusRef = useRef(null);

let isReady = false;
let isQuestion = false;
let isOptions = false;
let options = [];

if (metadata) {
isReady = metadata[0] === "READY";
window.electron.logInfo('metadata:'+ JSON.stringify(metadata, null, 2));
}



if (metadata) {
isQuestion = metadata[0] === "QUESTION";
isOptions = metadata[0] === "OPTIONS";
isOptions = metadata[1] === "OPTIONS";

if (isOptions && metadata[1]) {
if (isQuestion && isOptions && metadata[2]) {
try {
let optionsData = metadata[1];
if (optionsData.startsWith('```json')) {
optionsData = optionsData.replace(/```json/g, '').replace(/```/g, '');
}
let optionsData = metadata[2];
// Use a regular expression to extract the JSON block
const jsonBlockMatch = optionsData.match(/```json([\s\S]*?)```/);

// If a JSON block is found, extract and clean it
if (jsonBlockMatch) {
optionsData = jsonBlockMatch[1].trim(); // Extract the content inside the block
} else {
// Optionally, handle the case where there is no explicit ```json block
console.warn("No JSON block found in the provided string.");
}
options = JSON.parse(optionsData);
options = options.filter(
(opt) =>
Expand Down Expand Up @@ -88,7 +99,7 @@ export default function GooseResponseForm({ message, metadata, append }: GooseRe

return (
<div className="space-y-4">
{isQuestion && (
{isQuestion && !isOptions && (
<div className="flex items-center gap-4 p-4 rounded-lg bg-tool-card dark:bg-tool-card-dark border dark:border-dark-border">
<Button
onClick={handleAccept}
Expand All @@ -108,7 +119,7 @@ export default function GooseResponseForm({ message, metadata, append }: GooseRe
</Button>
</div>
)}
{isOptions && options.length > 0 && (
{isQuestion && isOptions && options.length > 0 && (
<div className="space-y-4">
{options.map((opt, index) => (
<div
Expand Down

0 comments on commit 4813b8b

Please sign in to comment.