Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement live task status update in task window #329

Merged
merged 13 commits into from
Apr 26, 2023

Conversation

Jshen123
Copy link
Contributor

@Jshen123 Jshen123 commented Apr 24, 2023

Description
image

Other changes

  1. Added Zustand to manage component's message states
  2. Refactor Message types in agentTypes

@vercel
Copy link

vercel bot commented Apr 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
agent-gpt ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 26, 2023 5:42pm


const TIMEOUT_LONG = 1000;
const TIMOUT_SHORT = 800;

class AutonomousAgent {
name: string;
goal: string;
tasks: string[] = [];
tasks: Message[] = [];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asim-shrestha update tasks, i's now a list of Message[] instead of a list of strings

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine but why not use a different type?

{
  title: string;
  state: "starting" |  "executing" | "complete";
}

Copy link
Contributor Author

@Jshen123 Jshen123 Apr 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

status type? Mostly incase other types of messages might have their own status

const result = await this.executeTask(currentTask.value);

currentTask.status = TASK_STATUS_EXECUTING;
currentTask.info = result;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asim-shrestha, .info will now contain execution details. .value will always track task value regardless of message types

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@awtkns, because .info and .value are now swapped for executing tasks. Execution messages from saved agents may look a bit funny

@asim-shrestha
Copy link
Contributor

Nice stuff.

Seems to not show up as completed in the preview build. Image below, two tasks are executing.

image

@Jshen123 Jshen123 self-assigned this Apr 24, 2023

const TIMEOUT_LONG = 1000;
const TIMOUT_SHORT = 800;

class AutonomousAgent {
name: string;
goal: string;
tasks: string[] = [];
tasks: Message[] = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine but why not use a different type?

{
  title: string;
  state: "starting" |  "executing" | "complete";
}

this.sendExecutionMessage(currentTask as string, result);
const result = await this.executeTask(currentTask.value);

currentTask.status = TASK_STATUS_EXECUTING;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be before the previous line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha! this will be fixed as part of the status/ui revamp.

case TASK_STATUS_EXECUTING:
return "border-white/20 text-white";
case TASK_STATUS_COMPLETED:
return "border-green-500 hover:border-green-400 hover:text-green-400 text-green-500";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seemed like the hover wasn't working correctly

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe in a different PR we should refactor the message into its own file. This probably doesn't belong in helpers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I think some sort of refactoring is warranted. Right now TaskWindowMessage and ChatWindowMessage are 2 distinct components sharing some similarities.

But agreed, helper is probably not the most ideal structure

Comment on lines 1 to 17
import type { StoreApi, UseBoundStore } from "zustand";

type WithSelectors<S> = S extends { getState: () => infer T }
? S & { use: { [K in keyof T]: () => T[K] } }
: never;

export const createSelectors = <S extends UseBoundStore<StoreApi<object>>>(
_store: S
) => {
const store = _store as WithSelectors<typeof _store>;
store.use = {};
for (const k of Object.keys(store.getState())) {
(store.use as any)[k] = () => store((s) => s[k as keyof typeof s]);
}

return store;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we comment what these are used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will add comment

@awtkns
Copy link
Member

awtkns commented Apr 25, 2023

@Jshen123 looking good to me, one minor thing, love the green outline but would it be possible to have the text remain white? IMHO the green text can make it quite hard to read.

image

@Jshen123
Copy link
Contributor Author

Jshen123 commented Apr 25, 2023

@Jshen123 looking good to me, one minor thing, love the green outline but would it be possible to have the text remain white? IMHO the green text can make it quite hard to read.

image

@awtkns done ✅

image

@Jshen123
Copy link
Contributor Author

Jshen123 commented Apr 25, 2023

@awtkns @asim-shrestha thoughts on lighter shade of green?

I prefer this over white text

image

@awtkns
Copy link
Member

awtkns commented Apr 25, 2023

@awtkns @asim-shrestha thoughts on lighter shade of green?
I prefer this over white text

@Jshen123 what if we made the task green and the output white? Just concerned for people that are colourblind too

@asim-shrestha
Copy link
Contributor

Agree with Adam here, liking the white more

Comment on lines +96 to +98
if (getTaskStatus(message) === TASK_STATUS_EXECUTING) {
return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats this for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants