Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions shinyapp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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.")
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message for authentication failure is not helpful for debugging. Consider providing more specific guidance about checking the LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, and LANGFUSE_HOST environment variables mentioned in the PR description.

Suggested change
print("Authentication failed. Please check your credentials and host.")
print(
"Authentication failed. Please check your LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, and LANGFUSE_HOST environment variables."
)

Copilot uses AI. Check for mistakes.

AnthropicInstrumentor().instrument()

Comment on lines +47 to +51
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Anthropic instrumentation is enabled unconditionally, even when Langfuse authentication fails. According to the PR description, instrumentation should be optional when environment variables are not available. Consider wrapping the instrumentation in the authentication check or adding proper error handling.

Suggested change
else:
print("Authentication failed. Please check your credentials and host.")
AnthropicInstrumentor().instrument()
AnthropicInstrumentor().instrument()
else:
print("Authentication failed. Please check your credentials and host.")

Copilot uses AI. Check for mistakes.
app_dir = Path(__file__).parent


Expand Down
5 changes: 5 additions & 0 deletions shinyapp/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ google-api-python-client
markdown
pandas
requests

# For instrumentation
openai
langfuse
opentelemetry-instrumentation-anthropic