Skip to content

Commit

Permalink
[docs]: LLM integration pages (langchain-ai#25005)
Browse files Browse the repository at this point in the history
  • Loading branch information
isahers1 authored Aug 13, 2024
1 parent 9d08369 commit 0478f7f
Show file tree
Hide file tree
Showing 5 changed files with 244 additions and 126 deletions.
10 changes: 1 addition & 9 deletions docs/docs/integrations/llms/anthropic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"# AnthropicLLM\n",
"\n",
":::caution\n",
"You are currently on a page documenting the use of Anthropic legacy Claude 2 models as [text completion models](/docs/concepts/#llms). The latest and most popular Anthropic models are [chat completion models](/docs/concepts/#chat-models).\n",
"You are currently on a page documenting the use of Anthropic legacy Claude 2 models as [text completion models](/docs/concepts/#llms). The latest and most popular Anthropic models are [chat completion models](/docs/concepts/#chat-models), and the text completion models have been deprecated.\n",
"\n",
"You are probably looking for [this page instead](/docs/integrations/chat/anthropic/).\n",
":::\n",
Expand Down Expand Up @@ -115,14 +115,6 @@
"\n",
"chain.invoke({\"question\": \"What is LangChain?\"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a52f765c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
64 changes: 42 additions & 22 deletions docs/docs/integrations/llms/cohere.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
"\n",
">[Cohere](https://cohere.ai/about) is a Canadian startup that provides natural language processing models that help companies improve human-machine interactions.\n",
"\n",
"Head to the [API reference](https://api.python.langchain.com/en/latest/llms/langchain_community.llms.cohere.Cohere.html) for detailed documentation of all attributes and methods."
"Head to the [API reference](https://api.python.langchain.com/en/latest/llms/langchain_community.llms.cohere.Cohere.html) for detailed documentation of all attributes and methods.\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/v0.2/docs/integrations/llms/cohere/) | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
"| [Cohere](https://api.python.langchain.com/en/latest/llms/langchain_community.llms.cohere.Cohere.html) | [langchain_community](https://api.python.langchain.com/en/latest/community_api_reference.html) | ❌ | beta | ✅ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain_community?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain_community?style=flat-square&label=%20) |\n"
]
},
{
Expand All @@ -29,34 +36,43 @@
"\n",
"The integration lives in the `langchain-community` package. We also need to install the `cohere` package itself. We can install these with:\n",
"\n",
"```bash\n",
"pip install -U langchain-community langchain-cohere\n",
"```\n",
"### Credentials\n",
"\n",
"We'll also need to get a [Cohere API key](https://cohere.com/) and set the `COHERE_API_KEY` environment variable:"
"We'll need to get a [Cohere API key](https://cohere.com/) and set the `COHERE_API_KEY` environment variable:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "3f5dc9d7-65e3-4b5b-9086-3327d016cfe0",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" ········\n"
]
}
],
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"os.environ[\"COHERE_API_KEY\"] = getpass.getpass()"
"if \"COHERE_API_KEY\" not in os.environ:\n",
" os.environ[\"COHERE_API_KEY\"] = getpass.getpass()"
]
},
{
"cell_type": "markdown",
"id": "ff211537",
"metadata": {},
"source": [
"### Installation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "318454f9",
"metadata": {},
"outputs": [],
"source": [
"pip install -U langchain-community langchain-cohere"
]
},
{
Expand All @@ -83,7 +99,7 @@
"id": "0b4e02bf-5beb-48af-a2a2-52cbcd8ebed6",
"metadata": {},
"source": [
"## Usage\n",
"## Invocation\n",
"\n",
"Cohere supports all [LLM](/docs/how_to#llms) functionality:"
]
Expand Down Expand Up @@ -199,6 +215,8 @@
"id": "39198f7d-6fc8-4662-954a-37ad38c4bec4",
"metadata": {},
"source": [
"## Chaining\n",
"\n",
"You can also easily combine with a prompt template for easy structuring of user input. We can do this using [LCEL](/docs/concepts#langchain-expression-language-lcel)"
]
},
Expand Down Expand Up @@ -237,12 +255,14 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4797d719",
"cell_type": "markdown",
"id": "ac5fcbed",
"metadata": {},
"outputs": [],
"source": []
"source": [
"## API reference\n",
"\n",
"For detailed documentation of all `Cohere` llm features and configurations head to the API reference: https://api.python.langchain.com/en/latest/llms/langchain_community.llms.cohere.Cohere.html"
]
}
],
"metadata": {
Expand Down
105 changes: 78 additions & 27 deletions docs/docs/integrations/llms/fireworks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
"\n",
">[Fireworks](https://app.fireworks.ai/) accelerates product development on generative AI by creating an innovative AI experiment and production platform. \n",
"\n",
"This example goes over how to use LangChain to interact with `Fireworks` models."
"This example goes over how to use LangChain to interact with `Fireworks` models.\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"| Class | Package | Local | Serializable | [JS support](https://js.langchain.com/v0.1/docs/integrations/llms/fireworks/) | Package downloads | Package latest |\n",
"| :--- | :--- | :---: | :---: | :---: | :---: | :---: |\n",
"| [Fireworks](https://api.python.langchain.com/en/latest/llms/langchain_fireworks.llms.Fireworks.html#langchain_fireworks.llms.Fireworks) | [langchain_fireworks](https://api.python.langchain.com/en/latest/fireworks_api_reference.html) | ❌ | ❌ | ✅ | ![PyPI - Downloads](https://img.shields.io/pypi/dm/langchain_fireworks?style=flat-square&label=%20) | ![PyPI - Version](https://img.shields.io/pypi/v/langchain_fireworks?style=flat-square&label=%20) |"
]
},
{
Expand All @@ -24,47 +31,72 @@
"id": "fb345268",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "ccff689e",
"metadata": {},
"source": [
"%pip install -qU langchain-fireworks"
"## Setup\n",
"\n",
"### Credentials \n",
"\n",
"Sign in to [Fireworks AI](http://fireworks.ai) for the an API Key to access our models, and make sure it is set as the `FIREWORKS_API_KEY` environment variable.\n",
"3. Set up your model using a model id. If the model is not set, the default model is fireworks-llama-v2-7b-chat. See the full, most up-to-date model list on [fireworks.ai](https://fireworks.ai)."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "60b6dbb2",
"execution_count": 3,
"id": "9ca87a2e",
"metadata": {},
"outputs": [],
"source": [
"from langchain_fireworks import Fireworks"
"import getpass\n",
"import os\n",
"\n",
"if \"FIREWORKS_API_KEY\" not in os.environ:\n",
" os.environ[\"FIREWORKS_API_KEY\"] = getpass.getpass(\"Fireworks API Key:\")"
]
},
{
"cell_type": "markdown",
"id": "ccff689e",
"id": "e42ced7e",
"metadata": {},
"source": [
"# Setup\n",
"### Installation\n",
"\n",
"1. Make sure the `langchain-fireworks` package is installed in your environment.\n",
"2. Sign in to [Fireworks AI](http://fireworks.ai) for the an API Key to access our models, and make sure it is set as the `FIREWORKS_API_KEY` environment variable.\n",
"3. Set up your model using a model id. If the model is not set, the default model is fireworks-llama-v2-7b-chat. See the full, most up-to-date model list on [fireworks.ai](https://fireworks.ai)."
"You need to install the `langchain_fireworks` python package for the rest of the notebook to work."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "9ca87a2e",
"execution_count": null,
"id": "ca824723",
"metadata": {},
"outputs": [],
"source": [
"%pip install -qU langchain-fireworks"
]
},
{
"cell_type": "markdown",
"id": "acc24d0c",
"metadata": {},
"source": [
"## Instantiation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d285fd7f",
"metadata": {},
"outputs": [],
"source": [
"import getpass\n",
"import os\n",
"\n",
"from langchain_fireworks import Fireworks\n",
"\n",
"if \"FIREWORKS_API_KEY\" not in os.environ:\n",
" os.environ[\"FIREWORKS_API_KEY\"] = getpass.getpass(\"Fireworks API Key:\")\n",
"\n",
"# Initialize a Fireworks model\n",
"llm = Fireworks(\n",
" model=\"accounts/fireworks/models/mixtral-8x7b-instruct\",\n",
Expand All @@ -74,10 +106,10 @@
},
{
"cell_type": "markdown",
"id": "acc24d0c",
"id": "a4c29f7b",
"metadata": {},
"source": [
"# Calling the Model Directly\n",
"## Invocation\n",
"\n",
"You can call the model directly with string prompts to get completions."
]
Expand All @@ -98,11 +130,18 @@
}
],
"source": [
"# Single prompt\n",
"output = llm.invoke(\"Who's the best quarterback in the NFL?\")\n",
"print(output)"
]
},
{
"cell_type": "markdown",
"id": "b0283343",
"metadata": {},
"source": [
"### Invoking with multiple prompts"
]
},
{
"cell_type": "code",
"execution_count": 5,
Expand All @@ -128,6 +167,14 @@
"print(output.generations)"
]
},
{
"cell_type": "markdown",
"id": "f18f5717",
"metadata": {},
"source": [
"### Invoking with additional parameters"
]
},
{
"cell_type": "code",
"execution_count": 7,
Expand Down Expand Up @@ -158,7 +205,7 @@
"id": "137662a6",
"metadata": {},
"source": [
"# Simple Chain with Non-Chat Model"
"## Chaining"
]
},
{
Expand Down Expand Up @@ -206,6 +253,8 @@
"id": "d0a29826",
"metadata": {},
"source": [
"## Streaming\n",
"\n",
"You can stream the output, if you want."
]
},
Expand Down Expand Up @@ -233,12 +282,14 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fcc0eecb",
"cell_type": "markdown",
"id": "692c5e76",
"metadata": {},
"outputs": [],
"source": []
"source": [
"## API reference\n",
"\n",
"For detailed documentation of all `Fireworks` LLM features and configurations head to the API reference: https://api.python.langchain.com/en/latest/llms/langchain_fireworks.llms.Fireworks.html#langchain_fireworks.llms.Fireworks"
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 0478f7f

Please sign in to comment.