Skip to content

Commit

Permalink
remove simple memory (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
Liuhaai authored Jan 13, 2025
1 parent c81ea0d commit 280d65c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 27 deletions.
6 changes: 2 additions & 4 deletions example/dummy_agent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DummyLLM } from "../src/llm";
import { Tool } from "../src/tools/tool";
import { Memory, SimpleMemory } from "../src/memory";
import { Workflow } from "../src/workflow";
import { Agent } from "../src/agent";

Expand All @@ -17,9 +16,8 @@ async function runDummyAgent() {
const llm = new DummyLLM();
const echoTool: Tool = new EchoTool(); // Explicitly type echoTool
const tools: Tool[] = [echoTool];
const memory = new SimpleMemory();
const workflow = new Workflow({ llm, tools, memory });
const agent = new Agent({ llm, tools, memory });
const workflow = new Workflow({ llm });
const agent = new Agent({ llm, tools });

const inputs = [
"Hello, Quicksilver!",
Expand Down
6 changes: 2 additions & 4 deletions example/ioid_agent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { OpenAILLM, LLM } from "../src/llm";
import { IoIDTool } from "../src/tools/ioId";
import { Agent } from "../src/agent";
import { SimpleMemory } from "../src/memory";
import { Tool } from "../src/tools/tool";
import * as dotenv from "dotenv";

Expand All @@ -17,11 +16,10 @@ async function runExample() {

const llm: LLM = new OpenAILLM(apiKey, "gpt-4"); // Use "gpt-3.5-turbo" for cost-effectiveness if needed

// Initialize tools, memory, and agent
// Initialize tools, and agent
const ioidTool = new IoIDTool();
const tools: Tool[] = [ioidTool];
const memory = new SimpleMemory();
const agent = new Agent({ llm, tools, memory });
const agent = new Agent({ llm, tools });

// User inputs to process
const inputs = [
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from "./tools/weatherapi";
import { NewsAPITool } from "./tools/newsapi";
import { Agent } from "./agent";
import { SimpleMemory } from "./memory";
import { Tool } from "./tools/tool";
import * as dotenv from "dotenv";

Expand Down
15 changes: 0 additions & 15 deletions src/memory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,3 @@ export interface Memory {
clear(): void;
}

export class SimpleMemory implements Memory {
private memory: { input: string; output: string }[] = [];

loadMemoryVariables(): Record<string, any> {
return { history: this.memory };
}

saveContext(input: string, output: string): void {
this.memory.push({ input, output });
}

clear(): void {
this.memory = [];
}
}
3 changes: 0 additions & 3 deletions src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class Workflow {
console.log({ toolOutput });

// FEED TOOL OUTPUT BACK TO LLM
// Previous Conversation: ${JSON.stringify(this.memory.loadMemoryVariables().history)}
const finalPrompt = this.agent.prompt({
input,
tool: action.tool,
Expand All @@ -67,8 +66,6 @@ export class Workflow {
output = action.output; // LLM handles it directly (no tool used)
}

// this.memory.saveContext(input, output);

return output;
} catch (error) {
console.error("Workflow Error:", error);
Expand Down

0 comments on commit 280d65c

Please sign in to comment.