Home / File/ openai.py — langchain Source File

openai.py — langchain Source File

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

Entity Profile

Dependency Diagram

graph LR
  7f2bcbc2_aff9_c904_6422_fbd83a0635f7["openai.py"]
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  7f2bcbc2_aff9_c904_6422_fbd83a0635f7 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  439a4142_6fa6_fe9a_2cba_7c9fb0cdceb7["langchain_classic._api"]
  7f2bcbc2_aff9_c904_6422_fbd83a0635f7 --> 439a4142_6fa6_fe9a_2cba_7c9fb0cdceb7
  18823f4a_9a9a_628e_6a5e_bb7a5ba86bb7["langchain_community.adapters.openai"]
  7f2bcbc2_aff9_c904_6422_fbd83a0635f7 --> 18823f4a_9a9a_628e_6a5e_bb7a5ba86bb7
  style 7f2bcbc2_aff9_c904_6422_fbd83a0635f7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import TYPE_CHECKING, Any

from langchain_classic._api import create_importer

if TYPE_CHECKING:
    from langchain_community.adapters.openai import (
        Chat,
        ChatCompletion,
        ChatCompletionChunk,
        ChatCompletions,
        Choice,
        ChoiceChunk,
        Completions,
        IndexableBaseModel,
        chat,
        convert_dict_to_message,
        convert_message_to_dict,
        convert_messages_for_finetuning,
        convert_openai_messages,
    )

# Create a way to dynamically look up deprecated imports.
# Used to consolidate logic for raising deprecation warnings and
# handling optional imports.
MODULE_LOOKUP = {
    "IndexableBaseModel": "langchain_community.adapters.openai",
    "Choice": "langchain_community.adapters.openai",
    "ChatCompletions": "langchain_community.adapters.openai",
    "ChoiceChunk": "langchain_community.adapters.openai",
    "ChatCompletionChunk": "langchain_community.adapters.openai",
    "convert_dict_to_message": "langchain_community.adapters.openai",
    "convert_message_to_dict": "langchain_community.adapters.openai",
    "convert_openai_messages": "langchain_community.adapters.openai",
    "ChatCompletion": "langchain_community.adapters.openai",
    "convert_messages_for_finetuning": "langchain_community.adapters.openai",
    "Completions": "langchain_community.adapters.openai",
    "Chat": "langchain_community.adapters.openai",
    "chat": "langchain_community.adapters.openai",
}

_import_attribute = create_importer(__file__, deprecated_lookups=MODULE_LOOKUP)


def __getattr__(name: str) -> Any:
    """Look up attributes dynamically."""
    return _import_attribute(name)


__all__ = [
    "Chat",
    "ChatCompletion",
    "ChatCompletionChunk",
    "ChatCompletions",
    "Choice",
    "ChoiceChunk",
    "Completions",
    "IndexableBaseModel",
    "chat",
    "convert_dict_to_message",
    "convert_message_to_dict",
    "convert_messages_for_finetuning",
    "convert_openai_messages",
]

Subdomains

Dependencies

  • langchain_classic._api
  • langchain_community.adapters.openai
  • typing

Frequently Asked Questions

What does openai.py do?
openai.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in openai.py?
openai.py defines 2 function(s): __getattr__, langchain_community.
What does openai.py depend on?
openai.py imports 3 module(s): langchain_classic._api, langchain_community.adapters.openai, typing.
Where is openai.py in the architecture?
openai.py is located at libs/langchain/langchain_classic/adapters/openai.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/langchain/langchain_classic/adapters).

Analyze Your Own Codebase

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

Try Supermodel Free