Skip to content

Commit

Permalink
docs: use standard openai params (#20160)
Browse files Browse the repository at this point in the history
Part of #20085
  • Loading branch information
baskaryan authored and hinthornw committed Apr 26, 2024
1 parent 236f76d commit fb24129
Show file tree
Hide file tree
Showing 44 changed files with 58 additions and 58 deletions.
2 changes: 1 addition & 1 deletion cookbook/autogpt/marathon_times.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
},
"outputs": [],
"source": [
"llm = ChatOpenAI(model_name=\"gpt-4\", temperature=1.0)"
"llm = ChatOpenAI(model=\"gpt-4\", temperature=1.0)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion cookbook/elasticsearch_db_qa.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"metadata": {},
"outputs": [],
"source": [
"llm = ChatOpenAI(model_name=\"gpt-4\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-4\", temperature=0)\n",
"chain = ElasticsearchDatabaseChain.from_llm(llm=llm, database=db, verbose=True)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion cookbook/langgraph_crag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
" prompt = hub.pull(\"rlm/rag-prompt\")\n",
"\n",
" # LLM\n",
" llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0, streaming=True)\n",
" llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0, streaming=True)\n",
"\n",
" # Post-processing\n",
" def format_docs(docs):\n",
Expand Down
2 changes: 1 addition & 1 deletion cookbook/langgraph_self_rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
" prompt = hub.pull(\"rlm/rag-prompt\")\n",
"\n",
" # LLM\n",
" llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
" llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"\n",
" # Post-processing\n",
" def format_docs(docs):\n",
Expand Down
2 changes: 1 addition & 1 deletion cookbook/press_releases.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"from langchain.retrievers import KayAiRetriever\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo\")\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo\")\n",
"retriever = KayAiRetriever.create(\n",
" dataset_id=\"company\", data_types=[\"PressRelease\"], num_contexts=6\n",
")\n",
Expand Down
2 changes: 1 addition & 1 deletion cookbook/retrieval_in_sql.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
"db = SQLDatabase.from_uri(\n",
" CONNECTION_STRING\n",
") # We reconnect to db so the new columns are loaded as well.\n",
"llm = ChatOpenAI(model_name=\"gpt-4\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-4\", temperature=0)\n",
"\n",
"sql_query_chain = (\n",
" RunnablePassthrough.assign(schema=get_schema)\n",
Expand Down
2 changes: 1 addition & 1 deletion cookbook/twitter-the-algorithm-analysis-deeplake.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3811,7 +3811,7 @@
"from langchain.chains import ConversationalRetrievalChain\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo-0613\") # switch to 'gpt-4'\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo-0613\") # switch to 'gpt-4'\n",
"qa = ConversationalRetrievalChain.from_llm(model, retriever=retriever)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion cookbook/two_agent_debate_tools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
" DialogueAgentWithTools(\n",
" name=name,\n",
" system_message=SystemMessage(content=system_message),\n",
" model=ChatOpenAI(model_name=\"gpt-4\", temperature=0.2),\n",
" model=ChatOpenAI(model=\"gpt-4\", temperature=0.2),\n",
" tool_names=tools,\n",
" top_k_results=2,\n",
" )\n",
Expand Down
2 changes: 1 addition & 1 deletion cookbook/wikibase_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@
"source": [
"from langchain_openai import ChatOpenAI\n",
"\n",
"llm = ChatOpenAI(model_name=\"gpt-4\", temperature=0)"
"llm = ChatOpenAI(model=\"gpt-4\", temperature=0)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/get_started/quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ from langchain_openai import ChatOpenAI
llm = ChatOpenAI()
```

If you'd prefer not to set an environment variable you can pass the key in directly via the `openai_api_key` named parameter when initiating the OpenAI LLM class:
If you'd prefer not to set an environment variable you can pass the key in directly via the `api_key` named parameter when initiating the OpenAI LLM class:

```python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(openai_api_key="...")
llm = ChatOpenAI(api_key="...")
```

</TabItem>
Expand Down Expand Up @@ -509,7 +509,7 @@ from langchain.agents import AgentExecutor
# Get the prompt to use - you can modify this!
prompt = hub.pull("hwchase17/openai-functions-agent")

# You need to set OPENAI_API_KEY environment variable or pass it as argument `openai_api_key`.
# You need to set OPENAI_API_KEY environment variable or pass it as argument `api_key`.
llm = ChatOpenAI(model="gpt-3.5-turbo", temperature=0)
agent = create_openai_functions_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/development/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Let's suppose we have a simple agent, and want to visualize the actions it takes
from langchain.agents import AgentType, initialize_agent, load_tools
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model_name="gpt-4", temperature=0)
llm = ChatOpenAI(model="gpt-4", temperature=0)
tools = load_tools(["ddg-search", "llm-math"], llm=llm)
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/guides/productionization/fallbacks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
" ]\n",
")\n",
"# Here we're going to use a bad model name to easily create a chain that will error\n",
"chat_model = ChatOpenAI(model_name=\"gpt-fake\")\n",
"chat_model = ChatOpenAI(model=\"gpt-fake\")\n",
"bad_chain = chat_prompt | chat_model | StrOutputParser()"
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
"source": [
"# Build a QA chain\n",
"qa_chain = RetrievalQA.from_chain_type(\n",
" llm=ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0),\n",
" llm=ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0),\n",
" chain_type=\"stuff\",\n",
" retriever=vectordb.as_retriever(),\n",
")"
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/integrations/providers/log10.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ messages = [
HumanMessage(content="Ping?"),
]

llm = ChatOpenAI(model_name="gpt-3.5-turbo", callbacks=[log10_callback])
llm = ChatOpenAI(model="gpt-3.5-turbo", callbacks=[log10_callback])
```

[Log10 + Langchain + Logs docs](https://github.com/log10-io/log10/blob/main/logging.md#langchain-logger)
Expand All @@ -55,7 +55,7 @@ messages = [
HumanMessage(content="Ping?"),
]

llm = ChatOpenAI(model_name="gpt-3.5-turbo", callbacks=[log10_callback], temperature=0.5, tags=["test"])
llm = ChatOpenAI(model="gpt-3.5-turbo", callbacks=[log10_callback], temperature=0.5, tags=["test"])
completion = llm.predict_messages(messages, tags=["foobar"])
print(completion)

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/retrievers/arxiv.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
"from langchain.chains import ConversationalRetrievalChain\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo\") # switch to 'gpt-4'\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo\") # switch to 'gpt-4'\n",
"qa = ConversationalRetrievalChain.from_llm(model, retriever=retriever)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/retrievers/kay.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
"from langchain.chains import ConversationalRetrievalChain\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo\")\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo\")\n",
"qa = ConversationalRetrievalChain.from_llm(model, retriever=retriever)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/retrievers/outline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"from langchain.chains import ConversationalRetrievalChain\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo\")\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo\")\n",
"qa = ConversationalRetrievalChain.from_llm(model, retriever=retriever)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/retrievers/sec_filings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"from langchain_community.retrievers import KayAiRetriever\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo\")\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo\")\n",
"retriever = KayAiRetriever.create(\n",
" dataset_id=\"company\", data_types=[\"10-K\", \"10-Q\"], num_contexts=6\n",
")\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/retrievers/wikipedia.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
"from langchain.chains import ConversationalRetrievalChain\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo\") # switch to 'gpt-4'\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo\") # switch to 'gpt-4'\n",
"qa = ConversationalRetrievalChain.from_llm(model, retriever=retriever)"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/vectorstores/jaguar.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"prompt = ChatPromptTemplate.from_template(template)\n",
"\n",
"\"\"\" Obtain a Large Language Model \"\"\"\n",
"LLM = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
"LLM = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"\n",
"\"\"\" Create a chain for the RAG flow \"\"\"\n",
"rag_chain = (\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
"metadata": {},
"outputs": [],
"source": [
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"qa_chain = RetrievalQA.from_chain_type(llm, retriever=vector_db.as_retriever())"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/integrations/vectorstores/sap_hanavector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@
"source": [
"from langchain.chains import ConversationalRetrievalChain\n",
"\n",
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\")\n",
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\")\n",
"memory = ConversationBufferMemory(\n",
" memory_key=\"chat_history\", output_key=\"answer\", return_messages=True\n",
")\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/integrations/vectorstores/weaviate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@
"source": [
"from langchain_community.chat_models import ChatOpenAI\n",
"\n",
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"llm.predict(\"What did the president say about Justice Breyer\")"
]
},
Expand Down Expand Up @@ -824,7 +824,7 @@
"source": [
"from langchain_community.chat_models import ChatOpenAI\n",
"\n",
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)"
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/modules/data_connection/text_embedding/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ Accessing the API requires an API key, which you can get by creating an account
export OPENAI_API_KEY="..."
```

If you'd prefer not to set an environment variable you can pass the key in directly via the `openai_api_key` named parameter when initiating the OpenAI LLM class:
If you'd prefer not to set an environment variable you can pass the key in directly via the `api_key` named parameter when initiating the OpenAI LLM class:

```python
from langchain_openai import OpenAIEmbeddings

embeddings_model = OpenAIEmbeddings(openai_api_key="...")
embeddings_model = OpenAIEmbeddings(api_key="...")
```

Otherwise you can initialize without any params:
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/model_io/chat/quick_start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"source": [
"```{=mdx}\n",
"<ChatModelTabs\n",
" openaiParams={`model=\"gpt-3.5-turbo-0125\", openai_api_key=\"...\"`}\n",
" openaiParams={`model=\"gpt-3.5-turbo-0125\", api_key=\"...\"`}\n",
" anthropicParams={`model=\"claude-3-sonnet-20240229\", anthropic_api_key=\"...\"`}\n",
" fireworksParams={`model=\"accounts/fireworks/models/mixtral-8x7b-instruct\", fireworks_api_key=\"...\"`}\n",
" mistralParams={`model=\"mistral-large-latest\", mistral_api_key=\"...\"`}\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/modules/model_io/chat/token_usage_tracking.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"metadata": {},
"outputs": [],
"source": [
"llm = ChatOpenAI(model_name=\"gpt-4\")"
"llm = ChatOpenAI(model=\"gpt-4\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/modules/model_io/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ llm = OpenAI()
chat_model = ChatOpenAI(model="gpt-3.5-turbo-0125")
```

If you'd prefer not to set an environment variable you can pass the key in directly via the `openai_api_key` named parameter when initiating the OpenAI LLM class:
If you'd prefer not to set an environment variable you can pass the key in directly via the `api_key` named parameter when initiating the OpenAI LLM class:

```python
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(openai_api_key="...")
llm = ChatOpenAI(api_key="...")
```

Both `llm` and `chat_model` are objects that represent configuration for a particular model.
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/modules/model_io/llms/quick_start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"export OPENAI_API_KEY=\"...\"\n",
"```\n",
"\n",
"If you'd prefer not to set an environment variable you can pass the key in directly via the `openai_api_key` named parameter when initiating the OpenAI LLM class:\n",
"If you'd prefer not to set an environment variable you can pass the key in directly via the `api_key` named parameter when initiating the OpenAI LLM class:\n",
"\n"
]
},
Expand All @@ -53,7 +53,7 @@
"source": [
"from langchain_openai import OpenAI\n",
"\n",
"llm = OpenAI(openai_api_key=\"...\")"
"llm = OpenAI(api_key=\"...\")"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/modules/model_io/quick_start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ llm = OpenAI()
chat_model = ChatOpenAI(model="gpt-3.5-turbo-0125")
```

If you'd prefer not to set an environment variable you can pass the key in directly via the `openai_api_key` named parameter when initiating the OpenAI LLM class:
If you'd prefer not to set an environment variable you can pass the key in directly via the `api_key` named parameter when initiating the OpenAI LLM class:

```python
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(openai_api_key="...")
llm = ChatOpenAI(api_key="...")
```

</TabItem>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/use_cases/code_understanding.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
"from langchain_core.prompts import ChatPromptTemplate\n",
"from langchain_openai import ChatOpenAI\n",
"\n",
"llm = ChatOpenAI(model_name=\"gpt-4\")\n",
"llm = ChatOpenAI(model=\"gpt-4\")\n",
"\n",
"# First we need a prompt that we can pass into an LLM to generate this search query\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/use_cases/data_generation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@
"outputs": [],
"source": [
"# LLM\n",
"model = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0.7)\n",
"model = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0.7)\n",
"chain = create_data_generation_chain(model)"
]
},
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/use_cases/question_answering/chat_history.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"# Retrieve and generate using the relevant snippets of the blog.\n",
"retriever = vectorstore.as_retriever()\n",
"prompt = hub.pull(\"rlm/rag-prompt\")\n",
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"\n",
"\n",
"def format_docs(docs):\n",
Expand Down Expand Up @@ -417,7 +417,7 @@
"from langchain_openai import ChatOpenAI, OpenAIEmbeddings\n",
"from langchain_text_splitters import RecursiveCharacterTextSplitter\n",
"\n",
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"\n",
"\n",
"### Construct retriever ###\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/use_cases/question_answering/sources.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"# Retrieve and generate using the relevant snippets of the blog.\n",
"retriever = vectorstore.as_retriever()\n",
"prompt = hub.pull(\"rlm/rag-prompt\")\n",
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"\n",
"\n",
"def format_docs(docs):\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/use_cases/question_answering/streaming.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
"# Retrieve and generate using the relevant snippets of the blog.\n",
"retriever = vectorstore.as_retriever()\n",
"prompt = hub.pull(\"rlm/rag-prompt\")\n",
"llm = ChatOpenAI(model_name=\"gpt-3.5-turbo\", temperature=0)\n",
"llm = ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0)\n",
"\n",
"\n",
"def format_docs(docs):\n",
Expand Down
2 changes: 1 addition & 1 deletion libs/community/langchain_community/chat_models/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class ChatOpenAI(BaseChatModel):
.. code-block:: python
from langchain_community.chat_models import ChatOpenAI
openai = ChatOpenAI(model_name="gpt-3.5-turbo")
openai = ChatOpenAI(model="gpt-3.5-turbo")
"""

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PromptLayerChatOpenAI(ChatOpenAI):
.. code-block:: python
from langchain_community.chat_models import PromptLayerChatOpenAI
openai = PromptLayerChatOpenAI(model_name="gpt-3.5-turbo")
openai = PromptLayerChatOpenAI(model="gpt-3.5-turbo")
"""

pl_tags: Optional[List[str]]
Expand Down
2 changes: 1 addition & 1 deletion libs/langchain/langchain/chains/combine_documents/stuff.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def create_stuff_documents_chain(
prompt = ChatPromptTemplate.from_messages(
[("system", "What are everyone's favorite colors:\\n\\n{context}")]
)
llm = ChatOpenAI(model_name="gpt-3.5-turbo")
llm = ChatOpenAI(model="gpt-3.5-turbo")
chain = create_stuff_documents_chain(llm, prompt)
docs = [
Expand Down
Loading

0 comments on commit fb24129

Please sign in to comment.