Skip to content

Commit

Permalink
Merge pull request #301 from receptron/sample_cleanup
Browse files Browse the repository at this point in the history
Sample cleanup (version 0.3 migration)
  • Loading branch information
snakajima authored May 10, 2024
2 parents 2592e05 + 4ce4393 commit 0833ea9
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 31 deletions.
5 changes: 3 additions & 2 deletions samples/graphs/arxiv.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 0.3
nodes:
searchArxiv:
params:
Expand All @@ -7,10 +8,10 @@ nodes:
limit: 10
agent: arxivAgent
arxiv2TextAgent:
inputs: [searchArxiv]
inputs: [:searchArxiv]
agent: arxiv2TextAgent
slashGPTAgent:
inputs: [arxiv2TextAgent.content]
inputs: [:arxiv2TextAgent.content]
agent: slashGPTAgent
params:
query: |
Expand Down
7 changes: 4 additions & 3 deletions samples/graphs/slash_gpt.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
verbose: true
version: 0.3
nodes:
node1:
agent: slashgpt
params:
query: Come up with ten business ideas for AI startup
node2:
agent: stringTemplate
inputs: [node1.$last.content]
inputs: [:node1.$last.content]
params:
template: |
Please evaluate following business ideas.
Expand All @@ -16,7 +17,7 @@ nodes:
inputs: [node2]
node4:
agent: stringTemplate
inputs: [node1.$last.content, node3.$last.content]
inputs: [:node1.$last.content, :node3.$last.content]
params:
template: |
Please pick the winner of this business idea contest.
Expand All @@ -26,4 +27,4 @@ nodes:
${1}
node5:
agent: slashgpt
inputs: [node4]
inputs: [:node4]
5 changes: 3 additions & 2 deletions samples/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ const home_actions = {
};

const graph_data: GraphData = {
version: 0.3,
nodes: {
node1: {
value: { content: "Turn on the light in the kitchen" },
},
node2: {
agent: "slashGPTAgent",
inputs: ["node1.content"],
inputs: [":node1.content"],
params: {
manifest: {
skip_function_result: true,
Expand All @@ -32,7 +33,7 @@ const graph_data: GraphData = {
},
node3: {
agent: "bypassAgent",
inputs: ["node2.$last.content"],
inputs: [":node2.$last.content"],
isResult: true,
params: {
firstElement: true,
Expand Down
5 changes: 3 additions & 2 deletions samples/sample_fibonacci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ const fibonacciAgent: AgentFunction = async ({ inputs }) => {
};

const graph_data = {
version: 0.3,
loop: {
count: 1000,
},
nodes: {
data: {
value: [1, 1],
update: "fibonacci",
update: ":fibonacci",
},
fibonacci: {
agent: "fibonacciAgent",
inputs: ["data"],
inputs: [":data"],
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions samples/sample_groq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const query =
"I'd like to write a paper about data flow programming for AI application, which involves multiple asynchronous calls, some of operations are done on other machines (distributed computing). Please come up with the title and an abstract for this paper.";

const graph_data = {
version: 0.2,
version: 0.3,
nodes: {
query: {
agent: "groqAgent",
Expand All @@ -18,7 +18,7 @@ const graph_data = {
},
answer: {
agent: "sleeperAgent",
inputs: ["query.choices.$0.message"],
inputs: [":query.choices.$0.message"],
},
},
};
Expand Down
3 changes: 2 additions & 1 deletion samples/sample_interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { graphDataTestRunner } from "~/utils/runner";
import { interactiveInputSelectAgent } from "./agents/interactiveInputAgent";

const graph_data = {
version: 0.3,
nodes: {
countingAgent: {
agent: "countingAgent",
Expand All @@ -13,7 +14,7 @@ const graph_data = {
},
},
interactiveInputAgent: {
inputs: ["countingAgent.list"],
inputs: [":countingAgent.list"],
agent: "interactiveInputSelectAgent",
isResult: true,
},
Expand Down
21 changes: 11 additions & 10 deletions samples/sample_loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ import { graphDataTestRunner } from "~/utils/runner";
import { pushAgent, shiftAgent, slashGPTAgent, totalAgent } from "@/experimental_agents";

const graph_data = {
version: 0.3,
loop: {
while: "people",
while: ":people",
},
nodes: {
people: {
value: ["Steve Jobs", "Elon Musk", "Nikola Tesla"],
update: "retriever.array",
update: ":retriever.array",
},
result: {
value: [],
update: "reducer2",
update: ":reducer2",
},
usage: {
value: {},
update: "acountant",
update: ":acountant",
},
retriever: {
agent: "shiftAgent",
inputs: ["people"],
inputs: [":people"],
},
query: {
agent: "slashGPTAgent",
Expand All @@ -30,23 +31,23 @@ const graph_data = {
prompt: "Describe about the person in less than 100 words",
},
},
inputs: ["retriever.item"],
inputs: [":retriever.item"],
},
reducer1: {
agent: "popAgent",
inputs: ["query"],
inputs: [":query"],
},
reducer2: {
agent: "pushAgent",
inputs: ["result", "reducer1.item"],
inputs: [":result", ":reducer1.item"],
},
usageData: {
agent: "totalAgent",
inputs: ["reducer2.$0"],
inputs: [":reducer2.$0"],
},
acountant: {
agent: "totalAgent",
inputs: ["usage", "usageData.usage"],
inputs: [":usage", ":usageData.usage"],
},
},
};
Expand Down
17 changes: 8 additions & 9 deletions samples/sample_rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { graphDataTestRunner } from "~/utils/runner";
import { fetchAgent, propertyFilterAgent, groqAgent, stringTemplateAgent, copyAgent } from "@/experimental_agents";

const graph_data = {
version: 0.2,
version: 0.3,
nodes: {
url: {
value: "https://www.theverge.com/apple/rss/index.xml",
Expand All @@ -14,44 +14,43 @@ const graph_data = {
params: {
type: "xml",
},
inputs: ["url"],
inputs: [":url"],
},
filter: {
agent: "propertyFilterAgent",
params: {
include: ["title", "link", "content"],
},
inputs: ["rssFeed.feed.entry"],
inputs: [":rssFeed.feed.entry"],
},
map: {
agent: "mapAgent",
inputs: ["filter"],
inputs: [":filter"],
isResult: true,
params: {
limit: 4, // to avoid rate limit
},
graph: {
version: 0.2,
nodes: {
template: {
agent: "stringTemplateAgent",
params: {
template: "Title:${0}\n${1}",
},
inputs: ["$0.title", "$0.content._"],
inputs: [":$0.title", ":$0.content._"],
},
query: {
agent: "groqAgent",
params: {
model: "Llama3-8b-8192", // "mixtral-8x7b-32768",
query: "次のHTMLからテキストだけを抜き出し、省略せずに、全文を日本語に翻訳して。余計なことは言わずに、翻訳した文章だけ答えて。",
},
inputs: ["template"],
inputs: [":template"],
},
extractor: {
agent: "copyAgent",
isResult: true,
inputs: ["query.choices.$0.message.content"],
inputs: [":query.choices.$0.message.content"],
},
},
},
Expand All @@ -67,7 +66,7 @@ const main = async () => {
stringTemplateAgent,
copyAgent,
})) as any;
console.log(result.map.extractor);
console.log(result.map.extractor.join("\n\n"));
};
if (process.argv[1] === __filename) {
main();
Expand Down

0 comments on commit 0833ea9

Please sign in to comment.