Skip to content

Commit

Permalink
Rename NetworkState to State (#18)
Browse files Browse the repository at this point in the history
We'll be extracting State separately, allowing you to create your own
Network loop.
  • Loading branch information
tonyhb authored Dec 6, 2024
1 parent 485afd1 commit 0ffb8f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/network.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { Agent, createTypedTool } from "./agent";
import { type AgenticModel } from "./model";
import { type InferenceResult, NetworkState } from "./state";
import { type InferenceResult, State } from "./state";
import { type MaybePromise } from "./util";

/**
Expand All @@ -21,7 +21,7 @@ export class Network {
/**
* state is the entire agent's state.
*/
state: NetworkState;
state: State;

/**
* defaultModel is the default model to use with the network. This will not
Expand Down Expand Up @@ -50,7 +50,7 @@ export class Network {
constructor({ agents, defaultModel, maxIter }: Network.Constructor) {
this.agents = new Map();
this._agents = new Map();
this.state = new NetworkState();
this.state = new State();
this.defaultModel = defaultModel;
this.maxIter = maxIter || 0;
this._stack = [];
Expand Down
8 changes: 2 additions & 6 deletions src/state.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { type AiAdapter, type OpenAi } from "inngest";
import { type Agent } from "./agent";

export interface InternalNetworkMessage {
Expand All @@ -8,9 +7,6 @@ export interface InternalNetworkMessage {
// TODO: Images and multi-modality.
}

export type OpenAiMessageType =
AiAdapter.Input<OpenAi.AiModel>["messages"][number];

export interface TextMessage {
type: "text";
text: string;
Expand All @@ -29,13 +25,13 @@ export interface ToolResult {
} // TODO: Content types.

/**
* NetworkState stores state (history) for a given network of agents. The state
* State stores state (history) for a given network of agents. The state
* includes key-values, plus a stack of all agentic calls.
*
* From this, the chat history can be reconstructed (and manipulated) for each
* subsequent agentic call.
*/
export class NetworkState {
export class State {
public kv: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
set: <T = any>(key: string, value: T) => void;
Expand Down

0 comments on commit 0ffb8f0

Please sign in to comment.