Skip to main content

Lightweight local-first tracing SDK for Python LLM applications

Project description

LangFeather Python SDK

English README

LangFeather Python SDK는 LangChain·LangGraph 실행과 일반 Python 코드를 local LangFeather collector로 보냅니다. SDK는 application의 실행 결과를 바꾸지 않도록 백그라운드에서 best-effort로 전송합니다.

시작하기 전에 local collector와 UI를 실행하세요. 전체 설치 방법은 프로젝트 README를 참고하세요.

설치

LangChain 또는 LangGraph application에는 optional extra를 설치합니다.

pip install "langfeather[langchain]"

일반 Python 함수나 ASGI application만 관측한다면 core package만 설치하면 됩니다.

pip install langfeather

SDK endpoint는 다음 우선순위로 결정됩니다.

  1. langfeather.configure(endpoint="http://...")
  2. endpoint를 생략했을 때 LANGFEATHER_ENDPOINT
  3. 기본값 http://127.0.0.1:4319

Host에서 application을 실행하면 기본 endpoint를 그대로 사용할 수 있습니다. 같은 Docker Compose network 안의 application container에서는 http://langfeather:4319처럼 collector service 주소를 지정하세요.

사용법

StateGraph.compile()의 결과처럼 실제로 호출하는 최상위 Runnable을 감쌉니다.

import langfeather

langfeather.configure(endpoint="http://127.0.0.1:4319")
graph = langfeather.wrap_runnable(compiled_graph, name="my-langgraph-app")

result = graph.invoke(
    {"question": "검색 결과를 요약해줘"},
    {"configurable": {"thread_id": "example-session"}},
)

# 짧게 끝나는 CLI/script에서는 종료 전에 호출합니다.
langfeather.flush(timeout=2)

UI에서 새 trace를 열어 root graph와 내부 Runnable·LLM·retriever·tool 실행을 확인하세요. 기존 입력, 출력, streaming chunk, 예외는 wrapper를 씌우기 전과 같은 형태로 application에 전달됩니다.

다음 문서

최소 API

import langfeather

langfeather.configure(endpoint="http://127.0.0.1:4319")

@langfeather.observe(name="retrieve_documents", kind="retriever")
def retrieve_documents(query: str) -> list[str]:
    with langfeather.span("local_lookup", input={"query": query}) as operation:
        documents = ["document"]
        operation.set_output(documents)
    return documents

@observe는 동기 함수, coroutine, generator, async generator를 지원합니다. 직접 provider SDK를 호출하거나 LangChain callback에 나타나지 않는 도구는 @observe(kind="tool") 또는 span(kind="tool")으로 감싸세요.

데이터와 전달의 경계

LangFeather는 debugging을 위해 trace payload를 자동으로 redact, truncate, summarize, sample하지 않습니다. 실제 secret이나 production data를 공유 database에 넣지 마세요.

전송은 bounded in-memory queue와 짧은 retry를 사용하는 best-effort 방식입니다. collector가 없거나 queue가 가득 차도 application의 반환값이나 예외를 바꾸지 않지만, 그 trace는 유실될 수 있습니다. flush()True를 반환해도 SDK가 collector에 전달 처리를 마쳤다는 뜻일 뿐, 서버 database에 저장됐다는 end-to-end 보장은 아닙니다. 자세한 운영 의미는 전송과 제약을 확인하세요.

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

langfeather-0.2.0.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

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

langfeather-0.2.0-py3-none-any.whl (41.5 kB view details)

Uploaded Python 3

File details

Details for the file langfeather-0.2.0.tar.gz.

File metadata

  • Download URL: langfeather-0.2.0.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for langfeather-0.2.0.tar.gz
Algorithm Hash digest
SHA256 aea70f49f97341b399f60f2aba0a257791e8198dd15932f13deedc72c6b96ad4
MD5 fb0a32e7bcaca8a8e7f05b9e3494af2d
BLAKE2b-256 af1df9690c5bbcc44b5a230cb7800aad5219999da793c12794568280e405f593

See more details on using hashes here.

Provenance

The following attestation bundles were made for langfeather-0.2.0.tar.gz:

Publisher: release.yml on SungjinWi99/LangFeather

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langfeather-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: langfeather-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 41.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for langfeather-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d6eaaf7950c00ad38134a2079485558da39fb154a9a339e97257534e228da5
MD5 88bfd4f31b99e94dcd6e8066f6f0febb
BLAKE2b-256 1a683d1444875ab1d5c0b6182a5e46331af45edc4baf8f9d61cf7c757cf97a06

See more details on using hashes here.

Provenance

The following attestation bundles were made for langfeather-0.2.0-py3-none-any.whl:

Publisher: release.yml on SungjinWi99/LangFeather

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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