Skip to main content

Octogen Python SDK built on langgraph

Project description

Octogen Python SDK built on LangGraph

PyPI version Python Version

A Python SDK for building LLM-powered shop agents using LangGraph and LangChain, designed to work with the Octogen platform.

Features

  • Build conversational shop agents with LangGraph's state management
  • Structured output parsing with Pydantic models
  • Built-in recommendation expansion functionality
  • Server deployment capabilities with FastAPI
  • Integration with Octogen MCP tools for product discovery
  • Streamlined agent creation through factory patterns

Environment Variables

Required Variables

  • OPENAI_API_KEY - Your OpenAI API key
  • OCTOGEN_API_KEY - Your Octogen API key
  • OCTOGEN_MCP_SERVER_HOST - Octogen MCP server host URL

Optional Variables (for LangChain Tracing)

  • LANGCHAIN_API_KEY - Your LangChain API key
  • LANGCHAIN_TRACING_V2 - Enable LangChain tracing (set to "true")
  • LANGCHAIN_PROJECT - LangChain project name

.env File Placement

For the SDK to properly load your environment variables, you can:

  1. Place a .env file in your project's root directory - The default behavior is to look for a .env file in the current working directory.

  2. Explicitly specify the path - When using example servers or creating agents, pass the path to your .env file:

    from dotenv import find_dotenv
    from octogen.shop_agent.settings import get_agent_settings
    
    # Pass the path to your .env file
    get_agent_settings(find_dotenv(usecwd=True))
    
  3. Set environment variables directly - You can also set these variables in your environment before running your application.

Example Projects

When running the example projects (stylist, discovery, comparison), place your .env file in the specific example's directory. For instance, to run the stylist example:

examples/stylist/.env  # Place your .env file here when running the stylist example

This is because the examples use find_dotenv(usecwd=True), which looks for a .env file in the current working directory.

Installation

pip install octogen-sdk-langgraph

Requirements

  • Python ≥ 3.12
  • Dependencies:
    • langchain ≥ 0.3.25
    • langgraph ≥ 0.4.3
    • pydantic ≥ 2.11.4
    • octogen-api ≥ 0.1.0a4
    • structlog ≥ 25.3.0

Quick Start

from langchain_openai import ChatOpenAI
from octogen.shop_agent import ShopAgent, create_agent
from your_models import ResponseClass, HydratedResponseClass

# Define your recommendation expansion function
def expand_recommendations(response, messages):
    # Process and expand recommendations
    return json.dumps(expanded_response)

# Create a shop agent
async with create_agent(
    model=ChatOpenAI(model="gpt-4"),
    agent_name="MyShopAgent",
    response_class=ResponseClass,
    hydrated_response_class=HydratedResponseClass,
    rec_expansion_fn=expand_recommendations,
    tool_names=["agent_search_products", "enrich_product_image"],
    hub_prompt_id="your/hub/prompt_id",
) as agent:
    # Use the agent
    result = await agent.run("I'm looking for a new jacket")

Usage Examples

See the examples/ directory for complete implementations:

  • examples/stylist/ - A personal shopping assistant
  • examples/discovery/ - Product discovery agent
  • examples/comparison/ - Product comparison tool

License

This project is licensed under the terms included in the LICENSE file.

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

octogen_sdk_langgraph-0.1.8.tar.gz (348.6 kB view details)

Uploaded Source

Built Distribution

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

octogen_sdk_langgraph-0.1.8-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file octogen_sdk_langgraph-0.1.8.tar.gz.

File metadata

  • Download URL: octogen_sdk_langgraph-0.1.8.tar.gz
  • Upload date:
  • Size: 348.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for octogen_sdk_langgraph-0.1.8.tar.gz
Algorithm Hash digest
SHA256 280c4abff958e34573f95f42ec858ae601e44b8ae667d71ce0ada4e055ef32d1
MD5 34604ab6579338ca83c4718b03f22392
BLAKE2b-256 430740bb413ff130dd5269b3295ee3a6d825046018dc3914672f2a50edf2e190

See more details on using hashes here.

Provenance

The following attestation bundles were made for octogen_sdk_langgraph-0.1.8.tar.gz:

Publisher: python-publish.yml on octogen-ai/octogen-py-sdk

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

File details

Details for the file octogen_sdk_langgraph-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for octogen_sdk_langgraph-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 509ee4347c3f5f772318da5f66c53d50ba9884a9304ebb4b534ac6be530c3a32
MD5 84f306d883eee7e4a969c1645eee66b7
BLAKE2b-256 4a73f80e60691a1fe438db7fa7bd65f9191245dfe23a97db1fd404ef44e66f38

See more details on using hashes here.

Provenance

The following attestation bundles were made for octogen_sdk_langgraph-0.1.8-py3-none-any.whl:

Publisher: python-publish.yml on octogen-ai/octogen-py-sdk

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