Skip to content

Commit

Permalink
Merge pull request #304 from isamu/cleanSample
Browse files Browse the repository at this point in the history
Clean sample
  • Loading branch information
snakajima authored May 10, 2024
2 parents 80837ce + 2e9d888 commit 3c8c04f
Show file tree
Hide file tree
Showing 18 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: yarn install
- run: npx ts-node -r tsconfig-paths/register samples/express.ts &
- run: npx ts-node -r tsconfig-paths/register samples/express/server.ts &
- run: cd tests/http-server/docs/ && npx http-server &
- run: yarn test
- run: yarn http_test
Expand Down
1 change: 1 addition & 0 deletions samples/agents/slashgpt_agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const slashGPTFuncitons2TextAgent: AgentFunction<{ function_data_key: str
params,
inputs,
}) => {
console.log(inputs);
const message = inputs[0].find((m) => m.role === "function_result");
if (!message) {
return;
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions samples/express.ts → samples/express/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// npx ts-node samples/express.ts
// sample client: samples/curl.sh

import { hello } from "./express/hello";
import { graphAISample } from "./express/graph_sample";
import { agentDispatcher } from "./express/agent_dispatcher";
import { hello } from "./hello";
import { graphAISample } from "./graph_sample";
import { agentDispatcher } from "./agent_dispatcher";

import express from "express";
import cors from "cors";
Expand Down
2 changes: 1 addition & 1 deletion samples/graphs/slash_gpt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nodes:
${0}
node3:
agent: slashgpt
inputs: [node2]
inputs: [:node2]
node4:
agent: stringTemplate
inputs: [:node1.$last.content, :node3.$last.content]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "dotenv/config";

import { countingAgent } from "@/experimental_agents";
import { graphDataTestRunner } from "~/utils/runner";
import { interactiveInputSelectAgent } from "./agents/interactiveInputAgent";
import { interactiveInputSelectAgent } from "../agents/interactiveInputAgent";

const graph_data = {
version: 0.3,
Expand All @@ -21,7 +21,7 @@ const graph_data = {
},
};

const main = async () => {
export const main = async () => {
const result = await graphDataTestRunner(__filename, graph_data, { countingAgent, interactiveInputSelectAgent });
console.log(JSON.stringify(result, null, " "));
console.log("COMPLETE 1");
Expand Down
6 changes: 3 additions & 3 deletions samples/interaction.ts → samples/interaction/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import "dotenv/config";

import { mergeNodeIdAgent } from "@/experimental_agents";
import { graphDataTestRunner } from "~/utils/runner";
import { interactiveInputTextAgent } from "./agents/interactiveInputAgent";
import { interactiveInputTextAgent } from "../agents/interactiveInputAgent";

const graph_data = {
version: 0.3,
Expand All @@ -15,7 +15,7 @@ const graph_data = {
update: ":node3",
},
node2: {
agent: "input",
agent: "interactiveInputTextAgent",
},
node3: {
inputs: [":node1", ":node2"],
Expand All @@ -27,7 +27,7 @@ const graph_data = {
export const main = async () => {
graph_data.nodes.node1.value = { injected: "test" };

const result = await graphDataTestRunner(__filename, graph_data, { merge: mergeNodeIdAgent, input: interactiveInputTextAgent });
const result = await graphDataTestRunner(__filename, graph_data, { merge: mergeNodeIdAgent, interactiveInputTextAgent });
console.log(result);

console.log("COMPLETE 1");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "dotenv/config";

import { graphDataTestRunner } from "~/utils/runner";
import { interactiveInputTextAgent } from "./agents/interactiveInputAgent";
import { interactiveInputTextAgent } from "../agents/interactiveInputAgent";
import { wikipediaAgent } from "@/experimental_agents";

const graph_data = {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion samples/sample_gpt.ts → samples/llm/slashgpt.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "dotenv/config";

import { fileTestRunner } from "./runner";
import { fileTestRunner } from "../runner";

import { stringTemplateAgent, slashGPTAgent } from "@/experimental_agents";

Expand Down
4 changes: 2 additions & 2 deletions samples/sample_paper_ai.ts → samples/net/paper_ai.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import "dotenv/config";

import { fileTestRunner } from "./runner";
import { fileTestRunner } from "../runner";

import { slashGPTAgent } from "@/experimental_agents";
import { arxivAgent, arxiv2TextAgent } from "./agents/arxiv_agent";
import { arxivAgent, arxiv2TextAgent } from "../agents/arxiv_agent";

export const main = async () => {
const res = await fileTestRunner("/graphs/arxiv.yml", { arxivAgent: arxivAgent, arxiv2TextAgent, slashGPTAgent });
Expand Down
File renamed without changes.
12 changes: 7 additions & 5 deletions samples/sample_runner.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import "dotenv/config";

import { main as gpt } from "./sample_gpt";
import { main as interaction } from "./interaction";
import { main as sample_co2 } from "./sample_co2";
import { main as slashgpt } from "./llm/slashgpt";
import { main as interaction_text } from "./interaction/text";
import { main as interaction_select } from "./interaction/select";
import { main as sample_co2 } from "./tools/sample_co2";
import { main as sample_paper_ai } from "./sample_paper_ai";
import { main as home } from "./home";

const main = async () => {
await gpt();
await interaction();
await slashgpt();
await interaction_text();
await interaction_select();
await sample_co2();
await sample_paper_ai();
await home();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions samples/sample_co2.ts → samples/tools/sample_co2.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "dotenv/config";

import { slashGPTFuncitons2TextAgent } from "./agents/slashgpt_agent";
import { slashGPTFuncitons2TextAgent } from "../agents/slashgpt_agent";
import { slashGPTAgent } from "@/experimental_agents";

import { graphDataTestRunner } from "~/utils/runner";
Expand Down Expand Up @@ -58,12 +58,12 @@ const graph_data = {
function_data_key: "methods",
result_key: 0,
},
inputs: ["slashGPTAgent"],
inputs: [":slashGPTAgent"],
agent: "slashGPTFuncitons2TextAgent",
},
mapNode: {
agent: "mapAgent",
inputs: ["function2prompt0"],
inputs: [":function2prompt0"],
params: {
injectionTo: ["memory"],
},
Expand All @@ -80,7 +80,7 @@ const graph_data = {
},
},
isResult: true,
inputs: ["memory"],
inputs: [":memory"],
},
},
},
Expand Down

0 comments on commit 3c8c04f

Please sign in to comment.