Skip to content

Commit

Permalink
feat: add a context in cot action in order to have clean output in me…
Browse files Browse the repository at this point in the history
…mory
  • Loading branch information
Matth26 committed Jan 28, 2025
1 parent 0bc8420 commit 7c4523e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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

0 comments on commit 7c4523e

Please sign in to comment.