|
14 | 14 | from app.utils import APIResponse |
15 | 15 | from app.crud.credentials import get_provider_credential |
16 | 16 | from app.core.security import decrypt_credentials |
| 17 | +from app.core.util import configure_langfuse |
17 | 18 |
|
18 | 19 | logger = logging.getLogger(__name__) |
19 | 20 | router = APIRouter(tags=["threads"]) |
@@ -245,11 +246,13 @@ async def threads( |
245 | 246 | error="LANGFUSE keys not configured for this organization." |
246 | 247 | ) |
247 | 248 |
|
248 | | - langfuse_context.configure( |
249 | | - secret_key=langfuse_credentials["secret_key"], |
250 | | - public_key=langfuse_credentials["public_key"], |
251 | | - host=langfuse_credentials["host"], |
252 | | - ) |
| 249 | + # Configure Langfuse |
| 250 | + _, success = configure_langfuse(langfuse_credentials) |
| 251 | + if not success: |
| 252 | + return APIResponse.failure_response( |
| 253 | + error="Failed to configure Langfuse client." |
| 254 | + ) |
| 255 | + |
253 | 256 | # Validate thread |
254 | 257 | is_valid, error_message = validate_thread(client, request.get("thread_id")) |
255 | 258 | if not is_valid: |
@@ -310,11 +313,11 @@ async def threads_sync( |
310 | 313 | ) |
311 | 314 |
|
312 | 315 | # Configure Langfuse |
313 | | - langfuse_context.configure( |
314 | | - secret_key=langfuse_credentials["secret_key"], |
315 | | - public_key=langfuse_credentials["public_key"], |
316 | | - host=langfuse_credentials.get("host", "https://cloud.langfuse.com"), |
317 | | - ) |
| 316 | + _, success = configure_langfuse(langfuse_credentials) |
| 317 | + if not success: |
| 318 | + return APIResponse.failure_response( |
| 319 | + error="Failed to configure Langfuse client." |
| 320 | + ) |
318 | 321 |
|
319 | 322 | # Validate thread |
320 | 323 | is_valid, error_message = validate_thread(client, request.get("thread_id")) |
|
0 commit comments