AppBuilder-SDK Documentation

repository·master·Indexed 20 days ago

https://github.com/baidubce/app-builder

A development toolkit for building AI-native applications focused on RAG (Retrieval-Augmented Generation) and Agentic workflows using Baidu Cloud's ecosystem. The SDK provides basic components for ASR, OCR, object recognition, and text generation, as well as the AssistantSDK for orchestrating complex flows including function calls, thread management, and stateful conversations. It supports the creation of AI Agents, Workflow Agents, and enterprise Q&A systems.

Tokens
190K
Snippets
523
Records
736
Agent score
68%

What's inside AppBuilder-SDK

  1. Overview of Baidu AI Search capabilities

    master

    Baidu AI Search integrates Baidu's search engine with Large Language Models (LLMs) to provide intelligent responses backed by real-time web information.

    Key features include:

    • Custom Persona Settings: Define the identity/tone of the AI.
    • Model Selection: Choose from different underlying LLMs.
    • Query Rewriting: Enhances search results using time-sensitive and multi-turn approaches.
    • Search Scope Configuration: Control modalities, specific site ranges, and publication date filters.
    • Reference Management: Customizable number of reference links provided in responses.
  2. Overview of AppBuilder-SDK

    master

    AppBuilder-SDK is a one-stop development platform client SDK for Baidu Cloud Qianfan AppBuilder, designed for AI-native application developers. It provides capabilities across three main pillars:

    1. Calling (Invocation)

    • Large Language Models (LLMs): Call models from the Baidu Cloud Qianfan platform and optimize prompts.
    • Capability Components: Access over 40+ high-quality components from the Baidu ecosystem to empower Agent applications.
    • AI-Native Applications: Use AppBuilderClient to access and manage applications published via the AppBuilder web console, and register local functions to link with cloud-end components.

    2. Orchestration

    • Knowledge Base Management: Use KnowledgeBase to manage documents and knowledge slices (CRUD operations) for industrial-grade RAG applications.
    • Workflow Orchestration: Implement multi-level workflows using Message, Component, and AgentRuntime abstractions. It is compatible with ecosystems like LangChain and OpenAI.

    3. Monitoring & Deployment

    • Monitoring: Includes visual Tracing and detailed DebugLog tools for production environments.
    • Deployment:
      • AgentRuntime supports deployment as API services (via Flask and gunicorn) or interactive chat frontends (via Chainlit).
      • appbuilder_bce_deploy tool allows for rapid deployment to Baidu Cloud to provide public API services linked to AppBuilder workflows.
  3. Overview of Vector Retrieval components

    master

    AppBuilder provides vector retrieval capabilities through two primary components that use different database backends for storing and retrieving high-dimensional vector data:

    1. Baidu VDB Retriever (向量检索-VDB): Uses Baidu Vector Database as the foundation. It is an enterprise-grade distributed database designed for high-performance, high-availability, and scalability. It supports various index types and similarity calculation methods, capable of managing billions of vectors with millisecond-level query response times.

    2. Baidu ElasticSearch Retriever (向量检索-BES): Uses Baidu ElasticSearch as the foundation. This component is built on a distributed search and analysis service that is compatible with open-source ElasticSearch but enhanced for enterprise needs. It is suitable for handling both structured and unstructured data and includes advanced permission management mechanisms for data security.

  4. Overview of the appbuilder.core package

    master

    The appbuilder.core package serves as the foundational layer for the AppBuilder SDK. It provides the core abstractions required to build AI-native applications, including agents, messaging systems, and capability components.

    Key sub-packages and modules include:

    • Subpackages:
      • appbuilder.core.assistant: Likely contains logic for assistant-style interactions.
      • appbuilder.core.components: Contains the building blocks for application capabilities.
      • appbuilder.core.console: Likely provides console-based or CLI interaction utilities.
    • Core Modules:
      • appbuilder.core.agent: Manages agentic behaviors and logic.
      • appbuilder.core.message: Handles the structure and flow of messages within the system.
      • appbuilder.core.component: Defines the base component architecture.
  5. What is AppBuilder SDK?

    master

    Baidu AI Cloud Qianfan AppBuilder SDK is a one-stop development tool for AI-native application developers. It provides capabilities across four main pillars:

    1. Utilization: Access Large Language Models (LLMs) on the Baidu AI Cloud Qianfan platform to develop and optimize prompts. Integrate over 40 high-quality functional components from the Baidu ecosystem. Access and manage AI-native applications published on the AppBuilder platform via AppBuilderClient and register local functions to link cloud components.
    2. Orchestration: Manage knowledge flows and RAG (Retrieval-Augmented Generation) applications using KnowledgeBase for CRUD operations on documents and knowledge slices. Orchestrate workflows using multi-layer abstractions including Message, Component, and AgentRuntime, allowing integration with ecosystems like LangChain and OpenAI.
    3. Monitoring: Access visualization traces and detailed debug logs for production environments.
    4. Deployment: Support for deploying AgentRuntime as API services (based on Flask and Gunicorn) or interactive frontend applications (based on Chainlit). The appbuilder_bce_deploy tool facilitates rapid deployment to Baidu Cloud as public network API services.
  6. Overview of DocParser component

    master

    The DocParser component is used for document content parsing. It supports 16 different document formats, including PDF, JPG, DOC, TXT, XLS, and PPT.

    It can extract:

    • Character content and text
    • Layout information (titles, body text, headers, footers, tables)
    • Position coordinates
    • Table structures
    • Reading order
    • Hierarchical title/paragraph trees

    Supported document types are categorized into:

    • Layout documents: pdf, jpg, jpeg, png, bmp, tif, tiff, ofd
    • Stream documents: doc, docx, txt, xls, xlsx, wps, ppt, pptx
  7. Use BaiduElasticSearchRetriever for vector search

    master

    The BaiduElasticSearchRetriever (BES) component enables efficient content retrieval based on text vector similarity using Baidu ElasticSearch. It allows you to ingest text segments into an ES cluster, build a vector index, and perform similarity searches using a query.

    import os
    import appbuilder
    
    # Set your AppBuilder token
    os.environ["APPBUILDER_TOKEN"] = '...'
    
    embedding = appbuilder.Embedding()
    segments = appbuilder.Message(["text segment 1", "text segment 2"])
    
    # 1. Initialize and build index
    vector_index = appbuilder.BESVectorStoreIndex.from_segments(
        segments=segments, 
        cluster_id=es_cluster_id, 
        user_name=es_username, 
        password=es_password, 
        embedding=embedding
    )
    
    # 2. Convert index to a retriever
    retriever = vector_index.as_retriever()
    
    # 3. Perform retrieval
    query = appbuilder.Message("your query")
    res = retriever(query=query, top_k=1)
    print(res)
    
    # 4. Cleanup (optional)
    vector_index.delete_all_segments()
  8. Use the GeneralOCR component for high-precision text recognition

    master

    The GeneralOCR component provides high-precision text detection and recognition across multiple scenarios and 20+ languages. It supports various formats including printed/handwritten documents, web images, tables, seals, numbers, and QR codes. It is suitable for digitizing paper documents, office report recognition, and image content auditing.

    import os
    import appbuilder
    import requests
    
    # Set your authentication token
    os.environ["APPBUILDER_TOKEN"] = 'your_token_here'
    
    # Load an image
    image_url = "https://example.com/image.png"
    raw_image = requests.get(image_url).content
    
    # Initialize and run GeneralOCR
    general_ocr = appbuilder.GeneralOCR()
    out = general_ocr.run(appbuilder.Message(content={"raw_image": raw_image}))
    print(out.content)
  9. Supported programming languages for AppBuilder SDKs

    master

    The AppBuilder SDKs are divided into two main categories with different language support:

    Platform Function SDKs

    Supports Python, Java, and Go. These SDKs allow you to manage applications and interact with knowledge bases.

    • Application Management: Manage and list applications.
    • AppBuilderClient SDK: Call applications directly.
    • KnowledgeBase SDK: Manage and interact with knowledge bases.

    AI Foundation Capability Component SDKs

    Supports Python only. These SDKs provide access to core AI capabilities.

    • Model Management: Retrieve lists of available models.
    • Capability Components: Access various foundational AI components.
  10. Explore the AppBuilder Python API structure

    master

    The AppBuilder Python SDK is organized into several core functional modules. Depending on your use case, you will interact with one of the following primary APIs:

    • Assistant API: Used for building and managing AI assistants that can handle complex tasks and maintain context.
    • Components API: Used to access and invoke specific capability components (e.g., specialized AI tools or functional modules).
    • Console API: Used for administrative or management tasks via the console interface.
  11. AppBuilder SDK Documentation Overview

    master

    The AppBuilder SDK documentation is organized into several key areas to help you build AI-native applications:

    1. Quick Start

    Includes installation guides, a quick start guide for your first application, industrial practice examples, and a list of supported programming languages.

    2. Basics

    • Models: How to interact with and list available models.
    • Components: Using the core building blocks of the SDK.
    • Monitoring: Using TRACE (basic and extended/Phoenix methods) and debug functionality to observe application behavior.
    • Deployment: Methods for deploying your applications, including interactive front-ends (Chainlit), public cloud deployment, Flask API access, AgentRuntime, and UserSession management.
    • Platform: Interacting with the AppBuilder platform via AppBuilderClient, managing published applications, using the Knowledge Base component, and creating custom components.

    3. Applications

    • Agent: Core knowledge, using official components, and advanced features like ToolCall and ToolChoice.
    • RAG (Retrieval-Augmented Generation): Basic knowledge, Knowledge Base management, and reference information processing.
    • Workflow: Building RAG or Agent applications from scratch using the Workflow orchestration tool.

    4. Developer Guide

    Technical details for secondary development, contributing code, version upgrade logs, error message references, and environmental parameters.

  12. Explore AppBuilder-SDK Documentation and Guides

    master

    The AppBuilder-SDK documentation is organized into several key areas to help you build AI-native applications:

    Quick Start

    • Start your first AI-native application: Includes installation and quickstart guides.
    • Industrial Practice Examples: Real-world usage examples of the SDK.
    • Supported Languages: A list of programming languages currently supported by the SDK.

    Core Modules (Basis)

    • Models: How to retrieve and use available large language models.
    • Components: Working with various functional components.
    • Monitoring (TRACE): Basic and extended tracing features for observability.
    • Deployment: Methods for deploying applications, including interactive frontends (Chainlit), public cloud deployment, Flask API access, AgentRuntime, and UserSession.
    • Platform Services: Managing applications via AppBuilderClient, interacting with Knowledge Bases, and using custom components.

    Application Patterns

    • Agents: Core knowledge, using official components, and implementing ToolCall or ToolChoice.
    • RAG (Retrieval-Augmented Generation): Knowledge base management and reference information processing.
    • Workflows: Building RAG or Agent applications from scratch using Workflow orchestration.

    Developer Resources

    • Advanced Development: Guides for secondary development and contributing code.
    • Maintenance: Version changelogs and error message references.
    • Configuration: Details on environmental parameters.