diff --git a/shinyapp/app.py b/shinyapp/app.py index 41a912a..3df228e 100644 --- a/shinyapp/app.py +++ b/shinyapp/app.py @@ -14,12 +14,15 @@ from anthropic import APIStatusError, AsyncAnthropic, RateLimitError from anthropic.types import CacheControlEphemeralParam, MessageParam -from app_utils import load_dotenv from htmltools import Tag -from local_types import MessageParam2 +from langfuse import get_client +from opentelemetry.instrumentation.anthropic import AnthropicInstrumentor from shiny import App, Inputs, Outputs, Session, reactive, render, ui from shiny.ui._card import CardItem +from app_utils import load_dotenv +from local_types import MessageParam2 + # from signature import validate_email_server, validate_email_ui @@ -36,6 +39,16 @@ # email_sig_key = os.environ.get("EMAIL_SIGNATURE_KEY", None) +langfuse = get_client() + +# Verify connection +if langfuse.auth_check(): + print("Langfuse client is authenticated and ready!") +else: + print("Authentication failed. Please check your credentials and host.") + +AnthropicInstrumentor().instrument() + app_dir = Path(__file__).parent diff --git a/shinyapp/requirements.txt b/shinyapp/requirements.txt index 3d01528..db316af 100644 --- a/shinyapp/requirements.txt +++ b/shinyapp/requirements.txt @@ -11,3 +11,8 @@ google-api-python-client markdown pandas requests + +# For instrumentation +openai +langfuse +opentelemetry-instrumentation-anthropic \ No newline at end of file