Home / File/ test_google_genai.py — langchain Source File

test_google_genai.py — langchain Source File

Architecture documentation for test_google_genai.py, a python file in the langchain codebase. 1 imports, 0 dependents.

File python LangChainCore MessageInterface 1 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  25aec1a3_6028_10e6_bb5b_1c7319a29818["test_google_genai.py"]
  e51f6b7d_dca5_fe6f_a7ce_019a4bee0eae["langchain_core.messages.block_translators.google_genai"]
  25aec1a3_6028_10e6_bb5b_1c7319a29818 --> e51f6b7d_dca5_fe6f_a7ce_019a4bee0eae
  style 25aec1a3_6028_10e6_bb5b_1c7319a29818 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"""Tests for Google GenAI block translator."""

from langchain_core.messages.block_translators.google_genai import (
    translate_grounding_metadata_to_citations,
)


def test_translate_grounding_metadata_web() -> None:
    """Test translation of web grounding metadata to citations."""
    grounding_metadata = {
        "grounding_chunks": [
            {
                "web": {
                    "uri": "https://example.com",
                    "title": "Example Site",
                },
                "maps": None,
            }
        ],
        "grounding_supports": [
            {
                "segment": {
                    "start_index": 0,
                    "end_index": 13,
                    "text": "Test response",
                },
                "grounding_chunk_indices": [0],
                "confidence_scores": [],
            }
        ],
        "web_search_queries": ["test query"],
    }

    citations = translate_grounding_metadata_to_citations(grounding_metadata)

    assert len(citations) == 1
    citation = citations[0]
    assert citation["type"] == "citation"
    assert citation.get("url") == "https://example.com"
    assert citation.get("title") == "Example Site"
    assert citation.get("start_index") == 0
    assert citation.get("end_index") == 13
    assert citation.get("cited_text") == "Test response"

    extras = citation.get("extras", {})["google_ai_metadata"]
    assert extras["web_search_queries"] == ["test query"]
    assert extras["grounding_chunk_index"] == 0
    assert "place_id" not in extras


def test_translate_grounding_metadata_maps() -> None:
    """Test translation of maps grounding metadata to citations."""
    grounding_metadata = {
        "grounding_chunks": [
            {
                "web": None,
                "maps": {
                    "uri": "https://maps.google.com/?cid=13100894621228039586",
                    "title": "Heaven on 7th Marketplace",
                    "placeId": "places/ChIJ0-zA1vBZwokRon0fGj-6z7U",
// ... (159 more lines)

Domain

Subdomains

Dependencies

  • langchain_core.messages.block_translators.google_genai

Frequently Asked Questions

What does test_google_genai.py do?
test_google_genai.py is a source file in the langchain codebase, written in python. It belongs to the LangChainCore domain, MessageInterface subdomain.
What functions are defined in test_google_genai.py?
test_google_genai.py defines 5 function(s): test_translate_grounding_metadata_confidence_scores_none, test_translate_grounding_metadata_maps, test_translate_grounding_metadata_multiple_chunks, test_translate_grounding_metadata_none, test_translate_grounding_metadata_web.
What does test_google_genai.py depend on?
test_google_genai.py imports 1 module(s): langchain_core.messages.block_translators.google_genai.
Where is test_google_genai.py in the architecture?
test_google_genai.py is located at libs/core/tests/unit_tests/messages/block_translators/test_google_genai.py (domain: LangChainCore, subdomain: MessageInterface, directory: libs/core/tests/unit_tests/messages/block_translators).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free