Python SDK for connecting to Large Language Platform.
- Simple, intuitive async API
- Thread-safe message handling with asyncio
- WebSocket-based communication
# Using uv (recommended)
uv add llpsdk
# Using pip
pip install llpsdkimportasyncio, osimportllpsdkasllpfrommy_agentimportcreate_agent# called when starting a conversation with a test agentdefon_start():
# create an instance of your agentreturncreate_agent()
# Define a callback handler for processing messagesasyncdefon_message(agent, annotater, msg):
# Process the prompt with your agent.# Replace this with your own processing logic.response=awaitagent.ainvoke(msg.prompt)
# You must return a responsereturnmsg.reply(response)
asyncdefmain():
# Initialize the clientclient=llp.Client(
os.getenv("LLP_AGENT_NAME"),
os.getenv("LLP_API_KEY"),
)
# Register your message handlerclient.on_start(on_start)
client.on_message(on_message)
try:
# Connect and keep the client runningawaitclient.connect()
print("Agent connected. Press Ctrl+C to exit...")
awaitasyncio.Event().wait()
finally:
awaitclient.close()
asyncio.run(main())# Install with dev dependencies
uv sync --extra dev
# Run tests, type checking, and linting
make test# Formatting
make format