MCPcopy
hub / github.com/langchain-ai/langchain / OpenAI

Class OpenAI

libs/community/langchain_community/llms/openai.py:733–756  ·  view source on GitHub ↗

OpenAI large language models. To use, you should have the ``openai`` python package installed, and the environment variable ``OPENAI_API_KEY`` set with your API key. Any parameters that are valid to be passed to the openai.create call can be passed in, even if not explicitly saved

Source from the content-addressed store, hash-verified

731 since="0.0.10", removal="0.3.0", alternative_import="langchain_openai.OpenAI"
732)
733class OpenAI(BaseOpenAI):
734 """OpenAI large language models.
735
736 To use, you should have the ``openai`` python package installed, and the
737 environment variable ``OPENAI_API_KEY`` set with your API key.
738
739 Any parameters that are valid to be passed to the openai.create call can be passed
740 in, even if not explicitly saved on this class.
741
742 Example:
743 .. code-block:: python
744
745 from langchain_community.llms import OpenAI
746 openai = OpenAI(model_name="gpt-3.5-turbo-instruct")
747 """
748
749 @classmethod
750 def get_lc_namespace(cls) -> List[str]:
751 """Get the namespace of the langchain object."""
752 return ["langchain", "llms", "openai"]
753
754 @property
755 def _invocation_params(self) -> Dict[str, Any]:
756 return {**{"model": self.model_name}, **super()._invocation_params}
757
758
759@deprecated(

Callers 15

chain.pyFile · 0.90
chain.pyFile · 0.90
chain.pyFile · 0.90
agent.pyFile · 0.90
BaseVectorStoreToolClass · 0.90
_get_default_llm_chainFunction · 0.90
test_llmFunction · 0.90
test_llm_on_chat_datasetFunction · 0.90
test_llm_on_llm_datasetFunction · 0.90

Calls

no outgoing calls

Tested by 15

test_llmFunction · 0.72
test_llm_on_chat_datasetFunction · 0.72
test_llm_on_llm_datasetFunction · 0.72
test_openai_callbackFunction · 0.72
test_tracing_sequentialFunction · 0.72
test_tracing_concurrentFunction · 0.72