Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkpiano committed Jun 1, 2024
1 parent c72b9e6 commit 2e0cdcb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
44 changes: 22 additions & 22 deletions src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
AgentContext,
AgentDecideOptions,
AgentDecisionLogic,
AgentDecisionInput as AgentDecisionOptions,
AgentDecisionOptions,
AgentGenerateTextOptions,
AgentLogic,
AgentMessageHistory,
Expand Down Expand Up @@ -54,24 +54,6 @@ export function createAgent<
} & GenerateTextOptions): Agent<TEvents> {
const messageListeners: Observer<AgentMessageHistory>[] = [];

const observe: Agent<TEvents>['addObservation'] = ({
state,
event,
nextState,
timestamp,
sessionId,
// eventOrigin,
}) => {
agent.send({
type: 'agent.observe',
state,
event,
nextState,
timestamp,
sessionId,
});
};

const agentLogic: AgentLogic<TEvents> = fromTransition(
(state, event) => {
switch (event.type) {
Expand Down Expand Up @@ -125,9 +107,11 @@ export function createAgent<
messageListeners.push(toObserver(callback));
};

agent.decide = (opts) => agentDecide(agent, opts);
agent.decide = (opts) => {
return agentDecide(agent, opts);
};

agent.addHistory = async (history) => {
agent.addHistory = (history) => {
agent.send({
type: 'agent.history',
history,
Expand All @@ -136,7 +120,23 @@ export function createAgent<

agent.generateText = (opts) => agentGenerateText(agent, opts);

agent.addObservation = observe;
agent.addObservation = ({
state,
event,
nextState,
timestamp,
sessionId,
}) => {
agent.send({
type: 'agent.observe',
state,
event,
nextState,
timestamp,
sessionId,
});
};

agent.addPlan = (plan) => {
agent.send({
type: 'agent.plan',
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ export interface AgentContext<TEvents extends EventObject> {
feedback: AgentFeedback[];
}

export type AgentDecisionInput = {
export type AgentDecisionOptions = {
goal: string;
model?: LanguageModel;
context?: any;
} & Omit<Parameters<typeof generateText>[0], 'model' | 'tools' | 'prompt'>;

export type AgentDecisionLogic<TEvents extends EventObject> = PromiseActorLogic<
AgentPlan<TEvents> | undefined,
AgentDecisionInput | string
AgentDecisionOptions | string
>;

export type AgentLogic<TEvents extends EventObject> = TransitionActorLogic<
Expand Down

0 comments on commit 2e0cdcb

Please sign in to comment.