Graphtomation Documentation
⚠️ Disclaimer: This package is still under development. Use it at your own risk.
Overview
Graphtomation is an AI utility package designed to simplify the development and deployment of AI-powered workflows. By combining Crew and LangGraph with FastAPI, it enables AI engineers to create modular, reusable components and expose them as API endpoints. With tools, agents, tasks, and crews ready for integration, Graphtomation accelerates the process of building and serving complex multi-agent systems.
Installation
Install the required dependencies for Graphtomation using the following command:
pip install graphtomation
Implementation
Crew
from typing import Type
from fastapi import FastAPI
from crewai.tools import BaseTool
from crewai import Agent, Task, Crew
from pydantic import BaseModel, Field
from langchain_community.tools import DuckDuckGoSearchRun
from graphtomation.crewai import CrewApiRouter, CrewExecutor
app = FastAPI()
class DuckDuckGoSearchInput(BaseModel):
"""Input schema for DuckDuckGoSearchTool."""
query: str = Field(..., description="Search query to look up on DuckDuckGo.")
class DuckDuckGoSearchTool(BaseTool):
name: str = "DuckDuckGoSearch"
description: str = (
"This tool performs web searches using DuckDuckGo and retrieves the top results. "
"Provide a query string to get relevant information."
)
args_schema: Type[BaseModel] = DuckDuckGoSearchInput
def _run(self, query: str) -> str:
"""
Perform a search using the DuckDuckGo API and return the top results.
"""
return DuckDuckGoSearchRun().invoke(query)
ddg_search_tool = DuckDuckGoSearchTool()
researcher = Agent(
role="Web Researcher",
goal="Perform searches to gather relevant information for tasks.",
backstory="An experienced researcher with expertise in online information gathering.",
tools=[ddg_search_tool],
verbose=True,
)
research_task = Task(
description="Search for the latest advancements in AI technology.",
expected_output="A summary of the top 3 advancements in AI technology from recent searches.",
agent=researcher,
)
example_crew = Crew(
agents=[researcher],
tasks=[research_task],
verbose=True,
planning=True,
)
crew_router = CrewApiRouter(
executor=CrewExecutor(
crews=[
{
"name": "example-crew",
"crew": example_crew,
"metadata": {
"description": "An example crew ai implementation",
"version": "1.0.0",
},
}
]
)
)
app.include_router(crew_router.router, prefix="/crew")
Langgraph
import os
from typing import Literal
from fastapi import FastAPI
from langchain_core.tools import tool
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import ToolNode
from langchain_community.tools import DuckDuckGoSearchRun
from graphtomation.langgraph import GraphExecutor, GraphApiRouter
from langgraph.graph import END, START, StateGraph, MessagesState
app = FastAPI()
@tool(name_or_callable="search-tool")
def search(query: str):
"""Search the web using this tool"""
return DuckDuckGoSearchRun().invoke(query)
tools = [search]
tool_node = ToolNode(tools)
model = ChatOpenAI(api_key=os.getenv("OPENAI_API_KEY")).bind_tools(tools)
def should_continue(state: MessagesState) -> Literal["tools", "__end__"]:
messages = state["messages"]
last_message = messages[-1]
if last_message.tool_calls:
return "tools"
return END
def call_model(state: MessagesState):
messages = state["messages"]
response = model.invoke(messages)
return {"messages": [response]}
workflow = StateGraph(MessagesState)
workflow.add_node("agent", call_model)
workflow.add_node("tools", tool_node)
workflow.add_edge(START, "agent")
workflow.add_conditional_edges(
"agent",
should_continue,
)
workflow.add_edge("tools", "agent")
graph_router = GraphApiRouter(
executor=GraphExecutor(
graphs=[
{
"name": "langgraph-chatbot",
"state_graph": workflow,
"kwargs": {
"checkpointer": {
"name": "postgres",
"conn_string": os.getenv("DB_CONN_STRING"),
},
},
}
]
)
)
app.include_router(graph_router.router, prefix="/graphs")
Metadata
Release files for graphtomation 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| graphtomation-0.2.0.tar.gz | 23.5 kB | Without provenance | Details for graphtomation-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| graphtomation-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for graphtomation-0.2.0-py3-none-any.whl |
Total release size: 43.8 kB
Release files / graphtomation-0.2.0.tar.gz
| Download URL | graphtomation-0.2.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9bec32c0260b097541bf04f6098350d418627bd96b91bc7c5367c472eb37a4ac
|
|
BLAKE2b-256 checksum How to use checksums |
150cf6b7d8c9185c5790512fcc8cf7b37a6a90b45f5f5f698581e27050805dc7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Release files / graphtomation-0.2.0-py3-none-any.whl
| Download URL | graphtomation-0.2.0-py3-none-any.whl |
|---|---|
| Size | 20.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2df74ba689b5c2cabdf7a035d5554b08081c15da4d6902a6e856f9b802a7ee35
|
|
BLAKE2b-256 checksum How to use checksums |
199ebb24137fff7599b1c4124c5e68fd608a2407739aa861ea941e4e4527c998
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Security for graphtomation 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.