Skip to main content

Async Python client library for interacting with Langflow API servers

Project description

Langflow Python Client

An async Python client library for interacting with Langflow API servers.

PyPI version Python Support License: MIT

Features

Features

  • 🚀 Async/await support - Built with modern Python async patterns for high performance
  • 🔐 Authentication - Secure API key authentication for protected Langflow instances
  • 🎛️ Dynamic Tweaks - Modify flow behavior at runtime without changing flow definitions
  • 📁 File Upload - Upload files directly to flows for document processing and analysis
  • 📝 Type Safety - Full type annotation support with IDE autocomplete
  • 🔧 Flexible Configuration - Support for different input/output types (text, chat)
  • 🐍 Python 3.10+ - Compatible with modern Python versions

Installation

pip install langflow-python-client

Quick Start

Basic Usage

import asyncio
from langflow_client import LangflowClient, FlowRequestOptions
from langflow_client.constants import InputTypes, OutputTypes

async def main():
    # Initialize the client
    client = LangflowClient(
        base_url="http://localhost:7860"
    )
    
    # Get a flow instance
    flow = client.flow("your-flow-id")
    
    # Create request options
    options = FlowRequestOptions(
        input_type=InputTypes.TEXT,
        output_type=OutputTypes.TEXT,
        session_id="my-session"
    )
    
    # Run the flow
    result = await flow.run(
        "Hello, Langflow!",
        options=options
    )
    
    print(result)

# Run the async function
asyncio.run(main())

Using Tweaks for Dynamic Configuration

Tweaks allow you to modify flow components at runtime without changing the flow definition:

async def run_with_tweaks():
    client = LangflowClient(base_url="http://localhost:7860")
    
    # Create flow with component tweaks
    flow = client.flow("flow-id").tweak(**{
        "TextInput-ABC123": {
            "input_value": "Candidate CV content here..."
        },
        "OpenAI-DEF456": {
            "temperature": 0.7,
            "max_tokens": 500
        },
        "ChatOutput-GHI789": {
            "should_store_message": False
        }
    })
    
    # Run with options
    options = FlowRequestOptions(
        input_type=InputTypes.CHAT,
        output_type=OutputTypes.CHAT
    )
    
    result = await flow.run(options=options)
    return result

Input and Output Types

The client supports different input and output types depending on your Langflow components:

Type Description Use Case
InputTypes.TEXT Plain text input Simple text processing, document analysis
InputTypes.CHAT Chat message format Interactive chatbots, conversational AI
OutputTypes.TEXT Plain text output Clean text responses
OutputTypes.CHAT Chat message format Interactive chatbots, conversational

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

langflow_python_client-1.0.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

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

langflow_python_client-1.0.0-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file langflow_python_client-1.0.0.tar.gz.

File metadata

  • Download URL: langflow_python_client-1.0.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for langflow_python_client-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9fbd85c666e4a3a175b2baf8f9370e068d2972b1cf2a85fd42ccca728e3d7fef
MD5 a41a9ab6e3a942ca5854487529be8c47
BLAKE2b-256 904cd3620f52a87b76ae1d8a95005adc7971c39808f3217ff5613e4681351418

See more details on using hashes here.

File details

Details for the file langflow_python_client-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langflow_python_client-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 25643e2a3a987d7501b7c3ea03eba657bfe63f47c543b76e9e2528a9951b14ad
MD5 414783d315ea254c197a71bb546dc76e
BLAKE2b-256 9b8ce27de554997d108a5cabc8137c0482a9a85cf9599fd9494c4259b80702f7

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