Skip to content

Commit

Permalink
Fix from the call
Browse files Browse the repository at this point in the history
  • Loading branch information
InAnYan committed Nov 15, 2024
1 parent f941f01 commit 4e3e901
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 46 deletions.
42 changes: 36 additions & 6 deletions module/move/assistant/design/agents_design.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,45 @@ Main description of such system is writen using **YAML**.

The system consists of **nodes** and **edges**.

Currently, we assume that the only information type passed between nodes is **single text** and nodes are connected as a direct acyclic graph (DAC). Node can take input from several nodes, but it can generate only 1 output.
Currently, we assume that the only information type passed between nodes is **single text** and nodes are connected as a direct acyclic graph (DAC). Node can take input from other nodes, but it can generate only 1 output.

In future, we can support other types like *list of strings*. *booleans*; we can deliver input to several nodes *in parallel*, etc.

## Nodes
## YAML description structure

Please refer to `examples/` directory.

## Paths

In several places in YAML file there are values of **paths**. Paths resemble paths in a real file system, parts are delimited with `::`. Absolute path starts from `::`.\

Examples of paths:

- `output`: relative path to single element `output`.
- `event::stdout`: relative path to `stdout` through `event`.
- `::trigger::stdin`: absolute path to `stdin` through `trigger`.

Places where paths are used:

- In nodes - `type`: type of the node. Different types of nodes live in different dirs.
- In nodes - `next`: to which node pass the execution. Nodes live in `::nodes` dir.
- In nodes - `agent_reuse`: reuse conversation history of previous agent.
- In templates - `{{...}}`: take output from the node. Output of nodes live in `::output` dir.

All paths (expect absolute) **are subject to absolutization**. This means that every relative path will be implicitly turned out to absolute path. In case of any ambiguities an error will be thrown. Absolutization also depends on the context: in `next` fields paths are absolutized to `::nodes` dir, in templates - to `::output` and so on.

## Execution

YAML file contains section about `nodes:`. You can think of them as statements in a programming language. Next statement is encoded in `next:` field. Output of the nodes are stored in `::output` dir.

## Scenarios referencing

There are two builtin scenarios:

- `::scenario::entry`
- `::scenario::termination`

## Detailed description of nodes

Each node has an `id` property (its name) and a `type` property.

Expand Down Expand Up @@ -109,7 +143,3 @@ Current **types**:
**Description**: when the process of execution is passed to this node, the whole program of the multi-agent system terminates.

This node is **implicitly present in every graph**, and to call it you just need to fill `next:` with the `scenario.terminate`.

## YAML description structure

Please refer to `examples/` directory.
21 changes: 10 additions & 11 deletions module/move/assistant/design/agents_examples/language_learner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,32 @@ description: >
nodes:
- id: question_input
type: trigger.stdin
type: trigger::stdin
prompt: 'Your question: '
next: answer

- id: answer
type: agent.completion
type: agent::completion
system_message: 'You are a helpful Q&A assistant. Answer in English'
user_message: 'Question: {{question_input}}'
next:
- translator
- frases_extractor
- output # TODO: What will happen if output would be called first (or in paralel to other "next"s) but there is no output of `translator` or `frases_extractor`?
next: translator

- id: translator
type: agent.completion
type: agent::completion
system_message: 'Translate the input in Ukrainian language'
user_message: '{{answer}}'
next: frases_extractor

- id: frases_extractor
type: agent.completion
type: agent::completion
system_message: >
You have a text in English. Extract unique and interesting frases or words from the text
that would be useful for English language learner. Present the output as a list of pairs:
the first element is English phrase and the second is Ukrainian translation.
user_message: '{{answer}}'
user_message: '{{translator}}'
next: output

- id: output
type: event.stdout
output: 'Answer: {{answer}}'
type: event::stdout
output: 'Answer: {{answer}}. In Ukrainian: {{translator}}. Words: {{frases_extractor}}'
next: scenario.termination
8 changes: 4 additions & 4 deletions module/move/assistant/design/agents_examples/qa_1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ description: >
nodes:
- id: question_input
type: trigger.stdin
type: trigger::stdin
prompt: 'Your question: '
next: cleaner

- id: cleaner
type: agent.completion
type: agent::completion
system_message: 'Correct the orthography and other English mistakes. Make the input clean and easy to understand.'
user_message: '{{question_input}}'
next: answer

- id: answer
type: agent.completion
type: agent::completion
system_message: 'You are a helpful Q&A assistant.'
user_message: 'Question: {{cleaner}}'
next: output

- id: output
type: event.stdout
output: 'Answer: {{answer}}'
next: scenario.termination
next: scenario::termination
36 changes: 16 additions & 20 deletions module/move/assistant/design/agents_examples/sql.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
title: DB information extractor

nodes:
- id: question_input
type: trigger.stdin
nodes:
- id: input
type: trigger::stdin
prompt: 'Your query: '
next: translator
next: node::translator

- id: thinker
type: agent.completion
# In real life scenario you should specify here:
# - Which DB is used?
# - What are the tables and columns?
# - Schema of the DB.
- id: sql_generator_stage1
type: agent::completion
system_message: 'Your task is to think about how to translate the user query in natural langauge in SQL langauge. Think step by steps.'
user_message: '{{question_input}}'
next: query
user_message: '{{input}}'
next: node::sql_generator_stage2

- id: query
type: agent.completion
- id: sql_generator_stage2
type: agent::completion
system_message: 'Your task to make an SQL code based on user query in natural language and the results of thinking on that query'.
user_message: 'Query: {{question_input}}. Thoughts: {{thinker}}'
user_message: '{{sql_generator_stage1}}'
agent_reuse: node::sql_generator_stage2
next: node::output

- id: output
type: event.stdout
output: '{{query}}'
next: scenario.termination
type: event::stdout
output: '{{sql_generator_stage2}}'
next: scenario::termination
10 changes: 5 additions & 5 deletions module/move/assistant/design/agents_examples/thinker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ description: >
nodes:
- id: question_input
type: trigger.stdin
type: trigger::stdin
prompt: 'Your question: '
next: cleaner

- id: thinker
type: agent.completion
type: agent::completion
system_message: > # This system prompt could be improved more, but for the sake of the example, we will leave it simple.
You are a methodical and knowledgeable assistant tasked with answering user questions thoroughly using a
chain-of-thought approach. Break down complex queries into components, outline a logical plan, and explain
each step in detail with examples or analogies as needed.
user_message: '{{question_input}}'
next: answer
next: summarizer

- id: summarizer
type: agent.completion
type: agent::completion
system_message: >
You are a summarizer tasked with distilling detailed responses into clear, concise summaries.
Capture key points and main conclusions, removing unnecessary details while preserving essential meaning and logical flow.
Expand All @@ -31,4 +31,4 @@ nodes:
- id: output
type: event.stdout
output: 'Answer: {{summarizer}}'
next: scenario.termination
next: scenario::termination

0 comments on commit 4e3e901

Please sign in to comment.