Skip to content

Latest commit

 

History

History
127 lines (85 loc) · 5.48 KB

introduction.mdx

File metadata and controls

127 lines (85 loc) · 5.48 KB
title description sidebarTitle mode
Introduction to SmartGraph
SmartGraph is a powerful, reactive Python framework for building scalable Large Language Model (LLM) applications. It simplifies complex AI workflows with modular components, built-in state management, and seamless LLM integration. Inspired by modern frontend frameworks, SmartGraph brings reactive programming to AI development, enabling developers to create efficient, maintainable, and visualizable LLM pipelines.
Introduction
wide

Building complex, agentic LLM workflows is challenging.

Basic APIs like OpenAI's and Hugging Face's are powerful, but they can't handle complex, multi-step AI workflows on their own. Frameworks like Langraph, CrewAI and AutoGen try to fill this gap, but they're often too abstract or rigid for custom, fine-tuned LLM pipelines. What if there was a flexible, reactive way to build any LLM-powered workflow you can imagine?

I'm intrigued. Go on...

Say hello to SmartGraph.

Hello, SmartGraph! What's your story?

SmartGraph is a reactive Python framework that lets you build tailored, complex LLM applications with the ease of assembling Lego blocks. It's flexible enough for any workflow, yet powerful enough to handle sophisticated AI agents and data transformations.

You've piqued my curiosity. Show me more!

It's unlike anything you've worked with before. The best way to grasp its power is to see it in action. Grab your lab coat and safety goggles – we're about to conduct some serious AI experiments.

...I'll fire up my quantum computer

Ok, let's see some code

Here's a real-time search assistant built with SmartGraph.

import asyncio
import os

from dotenv import load_dotenv

from smartgraph import ReactiveSmartGraph
from smartgraph.components import CompletionComponent, TextInputHandler
from smartgraph.tools.duckduckgo_toolkit import DuckDuckGoToolkit

# Load environment variables
load_dotenv()

class SearchAssistant(ReactiveSmartGraph):
    def __init__(self):
        super().__init__()
        pipeline = self.create_pipeline("SearchAssistant")

        pipeline.add_component(TextInputHandler("TextInput"))
        pipeline.add_component(CompletionComponent(
            "GPT_Completion",
            model="gpt-4o-mini",
            api_key=os.getenv("OPENAI_API_KEY"),
            toolkits=[DuckDuckGoToolkit()]
        ))

        # Compile the graph
        self.compile()

    async def search(self, query):
        return await self.execute("SearchAssistant", query)

async def main():
    assistant = SearchAssistant()
    result = await assistant.search("Who win the first medal in Paris's JO 2024?")
    print(result)

if __name__ == "__main__":
    asyncio.run(main())

When a user sends a query, the assistant searches the web and provides an AI-generated response in real-time.

Magical, I know...

How the heck does this work?

  • SmartGraph sets up a reactive pipeline with modular components (like TextInputHandler and CompletionComponent).
  • When a search query comes in, it flows through the pipeline.
  • The DuckDuckGoToolkit performs a web search based on the query.
  • The CompletionComponent uses the search results and the original query to generate a response with the LLM.
  • SmartGraph manages the entire flow, handling state and asynchronous operations seamlessly.

Why SmartGraph?

  • Reactive Core: Built on ReactiveX, SmartGraph makes handling complex, event-driven workflows a breeze.
  • LLM-First: Tailored for AI applications, with optimized components for working with language models.
  • State Management: Handling state across multiple API calls and LLM interactions? SmartGraph's got you covered.
  • Visualize Your AI: Understand your AI pipelines at a glance with built-in visualization tools.

Installation: As easy as ABC

Getting started with SmartGraph is as simple as:

pip install smartgraph

No need for complex boilerplate or configuration files!

Exciting things to come...

SmartGraph is constantly evolving. Join our mailing list, and we'll send you updates about the framework and upcoming educational materials. (You'll also get the occasional AI wisdom drops, unsubscribe anytime)

[Subscribe Button]

We won't send you spam. Only golden AI nuggets from our neural networks. Unsubscribe at any time.

In Conclusion

SmartGraph brings the reactive programming paradigm to the world of AI and LLM applications. It's not just a library; it's a new way of thinking about and building AI-powered systems.

Ready to simplify your LLM application development? Dive into the following sections to explore SmartGraph's core concepts, advanced features, and best practices. Let's revolutionize AI development together!

Next Steps

To dive deeper into SmartGraph's capabilities and learn how to build more complex applications, check out the following sections:

  • Core Concepts: Learn about the fundamental building blocks of SmartGraph.
  • Controlling Flow: Discover how to create dynamic workflows using piplines and inputs handlers.
  • State Management: Understand how to manage application state.
  • AI Assistants: Learn how to integrate and leverage AI assistants in your SmartGraph applications.
  • Custom Components: Explore how to extend SmartGraph with your own specialized components.

By mastering these concepts, you'll be well-equipped to create powerful, intelligent applications using SmartGraph.