Skip to main content

SDK for integrating purchased graphs from the lmsystems marketplace.

Reason this release was yanked:

Security vulnerability - please upgrade to 1.0.8

Project description

LMSystems SDK

The LMSystems SDK provides a simple interface for integrating and executing purchased graphs from the LMSystems marketplace in your Python applications. This SDK allows you to seamlessly connect to pre-built LangGraph workflows and execute them with your own configurations.

Installation

Install the package using pip:

pip install lmsystems

Quick Start

Here's a simple example of how to use a purchased graph:

from lmsystems.purchased_graph import PurchasedGraph
from langgraph.graph import StateGraph, START, MessagesState
import os
from dotenv import load_dotenv

# Load environment variables
load_dotenv()

# Configure your graph
config = {
    "configurable": {
        "model": "anthropic",
        "anthropic_api_key": "your-api-key"
    }
}

# Set required state values
state_values = {
    "repo_url": "https://github.com/yourusername/yourrepo",
    "github_token": "your-github-token",
    "repo_path": "/path/to/repo"
}

# Initialize the purchased graph
purchased_graph = PurchasedGraph(
    graph_name="github-agent-6",
    api_key=os.environ.get("LMSYSTEMS_API_KEY"),
    config=config,
    default_state_values=state_values
)

# Create a parent graph with MessagesState schema
builder = StateGraph(MessagesState)
builder.add_node("purchased_node", purchased_graph)
builder.add_edge(START, "purchased_node")
graph = builder.compile()

# Invoke the graph
result = graph.invoke({
    "messages": [{"role": "user", "content": "what's this repo about?"}]
})

# Stream outputs (optional)
for chunk in graph.stream({
    "messages": [{"role": "user", "content": "what's this repo about?"}]
}, subgraphs=True):
    print(chunk)

Authentication

API Key

To use the SDK, you'll need an LMSystems API key. Get your API key by:

  1. Creating an account at LMSystems
  2. Navigate to your account settings
  3. Generate an API key

Store your API key securely using environment variables:

export LMSYSTEMS_API_KEY="your-api-key"

Configuration

Graph Configuration

The config parameter allows you to customize the behavior of your purchased graph:

  • model: Specify the LLM provider (e.g., "anthropic", "openai")
  • *_api_key: The corresponding API key for your chosen model
  • Additional configuration options specific to your purchased graph

State Values

default_state_values sets default values for required state parameters:

  • Values specific to your graph's requirements
  • Common examples include API tokens, URLs, and paths
  • These values are merged with any input provided during invocation

API Reference

PurchasedGraph Class

PurchasedGraph(
    graph_name: str,
    api_key: str,
    config: Optional[RunnableConfig] = None,
    default_state_values: Optional[dict[str, Any]] = None,
    base_url: str = "https://api.lmsystems.ai",
    development_mode: bool = False,
)

Parameters:

  • graph_name: Name of the purchased graph
  • api_key: Your LMSystems API key
  • config: Optional configuration for the graph
  • default_state_values: Default values for required state parameters
  • base_url: LMSystems API base URL
  • development_mode: Enable development mode features

Methods:

  • invoke(): Execute the graph synchronously
  • ainvoke(): Execute the graph asynchronously
  • stream(): Stream graph outputs synchronously
  • astream(): Stream graph outputs asynchronously

Error Handling

The SDK provides specific exceptions for different error cases:

  • AuthenticationError: API key or authentication issues
  • GraphError: Graph execution or configuration issues
  • InputError: Invalid input parameters
  • APIError: Backend communication issues

Example error handling:

from lmsystems.exceptions import LmsystemsError

try:
    result = graph.invoke(input_data)
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
except GraphError as e:
    print(f"Graph execution failed: {e}")
except InputError as e:
    print(f"Invalid input: {e}")
except APIError as e:
    print(f"API communication error: {e}")
except LmsystemsError as e:
    print(f"General error: {e}")

Support

For support, feature requests, or bug reports:

License

This project is licensed under the terms of the MIT 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

lmsystems-0.0.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

lmsystems-0.0.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file lmsystems-0.0.1.tar.gz.

File metadata

  • Download URL: lmsystems-0.0.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.9

File hashes

Hashes for lmsystems-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e9ccf2728d232ea7b5f54112d4ff64800fdcf56bb6728ce16ea914203c65d939
MD5 c33cb3d679361f1976c9cbe9b7d027b7
BLAKE2b-256 57555f9cc1cdf9cd834ee1fa1187fe316bebe27c777a5e426cd8b68d08092931

See more details on using hashes here.

File details

Details for the file lmsystems-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: lmsystems-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.9

File hashes

Hashes for lmsystems-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a755e699e8a6f5a99bebb411cfaee5b9d263bfc7facf48906dc9da497e3f2f87
MD5 90c942f2b81add879a830f71adee58dd
BLAKE2b-256 afccb7aca9988f7d331538b1c50a4707711f4f340b694ef1620387327f583589

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