Skip to main content

An AI utility package to build and serve CrewAI and LangGraph workflows as FastAPI routes, packed with reusable components for AI engineers.

Project description

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 CrewAI 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

import requests
from typing import Type
from fastapi import FastAPI
from crewai.tools import BaseTool
from crewai import Agent, Task, Crew
from graphtomation import CrewAIRouter
from pydantic import BaseModel, Field

# Define the input schema for the tool
class DuckDuckGoSearchInput(BaseModel):
    """Input schema for DuckDuckGoSearchTool."""

    query: str = Field(..., description="Search query to look up on DuckDuckGo.")


# Create the custom tool by subclassing BaseTool
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.
        """
        url = "https://api.duckduckgo.com/"
        params = {
            "q": query,
            "format": "json",
            "no_redirect": "1",
            "no_html": "1",
        }
        try:
            response = requests.get(url, params=params)
            response.raise_for_status()
            data = response.json()

            # Extract the top result or fallback to AbstractText
            if "RelatedTopics" in data and data["RelatedTopics"]:
                results = [
                    topic.get("Text", "No description available")
                    for topic in data["RelatedTopics"]
                    if "Text" in topic
                ]
                return "\n".join(results[:3])  # Return the top 3 results
            else:
                return "No results found for the given query."

        except requests.RequestException as e:
            return f"An error occurred while performing the search: {e}"

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,
)

app = FastAPI()

crew_router = CrewAIRouter(
    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")

Running the Application

fastapi dev main.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphtomation-0.0.4.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graphtomation-0.0.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file graphtomation-0.0.4.tar.gz.

File metadata

  • Download URL: graphtomation-0.0.4.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for graphtomation-0.0.4.tar.gz
Algorithm Hash digest
SHA256 d4fb099d1fb7886770a8fdd134d0a3b37fcb6a2e754924f4d9ca6df7ec154655
MD5 664017de0c0bde94be57d7d34c42d1cf
BLAKE2b-256 5e95b995ed92b8fccf362ad89d075dd741026cce2f72eaa72d23d1a8baca8f9c

See more details on using hashes here.

File details

Details for the file graphtomation-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: graphtomation-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.7

File hashes

Hashes for graphtomation-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c80a675f1a11028e4fcd35e1408c050ea08d8841c98626c7211a97c56e3bb181
MD5 0707632a5739e9b7c2454195d189b2e7
BLAKE2b-256 9313567d8ed46f3510a0295b0ae18fcb556e801473278afd9ad3b25d2cd4817a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page