Home / File/ test_openai.py — langchain Source File

test_openai.py — langchain Source File

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

File python CoreAbstractions MessageSchema 4 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  a5767d2c_457f_93b9_bca6_38ff2af870fe["test_openai.py"]
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  a5767d2c_457f_93b9_bca6_38ff2af870fe --> 120e2591_3e15_b895_72b6_cb26195e40a6
  d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"]
  a5767d2c_457f_93b9_bca6_38ff2af870fe --> d758344f_537f_649e_f467_b9d7442e86df
  5bb05482_5f6d_f5c2_1460_a2ec977e38f7["langchain_core.messages.block_translators.openai"]
  a5767d2c_457f_93b9_bca6_38ff2af870fe --> 5bb05482_5f6d_f5c2_1460_a2ec977e38f7
  6e27a55e_2e34_4dd3_6821_c8c2b0a67be6["tests.unit_tests.language_models.chat_models.test_base"]
  a5767d2c_457f_93b9_bca6_38ff2af870fe --> 6e27a55e_2e34_4dd3_6821_c8c2b0a67be6
  style a5767d2c_457f_93b9_bca6_38ff2af870fe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import pytest

from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage
from langchain_core.messages import content as types
from langchain_core.messages.block_translators.openai import (
    convert_to_openai_data_block,
)
from tests.unit_tests.language_models.chat_models.test_base import (
    _content_blocks_equal_ignore_id,
)


def test_convert_to_v1_from_responses() -> None:
    message = AIMessage(
        [
            {"type": "reasoning", "id": "abc123", "summary": []},
            {
                "type": "reasoning",
                "id": "abc234",
                "summary": [
                    {"type": "summary_text", "text": "foo bar"},
                    {"type": "summary_text", "text": "baz"},
                ],
            },
            {
                "type": "function_call",
                "call_id": "call_123",
                "name": "get_weather",
                "arguments": '{"location": "San Francisco"}',
            },
            {
                "type": "function_call",
                "call_id": "call_234",
                "name": "get_weather_2",
                "arguments": '{"location": "New York"}',
                "id": "fc_123",
            },
            {"type": "text", "text": "Hello "},
            {
                "type": "text",
                "text": "world",
                "annotations": [
                    {"type": "url_citation", "url": "https://example.com"},
                    {
                        "type": "file_citation",
                        "filename": "my doc",
                        "index": 1,
                        "file_id": "file_123",
                    },
                    {"bar": "baz"},
                ],
            },
            {"type": "image_generation_call", "id": "ig_123", "result": "..."},
            {
                "type": "file_search_call",
                "id": "fs_123",
                "queries": ["query for file search"],
                "results": [{"file_id": "file-123"}],
                "status": "completed",
            },
// ... (546 more lines)

Subdomains

Dependencies

  • langchain_core.messages
  • langchain_core.messages.block_translators.openai
  • pytest
  • tests.unit_tests.language_models.chat_models.test_base

Frequently Asked Questions

What does test_openai.py do?
test_openai.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_openai.py?
test_openai.py defines 5 function(s): test_compat_responses_v03, test_convert_to_openai_data_block, test_convert_to_v1_from_openai_input, test_convert_to_v1_from_responses, test_convert_to_v1_from_responses_chunk.
What does test_openai.py depend on?
test_openai.py imports 4 module(s): langchain_core.messages, langchain_core.messages.block_translators.openai, pytest, tests.unit_tests.language_models.chat_models.test_base.
Where is test_openai.py in the architecture?
test_openai.py is located at libs/core/tests/unit_tests/messages/block_translators/test_openai.py (domain: CoreAbstractions, subdomain: MessageSchema, 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