Skip to main content

langchain-valthera

langchain-valthera is an open-source package that integrates LangChain with the Valthera framework, enabling smarter and more timely user engagement through LLM agents.

Installation

Install the package via pip:

pip install -U langchain-valthera

Make sure to configure your credentials by setting the following environment variables:

  • OPENAI_API_KEY: Your OpenAI API key
  • Additional environment variables as needed for your data connectors

Tools

The main component of the langchain-valthera package is the ValtheraTool which integrates with LangGraph agents.

from langchain_valthera.tools import ValtheraTool

Overview

langchain-valthera leverages data from multiple sources to compute real-time engagement metrics. By evaluating a user's context, the framework helps determine the right time and approach to interact with users, ensuring that engagement actions are both timely and context-aware.

Key Components

  • Data Aggregator: Collects and unifies data from various sources like HubSpot, PostHog, and Snowflake.
  • Scorer: Computes user engagement scores (motivation and ability) based on configurable metrics.
  • Reasoning Engine: Uses decision rules to determine the appropriate action (e.g., trigger engagement, improve motivation, or enhance ability).
  • Trigger Generator: Crafts personalized messages or notifications for user engagement.

Getting Started

Here's a quick example of how to set up and run the Valthera agent using LangGraph React:

import os
from langchain_openai import ChatOpenAI
from langchain_valthera.tools import ValtheraTool
from langgraph.prebuilt import create_react_agent

# Initialize your data aggregator and configurations (replace with your implementations)
data_aggregator = ...  # e.g., DataAggregator(connectors=your_connectors)
motivation_config = ...  # Your motivation scoring configuration
ability_config = ...  # Your ability scoring configuration
reasoning_engine = ...  # Your ReasoningEngine instance
trigger_generator = ...  # Your TriggerGenerator instance

# Instantiate the Valthera tool
valthera_tool = ValtheraTool(
    data_aggregator=data_aggregator,
    motivation_config=motivation_config,
    ability_config=ability_config,
    reasoning_engine=reasoning_engine,
    trigger_generator=trigger_generator
)

# Create a LangGraph agent
llm = ChatOpenAI(model_name="gpt-4-turbo", temperature=0.0, openai_api_key=os.environ.get("OPENAI_API_KEY"))
tools = [valthera_tool]
agent = create_react_agent(llm, tools=tools)

# Define input for testing
inputs = {
    "messages": [("user", "Evaluate behavior for user_12345: Finish Onboarding")]
}

# Run the agent and print the responses
for response in agent.stream(inputs, stream_mode="values"):
    print(response)

Customization

Developers can easily extend and customize langchain-valthera to fit their needs:

  • Connectors: Add or modify data connectors to pull information from different sources.
  • Scoring Configurations: Adjust weights and transformation functions to match your business logic.
  • Decision Rules: Define custom rules that determine which engagement action to trigger.

Release files for langchain-valthera 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for langchain-valthera 0.1.3
File Size Uploaded
langchain_valthera-0.1.3.tar.gz 4.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for langchain-valthera 0.1.3
File Interpreter ABI Platform
langchain_valthera-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / langchain_valthera-0.1.3.tar.gz

Download URL langchain_valthera-0.1.3.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
97978fd7fdd1542e1e2edd48fbe2cefb0464eb4c2d55dbb2b9ec3d6ca1774e39
BLAKE2b-256 checksum
How to use checksums
3d5e60f4b12b5f515fb71f20ed72a6633057968176aa18ea7bf74ae0e7a0e9c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.13.2 Darwin/24.3.0

Release files / langchain_valthera-0.1.3-py3-none-any.whl

Download URL langchain_valthera-0.1.3-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d826f2d070cb3f37b659a86ee2336ea4f4ddbf6067611497c3c3274e61b5342a
BLAKE2b-256 checksum
How to use checksums
9f5e5820a39d690ca2ca44113f566ed17ff735526ed5b16ebb5458d9dbdc546d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.5 CPython/3.13.2 Darwin/24.3.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page