This project has been archived by its maintainers, and is no longer receiving any updates.
Freeplay Python LangGraph
Freeplay integration for LangGraph and LangChain, providing observability and prompt management for your AI applications.
Installation
pip install freeplay-python-langgraph
Features
- 🔍 Automatic Observability: OpenTelemetry instrumentation for LangChain and LangGraph applications
- 📝 Prompt Management: Call Freeplay-hosted prompts with version control and environment management
- 🤖 Auto-Model Instantiation: Automatically create LangChain models based on Freeplay's configuration
- 💬 Conversation History: Native support for multi-turn conversations with LangGraph MessagesState
- 🛠️ Tool Support: Seamless integration with LangChain tools
- 🧪 Test Execution Tracking: Track test runs and test cases for evaluation workflows
- 🎯 Multi-Provider Support: Works with OpenAI, Anthropic, Vertex AI, and more
Quick Start
Configuration
Set up your environment variables:
export FREEPLAY_API_URL="https://app.freeplay.ai/api"
export FREEPLAY_API_KEY="fp-..."
export FREEPLAY_PROJECT_ID="..."
Or pass them directly when initializing:
from freeplay_python_langgraph import FreeplayLangGraph
freeplay = FreeplayLangGraph(
freeplay_api_url="https://api.freeplay.ai",
freeplay_api_key="fp_...",
project_id="proj_...",
)
Usage
Prompt Management with Auto-Model Instantiation
Call a Freeplay-hosted prompt and let the SDK automatically instantiate the correct model:
from freeplay_python_langgraph import FreeplayLangGraph
freeplay = FreeplayLangGraph()
# Invoke a prompt - model is automatically created based on Freeplay's config
response = freeplay.invoke(
prompt_name="weather-assistant",
variables={"city": "San Francisco"},
environment="production"
)
Using Custom Models
You can also provide your own pre-configured model:
from langchain_openai import ChatOpenAI
from freeplay_python_langgraph import FreeplayLangGraph
freeplay = FreeplayLangGraph()
model = ChatOpenAI(model="gpt-4", temperature=0.7)
response = freeplay.invoke(
prompt_name="weather-assistant",
variables={"city": "New York"},
model=model
)
Conversation History (Multi-turn Chat)
Maintain conversation context with history:
from langchain_core.messages import HumanMessage, AIMessage
from freeplay_python_langgraph import FreeplayLangGraph
freeplay = FreeplayLangGraph()
# Build conversation history
history = [
HumanMessage(content="What's the weather in Paris?"),
AIMessage(content="It's sunny and 22°C in Paris."),
HumanMessage(content="What about in winter?")
]
response = freeplay.invoke(
prompt_name="weather-assistant",
variables={"city": "Paris"},
history=history
)
Tool Calling
Bind LangChain tools to your prompts:
from langchain_core.tools import tool
from freeplay_python_langgraph import FreeplayLangGraph
@tool
def get_weather(city: str) -> str:
"""Get the current weather for a city."""
# Your weather API logic here
return f"Weather in {city}: Sunny, 22°C"
freeplay = FreeplayLangGraph()
response = freeplay.invoke(
prompt_name="weather-assistant",
variables={"city": "London"},
tools=[get_weather]
)
Test Execution Tracking
Track test runs for evaluation workflows:
from freeplay_python_langgraph import FreeplayLangGraph
freeplay = FreeplayLangGraph()
response = freeplay.invoke(
prompt_name="my-prompt",
variables={"input": "test input"},
test_run_id="test_run_123",
test_case_id="test_case_456"
)
Observability
The SDK automatically instruments your LangChain and LangGraph applications with OpenTelemetry. All traces are sent to Freeplay.
Provider Support
The SDK supports automatic model instantiation for the following providers:
- OpenAI: Requires
langchain-openaipackage - Anthropic: Requires
langchain-anthropicpackage - Vertex AI: Requires
langchain-google-vertexaipackage
Install the required provider package:
pip install langchain-openai
# or
pip install langchain-anthropic
# or
pip install langchain-google-vertexai
Metadata
Release files for freeplay-python-langgraph 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| freeplay_python_langgraph-0.1.2.tar.gz | 273.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| freeplay_python_langgraph-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 281.9 kB
Release files / freeplay_python_langgraph-0.1.2.tar.gz
| Download URL | freeplay_python_langgraph-0.1.2.tar.gz |
|---|---|
| Size | 273.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e372e1c6f3e36bf07a56213ee4ba73a0564bbb8ae3cbac2582111dc954580078
|
|
BLAKE2b-256 checksum How to use checksums |
a46225d9629510fd33fd983b175c0ed8e9313b006275a2053e80ef8638628a7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.4
|
Release files / freeplay_python_langgraph-0.1.2-py3-none-any.whl
| Download URL | freeplay_python_langgraph-0.1.2-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0baa479f732735695c5ff6f63132dbe85960dbb382796ac697023876c2ff65d1
|
|
BLAKE2b-256 checksum How to use checksums |
e4e219b42fd56b404447f934d15afc6f65ef763351422cd0815e3480826c317c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.4
|