发布

  • [OPIK-2068] [P SDK] LangGraph Studio Failed to extract token usage from presumably Google LLM langchain run. (#2798)

    frostbyte_neo 发布于 2025-07-23 13:04:02 +00:00

    • [OPIK-2068]: Refactored token usage logic and added LangChain integration support.
    • Extracted common token flattening and filtering logic into flatten_result_and_add_model_extra for reuse across providers.
    • Added the LangChainUsage model for handling LangChain responses, supporting token details and backend-compatible dictionary conversion.
    • Integrated LangChainUsage into the OpikUsage factory, enabling seamless support for LangChain responses in the usage pipeline.
    • [OPIK-2068]: Added unit tests for LangChainUsage.
    • Introduced comprehensive test coverage for LangChainUsage model.
    • Validated happy paths, missing input/output token details, and invalid data scenarios.
    • Added tests for backend-compatible flat dictionary conversion.
    • [OPIK-2068]: Refactored LangChain integration and enhanced token usage extraction.
    • Added _assert_chat_usage_validity and updated tests to validate additional token usage keys.
    • Introduced langchain_run_helpers for modular handling of LangChain-specific token usage and metadata extraction.
    • Refactored token usage logic across integrations to leverage langchain_run_helpers.
    • Fixed completion_tokens handling in OpikUsage to address token calculation inaccuracies.
    • Improved maintainability by reducing code duplication and centralizing LangChain token extraction logic.
    • [OPIK-2068]: Added Google GenAI integration tests and updated LangChain configuration.
    • Introduced ensure_google_api_configured fixture to verify GOOGLE_API_KEY environment variable setup.
    • Added tests validating LangChain's Google GenAI token usage and integration.
    • Updated GitHub Actions to include GOOGLE_API_KEY as a secret.
    • Added langchain_google_genai to library integration requirements.
    • [OPIK-2068]: Updated library requirements to fix the Python 3.9 type annotation evaluation issue.
    • Added eval-type-backport to openai integration test requirements for compatibility with Python 3.9.
    • [OPIK-2068]: Updated gemini model version in sample agent SSE.
    • Changed model from gemini-2.5-flash-preview-05-20 to gemini-2.5-flash in weather_time_agent.
    • [OPIK-2068]: Trimmed leading and trailing spaces from feedback score reasons in E2E tests.
    • Applied strip() to score.reason in verifiers.py and test_threads_evaluate.py to ensure consistent formatting.
    • [OPIK-2068]: Removed LangChainUsage and refactored token usage handling across integrations.
    • Deleted LangChainUsage model and related tests.
    • Refactored OpikUsage to directly handle LangChain token usage via Google Gemini mapping.
    • Consolidated token usage logic into integration-specific helpers for consistent extraction.
    • Added google_helpers.py for reusable token usage validation utilities in tests.
    • [OPIK-2068]: Removed LangChainUsage and refactored token usage handling across integrations.
    • Deleted LangChainUsage model and related tests.
    • Refactored OpikUsage to directly handle LangChain token usage via Google Gemini mapping.
    • Consolidated token usage logic into integration-specific helpers for consistent extraction.
    • Added google_helpers.py for reusable token usage validation utilities in tests.
    下载附件