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
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
862c0dfe5d12fa78fe05f99c4a9faa2f5023a4c4aae999f70dc628a15019a1d2
|
|
| MD5 |
60893bb19b62c4a589e000873702fa40
|
|
| BLAKE2b-256 |
d02401386816d750c0171775bc39b5337183a53f2c47507813401e7e1db26db0
|
File details
Details for the file langflow_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langflow_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb8d345e12ce0868c97bac9450bb59709b2b516580d36178475fd9adf76b3a39
|
|
| MD5 |
4d7027b33f26987d5660f4694572ae72
|
|
| BLAKE2b-256 |
5bf0d437afaeaefe3934cdfce336fc43f3b29117afec04710fbd01d53523ab58
|