Skip to content

add a draw_graph() method for enhanced acessibility #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
4 tasks
josh-ashkinaze opened this issue Sep 13, 2024 · 1 comment
Open
4 tasks

add a draw_graph() method for enhanced acessibility #45

josh-ashkinaze opened this issue Sep 13, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request p1 important

Comments

@josh-ashkinaze
Copy link
Owner

josh-ashkinaze commented Sep 13, 2024

Is your feature request related to a problem? Please describe if so!
Not a problem but it would be nice if users could SEE the graph they created just to make sure they created it right.

Describe the feature you'd like!
As we discussed, implement a `draw_graph' method of DAG so that users can see if they created the thing they wanted to.

End-stage behavior:

  • users can call Graph.draw_graph() and it will draw a graph and return a matplotlib object for customization.

I started this awhile back here (

def _build_graph(self):
)

Implementation

Drawing stuff

  • Create a directed graph through networkx from the agents and edges list, and then use the native nx graph drawing function [1]

Labels

Dict method

  • For the dict method, the nodes should be the keys. So for example:
agents = {'a1':Agent(system_instructions="blah"), 'a2':Agent(system_instructions="blah2")}
edges = [('a1', 'a2')]

Here, the desired behavior is that we have nodes labeled a1 and a2 and edges from a1 to a2.

List Method

  • For the list method, it is not as obvious how this should be implemented since Agents don't really have a "name". But let's just make the name the index of the Agent (and maybe we say in docs we recommend dict method)
agents = [ Agent(system_instructions="blah"), Agent(system_instructions="blah2"]
edges = [(0,1)]

Here, the desired behavior is that we have nodes labeled 0 and 1 and edges from 0 to 1.

Dependency update

  • Add networkx and matplotlib as dependencies. Bound between major versions of what they are currently on. So for example, if networkx is 2.1 then let's require Networkx between 2.1 and 3

[1]
https://networkx.org/documentation/stable/reference/generated/networkx.drawing.nx_pylab.draw_networkx.html#networkx.drawing.nx_pylab.draw_networkx

Unit tests

  • Mainly, we need to validate that we are constructing the nx graph correctly. Because a graph has two components (nodes and vertices), I'd check each one. So first just make sure the nodes have the correct names, then verify each edge
  • Let's also verify we are returning a matplotlib object

Documentation

  • Update the docstrings for the dag class
  • Give example of using this in the tutorial...the file is tutorials_4_graph.rst

Optional enhancements

  • always good when things look pretty, my first stab (in the graph branch) was ok but can be improved on :)
@josh-ashkinaze josh-ashkinaze added the enhancement New feature or request label Sep 13, 2024
@josh-ashkinaze josh-ashkinaze added the p1 important label Sep 23, 2024
@josh-ashkinaze
Copy link
Owner Author

@avi22bhattacharya where are we at with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request p1 important
Projects
None yet
Development

No branches or pull requests

2 participants