Skip to main content

An integration package connecting Valthera and LangChain

Project description

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.

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

langchain_valthera-0.1.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

langchain_valthera-0.1.3-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file langchain_valthera-0.1.3.tar.gz.

File metadata

  • Download URL: langchain_valthera-0.1.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.13.2 Darwin/24.3.0

File hashes

Hashes for langchain_valthera-0.1.3.tar.gz
Algorithm Hash digest
SHA256 97978fd7fdd1542e1e2edd48fbe2cefb0464eb4c2d55dbb2b9ec3d6ca1774e39
MD5 8ccf48fc4c1f5227f3aa5d8da358a1be
BLAKE2b-256 3d5e60f4b12b5f515fb71f20ed72a6633057968176aa18ea7bf74ae0e7a0e9c2

See more details on using hashes here.

File details

Details for the file langchain_valthera-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_valthera-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d826f2d070cb3f37b659a86ee2336ea4f4ddbf6067611497c3c3274e61b5342a
MD5 9a849211d8ba640c71ffebd0c1b577bb
BLAKE2b-256 9f5e5820a39d690ca2ca44113f566ed17ff735526ed5b16ebb5458d9dbdc546d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page