Skip to main content

Un-official Python client for the Langflow API

Project description

Python client for the Langflow API

This package provides an easy way to use the Langflow API to run flows from Python applications.

  • Package: langflow-client
  • Import: import langflow_client
  • License: Apache-2.0

Installation

pip install langflow-client

Prerequisites

  • Base URL of your Langflow instance
  • API key if authentication is enabled on your instance

Usage

Initialization

from langflow_client import LangflowClient

client = LangflowClient({
    "base_url": "http://localhost:7860",
    "api_key": "sk-...",  # optional
})

Running a flow

flow = client.flow("<flow-id>")
response = flow.run("Hello, world!")
print(response.outputs)
print(response.chat_output_text())

You can pass tweaks and IO options:

from langflow_client.consts import InputTypes, OutputTypes

response = flow.run(
    "Hello",
    input_type=InputTypes.CHAT,
    output_type=OutputTypes.CHAT,
    session_id="optional-session-id",
    tweaks={"ChatInput-abc": {"temperature": 0.2}},
)

Streaming

for event in flow.stream("Hello"):
    print(event)

Events are dicts with event keys such as add_message, token, and end.

File upload

  • v1 flow-scoped image upload:
with open("image.jpg", "rb") as f:
    upload = flow.upload_file(f, filename="image.jpg", content_type="image/jpeg")
    print(upload.file_path)
  • v2 user-scoped file upload and listing:
with open("document.pdf", "rb") as f:
    uploaded = client.files.upload(f, filename="document.pdf", content_type="application/pdf")

files = client.files.list()

License

Apache License 2.0. See LICENSE

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_client-0.1.0.tar.gz (19.7 kB view details)

Uploaded Source

Built Distribution

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

langflow_client-0.1.0-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file langflow_client-0.1.0.tar.gz.

File metadata

  • Download URL: langflow_client-0.1.0.tar.gz
  • Upload date:
  • Size: 19.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for langflow_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 862c0dfe5d12fa78fe05f99c4a9faa2f5023a4c4aae999f70dc628a15019a1d2
MD5 60893bb19b62c4a589e000873702fa40
BLAKE2b-256 d02401386816d750c0171775bc39b5337183a53f2c47507813401e7e1db26db0

See more details on using hashes here.

File details

Details for the file langflow_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langflow_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb8d345e12ce0868c97bac9450bb59709b2b516580d36178475fd9adf76b3a39
MD5 4d7027b33f26987d5660f4694572ae72
BLAKE2b-256 5bf0d437afaeaefe3934cdfce336fc43f3b29117afec04710fbd01d53523ab58

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