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: add context to CoT actions for cleaner memory output #61

Merged
Merged
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
10 changes: 7 additions & 3 deletions packages/core/src/core/chain-of-thought.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ export class ChainOfThought extends EventEmitter {
* ```ts
* const result = await chain.executeAction({
* type: "sendMessage",
* context: "Sending a message to user"
* payload: {
* message: "Hello world"
* }
Expand Down Expand Up @@ -1190,16 +1191,18 @@ ${this.context.worldState}
4. If the required amounts are not available, end the sequence.
{{additional_validations}}


## Output Format
Return a JSON array where each step contains:
- plan: A short explanation of what you will do
- meta: A metadata object with requirements for the step. Find this in the context.
- actions: A list of actions to be executed. You can either use ${this.getAvailableOutputs()}

<AVAILABLE_ACTIONS>
Below is a list of actions you may use. For each action,
the "payload" must follow the indicated structure exactly. Do not include any markdown formatting, slashes or comments.
Below is a list of actions you may use.
The "payload" must follow the indicated structure exactly. Do not include any markdown formatting, slashes or comments.
Each action must include:
- **payload**: The action data structured as per the available actions.
- **context**: A contextual description or metadata related to the action's execution. This can include statuses, results, or any pertinent information that may influence future actions.

${availableOutputs
.map(
Expand Down Expand Up @@ -1257,6 +1260,7 @@ ${availableOutputs
actions: z.array(
z.object({
type: z.string(),
context: z.string(),
payload: z.any(),
})
),
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/core/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface ChainOfThoughtContext {
*/
export interface CoTAction {
type: string;
context: string;
payload: Record<string, any>;
}

Expand Down