Skip to content

Commit

Permalink
chat in 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
snakajima committed May 9, 2024
1 parent 861e72d commit d79f24c
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions samples/sample_chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { groqAgent, shiftAgent, nestedAgent } from "@/experimental_agents";
import input from "@inquirer/input";

const graph_data = {
version: 0.2,
version: 0.3,
loop: {
while: "continue",
while: ":continue",
},
nodes: {
continue: {
value: true,
update: "checkInput",
update: ":checkInput",
},
messages: {
// This node holds the conversation, array of messages.
value: [],
update: "reducer",
update: ":reducer",
isResult: true,
},
userInput: {
Expand All @@ -25,31 +25,31 @@ const graph_data = {
},
checkInput: {
agent: (query: string) => query !== "/bye",
inputs: ["userInput"],
inputs: [":userInput"],
},
appendedMessages: {
// This node appends the user's input to the array of messages.
agent: (content: string, messages: Array<any>) => [...messages, { role: "user", content }],
inputs: ["userInput", "messages"],
if: "checkInput",
inputs: [":userInput", ":messages"],
if: ":checkInput",
},
groq: {
// This node sends those messages to Llama3 on groq to get the answer.
agent: "groqAgent",
params: {
model: "Llama3-8b-8192",
},
inputs: [undefined, "appendedMessages"],
inputs: [undefined, ":appendedMessages"],
},
output: {
// This node displays the responce to the user.
agent: (answer: string) => console.log(`Llama3: ${answer}\n`),
inputs: ["groq.choices.$0.message.content"],
inputs: [":groq.choices.$0.message.content"],
},
reducer: {
// This node append the responce to the messages.
agent: "pushAgent",
inputs: ["appendedMessages", "groq.choices.$0.message"],
inputs: [":appendedMessages", ":groq.choices.$0.message"],
},
},
};
Expand Down

0 comments on commit d79f24c

Please sign in to comment.