API Reference#
Welcome to AdalFlow. The API reference is organized by subdirectories.
Core#
All base/abstract classes, core components like generator, embedder, and basic functions are here.
Base building block for building LLM task pipelines. |
|
Container component for composing multiple components, such as Sequential. |
|
A base class that provides an easy way for data to interact with LLMs. |
|
This is the default system prompt template used in the LightRAG. |
|
ModelClient is the protocol and base class for all models(either via APIs or local models) to communicate with components. |
|
LocalDB to perform in-memory storage and data persistence(pickle or any filesystem) for data models like documents and dialogturn. |
|
Functional interface. |
|
Generator is a user-facing orchestration component with a simple and unified interface for LLM prediction. |
|
Extract and convert common string to Python objects. |
|
The component that orchestrates model client (Embedding models in particular) and output processors. |
|
The base class for all retrievers who in particular retrieve documents from a given database. |
|
Class prompt builder for LightRAG system prompt. |
|
Tokenizer from tiktoken. |
|
Tool is LLM's extended capability which is one of the core design pattern of Agent. |
|
The ToolManager manages a list of tools, context, and all ways to execute functions. |
|
Functional data classes to support functional components like Generator, Retriever, and Assistant. |
Components#
Functional components like model client, retriever, agent, local data processing, and output parsers are here.
Implementation and optimization of React agent. |
|
Anthropic ModelClient integration. |
|
Cohere ModelClient integration. |
|
Google GenAI ModelClient integration. |
|
Groq ModelClient integration. |
|
OpenAI ModelClient integration. |
|
Huggingface transformers ModelClient integration. |
|
Helpers for model client for integrating models and parsing the output. |
|
Helper components for data transformation such as embeddings and document splitting. |
|
Splitting texts is commonly used as a preprocessing step before embedding and retrieving texts. |
|
BM25 retriever implementation. |
|
Semantic search/embedding-based retriever using FAISS. |
|
LLM as retriever module. |
|
Leverage a postgres database to store and retrieve documents. |
|
Reranking model using modelclient as a retriever. |
|
The most commonly used output parsers for the Generator. |
Datasets#
Evaluation#
Abstract base class for evaluation metrics. |
|
This is the metric for QA generation. |
|
Retriever Recall @k metric. |
|
This is the metric to use an LLM as a judge for evaluating the performance of predicted answers. |
|
Implementation of G-Eval: G-eval <https://arxiv.org/abs/2303.08774, nlpyang/geval> Instead of getting 1/5 as the score, AdalFlow will use 0.2 as the score, so that we can have a score in range [0, 1] for all metrics. |
Optimization#
Parameter is used by Optimizer, Trainers, AdalComponent to auto-optimizations |
|
Base Classes for AdalFlow Optimizers, including Optimizer, TextOptimizer, and DemoOptimizer. |
|
Base class for Autograd Components that can be called and backpropagated through. |
|
All data types used by Parameter, Optimizer, AdalComponent, and Trainer. |
|
Adapted and optimized boostrap fewshot optimizer: |
|
Adapted from text_grad's String Based Function |
|
Text-grad optimizer and prompts. |
|
Implementation of TextGrad: Automatic “Differentiation” via Text |
|
Ready to use trainer for LLM task pipeline |
|
AdalComponent provides an interface to compose different parts, from eval_fn, train_step, loss_step, optimizers, backward engine, teacher generator, etc to work with Trainer. |
Tracing#
Utils#
Default Dataset, DataLoader similar to utils.data in PyTorch. |
|
This logger file provides easy configurability of the root and named loggers, along with a color print function for console output. |
|
|
Load environment variables from .env file. |
Lazy import a module and class. |
|
Config helper functions to manage configuration and rebuilt your task pipeline. |
|