https://github.com/milosgajdos/go-hypher
AI agents as computational graphs in Go
https://github.com/milosgajdos/go-hypher
Last synced: 29 days ago
JSON representation
AI agents as computational graphs in Go
- Host: GitHub
- URL: https://github.com/milosgajdos/go-hypher
- Owner: milosgajdos
- License: apache-2.0
- Created: 2024-07-26T12:54:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-09-04T10:25:53.000Z (9 months ago)
- Last Synced: 2024-12-26T05:42:10.670Z (5 months ago)
- Language: Go
- Homepage:
- Size: 117 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-hypher
[](https://github.com/milosgajdos/go-hypher/actions?query=workflow%3ACI)
[](https:/.go.dev/github.com/milosgajdos/go-hypher)
[](https://opensource.org/licenses/Apache-2.0)Go module for building AI agents as computational graphs.
> [!IMPORTANT]
> **THIS IS A WILD THEORETICAL EXPERIMENT**This project attempts to implement AI agents as computational graphs in Go.
> [!NOTE]
> The name of the project has been inspired by [Hypha](https://en.wikipedia.org/wiki/Hypha)
> which is understood to be a long, branching structure -- like a graph -- which enables
> communication in fungi by conducting electrical impulses through hyphae.# Basics
AI agent is represented as a weighted directed acyclic graph (DAG).
The graph nodes are the fundamental computational units: they execute an action anre return its result.
The action can be any computational task e.g. LLM prompt, function call, etc.The actions are chained together through the graph edges. Each edge can have a weight assigned to it.
Nodes may have explicit input provided to them, though some nodes do not need any input to execute their action.
Some nodes are marked as input: they are the nodes where the agent execution starts.
There must be at least one output node: the node that generates the agent output i.e. the result
of its (node) actions. It's usually the leaf node in the graph.When the agent runs, it first does a topological sort of its nodes and then executes each node action
in the order returned by the sort.The topological sort is done in ascending order by the number of node incoming edges i.e. in-degrees of nodes.
Naturally, the nodes that have no incoming edges are executed first and usually have inputs provided, though,
the inputs may also come from the node Op(eration) they execute.The output of each node is passed to all its successive nodes which in turn process it, along with their own
input, and then execute their own action and pass the output to the next node: the agent graphs works
in a similar way to a data stream -- the data flows from the inputs, are transformed by intermediate nodes
on their way to the output node. The output node provides the agent execution result.Given each agent is a graph it should be possible to create ensemble of agents by composing agent graphs
to perform arbitrarily complex tasks.Furthermore, in a similar way as the neural networks, we should be able to improve the agent operation
through output feedback using some sort of evaluation of output and some type of optimiser.In the context of LLM agents, we could theoretically improve agent operation by tuning its node prompts
when running the agent in some simulation environments through several cycles: agents could maintain
their prompts history and eval result for each simulation run and the final tuned agent would then simply
pick the prompt that performs the best for the given task.