#!/usr/bin/env python3
"""
LangChain Outside-In Monitoring Example

Demonstrates how to expose a local LangChain agent to the
distributed monitoring network using the tunnel relay.

Requirements:
    pip install agent-status-sdk[langchain] langchain-openai
"""

import os
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from agent_status.integrations.langchain import expose

RORA_API_KEY = os.environ.get("RORA_API_KEY", "your_rora_key")
OPENAI_API_KEY = os.environ.get("OPENAI_API_KEY", "your_openai_key")

llm = ChatOpenAI(model="gpt-4o-mini", api_key=OPENAI_API_KEY)
prompt = ChatPromptTemplate.from_template(
    "You are a helpful assistant. Answer concisely: {input}"
)
chain = prompt | llm | StrOutputParser()

print("Exposing LangChain agent to Agent Status...")
print("Press Ctrl+C to stop")

expose(
    chain,
    api_key=RORA_API_KEY,
    agent_name="My LangChain Assistant",
    blocking=True,
)
