mirror of https://github.com/hwchase17/langchain
docs: `ecosystem/integrations` update 5 (#5752)
- added missed integration to `docs/ecosystem/integrations/` - updated notebooks to consistent format: changed titles, file names; added descriptions #### Who can review? @hwchase17 @dev2049pull/5761/head
parent
aea090045b
commit
92a5f00ffb
@ -0,0 +1,26 @@
|
|||||||
|
# Anthropic
|
||||||
|
|
||||||
|
>[Anthropic](https://en.wikipedia.org/wiki/Anthropic) is an American artificial intelligence (AI) startup and
|
||||||
|
> public-benefit corporation, founded by former members of OpenAI. `Anthropic` specializes in developing general AI
|
||||||
|
> systems and language models, with a company ethos of responsible AI usage.
|
||||||
|
> `Anthropic` develops a chatbot, named `Claude`. Similar to `ChatGPT`, `Claude` uses a messaging
|
||||||
|
> interface where users can submit questions or requests and receive highly detailed and relevant responses.
|
||||||
|
|
||||||
|
## Installation and Setup
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install anthropic
|
||||||
|
```
|
||||||
|
|
||||||
|
See the [setup documentation](https://console.anthropic.com/docs/access).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Chat Models
|
||||||
|
|
||||||
|
See a [usage example](../modules/models/chat/integrations/anthropic.ipynb)
|
||||||
|
|
||||||
|
```python
|
||||||
|
from langchain.chat_models import ChatAnthropic
|
||||||
|
```
|
@ -0,0 +1,24 @@
|
|||||||
|
# Google Vertex AI
|
||||||
|
|
||||||
|
>[Vertex AI](https://cloud.google.com/vertex-ai/docs/start/introduction-unified-platform) is a machine learning (ML)
|
||||||
|
> platform that lets you train and deploy ML models and AI applications.
|
||||||
|
> `Vertex AI` combines data engineering, data science, and ML engineering workflows, enabling your teams to
|
||||||
|
> collaborate using a common toolset.
|
||||||
|
|
||||||
|
## Installation and Setup
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install google-cloud-aiplatform
|
||||||
|
```
|
||||||
|
|
||||||
|
See the [setup instructions](../modules/models/chat/integrations/google_vertex_ai_palm.ipynb)
|
||||||
|
|
||||||
|
|
||||||
|
## Chat Models
|
||||||
|
|
||||||
|
See a [usage example](../modules/models/chat/integrations/google_vertex_ai_palm.ipynb)
|
||||||
|
|
||||||
|
```python
|
||||||
|
from langchain.chat_models import ChatVertexAI
|
||||||
|
```
|
@ -0,0 +1,22 @@
|
|||||||
|
# Tensorflow Hub
|
||||||
|
|
||||||
|
>[TensorFlow Hub](https://www.tensorflow.org/hub) is a repository of trained machine learning models ready for fine-tuning and deployable anywhere.
|
||||||
|
|
||||||
|
>[TensorFlow Hub](https://tfhub.dev/) lets you search and discover hundreds of trained, ready-to-deploy machine learning models in one place.
|
||||||
|
|
||||||
|
## Installation and Setup
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install tensorflow-hub
|
||||||
|
pip install tensorflow_text
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Text Embedding Models
|
||||||
|
|
||||||
|
See a [usage example](../modules/models/text_embedding/examples/tensorflowhub.ipynb)
|
||||||
|
|
||||||
|
```python
|
||||||
|
from langchain.embeddings import TensorflowHubEmbeddings
|
||||||
|
```
|
@ -1,222 +1,233 @@
|
|||||||
{
|
{
|
||||||
"nbformat": 4,
|
"cells": [
|
||||||
"nbformat_minor": 0,
|
{
|
||||||
"metadata": {
|
"cell_type": "markdown",
|
||||||
"colab": {
|
"metadata": {
|
||||||
"provenance": []
|
"id": "mesCTyhnJkNS"
|
||||||
},
|
},
|
||||||
"kernelspec": {
|
"source": [
|
||||||
"name": "python3",
|
"# Prediction Guard\n",
|
||||||
"display_name": "Python 3"
|
"\n",
|
||||||
},
|
">[Prediction Guard](https://docs.predictionguard.com/) gives a quick and easy access to state-of-the-art open and closed access LLMs, without needing to spend days and weeks figuring out all of the implementation details, managing a bunch of different API specs, and setting up the infrastructure for model deployments."
|
||||||
"language_info": {
|
]
|
||||||
"name": "python"
|
},
|
||||||
}
|
{
|
||||||
},
|
"cell_type": "code",
|
||||||
"cells": [
|
"execution_count": null,
|
||||||
{
|
"metadata": {
|
||||||
"cell_type": "code",
|
"id": "3RqWPav7AtKL"
|
||||||
"execution_count": null,
|
},
|
||||||
"metadata": {
|
"outputs": [],
|
||||||
"id": "3RqWPav7AtKL"
|
"source": [
|
||||||
},
|
"! pip install predictionguard langchain"
|
||||||
"outputs": [],
|
]
|
||||||
"source": [
|
},
|
||||||
"! pip install predictionguard langchain"
|
{
|
||||||
]
|
"cell_type": "code",
|
||||||
},
|
"execution_count": null,
|
||||||
{
|
"metadata": {
|
||||||
"cell_type": "code",
|
"id": "2xe8JEUwA7_y"
|
||||||
"source": [
|
},
|
||||||
"import os\n",
|
"outputs": [],
|
||||||
"\n",
|
"source": [
|
||||||
"import predictionguard as pg\n",
|
"import os\n",
|
||||||
"from langchain.llms import PredictionGuard\n",
|
"\n",
|
||||||
"from langchain import PromptTemplate, LLMChain"
|
"import predictionguard as pg\n",
|
||||||
],
|
"from langchain.llms import PredictionGuard\n",
|
||||||
"metadata": {
|
"from langchain import PromptTemplate, LLMChain"
|
||||||
"id": "2xe8JEUwA7_y"
|
]
|
||||||
},
|
},
|
||||||
"execution_count": null,
|
{
|
||||||
"outputs": []
|
"cell_type": "code",
|
||||||
},
|
"execution_count": null,
|
||||||
{
|
"metadata": {
|
||||||
"cell_type": "markdown",
|
"id": "kp_Ymnx1SnDG"
|
||||||
"source": [
|
},
|
||||||
"# Basic LLM usage\n",
|
"outputs": [],
|
||||||
"\n"
|
"source": [
|
||||||
],
|
"# Optional, add your OpenAI API Key. This is optional, as Prediction Guard allows\n",
|
||||||
"metadata": {
|
"# you to access all the latest open access models (see https://docs.predictionguard.com)\n",
|
||||||
"id": "mesCTyhnJkNS"
|
"os.environ[\"OPENAI_API_KEY\"] = \"<your OpenAI api key>\"\n",
|
||||||
}
|
"\n",
|
||||||
},
|
"# Your Prediction Guard API key. Get one at predictionguard.com\n",
|
||||||
{
|
"os.environ[\"PREDICTIONGUARD_TOKEN\"] = \"<your Prediction Guard access token>\""
|
||||||
"cell_type": "code",
|
]
|
||||||
"source": [
|
},
|
||||||
"# Optional, add your OpenAI API Key. This is optional, as Prediction Guard allows\n",
|
{
|
||||||
"# you to access all the latest open access models (see https://docs.predictionguard.com)\n",
|
"cell_type": "code",
|
||||||
"os.environ[\"OPENAI_API_KEY\"] = \"<your OpenAI api key>\"\n",
|
"execution_count": null,
|
||||||
"\n",
|
"metadata": {
|
||||||
"# Your Prediction Guard API key. Get one at predictionguard.com\n",
|
"id": "Ua7Mw1N4HcER"
|
||||||
"os.environ[\"PREDICTIONGUARD_TOKEN\"] = \"<your Prediction Guard access token>\""
|
},
|
||||||
],
|
"outputs": [],
|
||||||
"metadata": {
|
"source": [
|
||||||
"id": "kp_Ymnx1SnDG"
|
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
||||||
},
|
]
|
||||||
"execution_count": null,
|
},
|
||||||
"outputs": []
|
{
|
||||||
},
|
"cell_type": "code",
|
||||||
{
|
"execution_count": null,
|
||||||
"cell_type": "code",
|
"metadata": {
|
||||||
"source": [
|
"id": "Qo2p5flLHxrB"
|
||||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
},
|
||||||
],
|
"outputs": [],
|
||||||
"metadata": {
|
"source": [
|
||||||
"id": "Ua7Mw1N4HcER"
|
"pgllm(\"Tell me a joke\")"
|
||||||
},
|
]
|
||||||
"execution_count": null,
|
},
|
||||||
"outputs": []
|
{
|
||||||
},
|
"cell_type": "markdown",
|
||||||
{
|
"metadata": {
|
||||||
"cell_type": "code",
|
"id": "EyBYaP_xTMXH"
|
||||||
"source": [
|
},
|
||||||
"pgllm(\"Tell me a joke\")"
|
"source": [
|
||||||
],
|
"# Control the output structure/ type of LLMs"
|
||||||
"metadata": {
|
]
|
||||||
"id": "Qo2p5flLHxrB"
|
},
|
||||||
},
|
{
|
||||||
"execution_count": null,
|
"cell_type": "code",
|
||||||
"outputs": []
|
"execution_count": null,
|
||||||
},
|
"metadata": {
|
||||||
{
|
"id": "55uxzhQSTPqF"
|
||||||
"cell_type": "markdown",
|
},
|
||||||
"source": [
|
"outputs": [],
|
||||||
"# Control the output structure/ type of LLMs"
|
"source": [
|
||||||
],
|
"template = \"\"\"Respond to the following query based on the context.\n",
|
||||||
"metadata": {
|
"\n",
|
||||||
"id": "EyBYaP_xTMXH"
|
"Context: EVERY comment, DM + email suggestion has led us to this EXCITING announcement! 🎉 We have officially added TWO new candle subscription box options! 📦\n",
|
||||||
}
|
"Exclusive Candle Box - $80 \n",
|
||||||
},
|
"Monthly Candle Box - $45 (NEW!)\n",
|
||||||
{
|
"Scent of The Month Box - $28 (NEW!)\n",
|
||||||
"cell_type": "code",
|
"Head to stories to get ALLL the deets on each box! 👆 BONUS: Save 50% on your first box with code 50OFF! 🎉\n",
|
||||||
"source": [
|
"\n",
|
||||||
"template = \"\"\"Respond to the following query based on the context.\n",
|
"Query: {query}\n",
|
||||||
"\n",
|
"\n",
|
||||||
"Context: EVERY comment, DM + email suggestion has led us to this EXCITING announcement! 🎉 We have officially added TWO new candle subscription box options! 📦\n",
|
"Result: \"\"\"\n",
|
||||||
"Exclusive Candle Box - $80 \n",
|
"prompt = PromptTemplate(template=template, input_variables=[\"query\"])"
|
||||||
"Monthly Candle Box - $45 (NEW!)\n",
|
]
|
||||||
"Scent of The Month Box - $28 (NEW!)\n",
|
},
|
||||||
"Head to stories to get ALLL the deets on each box! 👆 BONUS: Save 50% on your first box with code 50OFF! 🎉\n",
|
{
|
||||||
"\n",
|
"cell_type": "code",
|
||||||
"Query: {query}\n",
|
"execution_count": null,
|
||||||
"\n",
|
"metadata": {
|
||||||
"Result: \"\"\"\n",
|
"id": "yersskWbTaxU"
|
||||||
"prompt = PromptTemplate(template=template, input_variables=[\"query\"])"
|
},
|
||||||
],
|
"outputs": [],
|
||||||
"metadata": {
|
"source": [
|
||||||
"id": "55uxzhQSTPqF"
|
"# Without \"guarding\" or controlling the output of the LLM.\n",
|
||||||
},
|
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
||||||
"execution_count": null,
|
]
|
||||||
"outputs": []
|
},
|
||||||
},
|
{
|
||||||
{
|
"cell_type": "code",
|
||||||
"cell_type": "code",
|
"execution_count": null,
|
||||||
"source": [
|
"metadata": {
|
||||||
"# Without \"guarding\" or controlling the output of the LLM.\n",
|
"id": "PzxSbYwqTm2w"
|
||||||
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
},
|
||||||
],
|
"outputs": [],
|
||||||
"metadata": {
|
"source": [
|
||||||
"id": "yersskWbTaxU"
|
"# With \"guarding\" or controlling the output of the LLM. See the \n",
|
||||||
},
|
"# Prediction Guard docs (https://docs.predictionguard.com) to learn how to \n",
|
||||||
"execution_count": null,
|
"# control the output with integer, float, boolean, JSON, and other types and\n",
|
||||||
"outputs": []
|
"# structures.\n",
|
||||||
},
|
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\", \n",
|
||||||
{
|
" output={\n",
|
||||||
"cell_type": "code",
|
" \"type\": \"categorical\",\n",
|
||||||
"source": [
|
" \"categories\": [\n",
|
||||||
"# With \"guarding\" or controlling the output of the LLM. See the \n",
|
" \"product announcement\", \n",
|
||||||
"# Prediction Guard docs (https://docs.predictionguard.com) to learn how to \n",
|
" \"apology\", \n",
|
||||||
"# control the output with integer, float, boolean, JSON, and other types and\n",
|
" \"relational\"\n",
|
||||||
"# structures.\n",
|
" ]\n",
|
||||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\", \n",
|
" })\n",
|
||||||
" output={\n",
|
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
||||||
" \"type\": \"categorical\",\n",
|
]
|
||||||
" \"categories\": [\n",
|
},
|
||||||
" \"product announcement\", \n",
|
{
|
||||||
" \"apology\", \n",
|
"cell_type": "markdown",
|
||||||
" \"relational\"\n",
|
"metadata": {
|
||||||
" ]\n",
|
"id": "v3MzIUItJ8kV"
|
||||||
" })\n",
|
},
|
||||||
"pgllm(prompt.format(query=\"What kind of post is this?\"))"
|
"source": [
|
||||||
],
|
"# Chaining"
|
||||||
"metadata": {
|
]
|
||||||
"id": "PzxSbYwqTm2w"
|
},
|
||||||
},
|
{
|
||||||
"execution_count": null,
|
"cell_type": "code",
|
||||||
"outputs": []
|
"execution_count": null,
|
||||||
},
|
"metadata": {
|
||||||
{
|
"id": "pPegEZExILrT"
|
||||||
"cell_type": "markdown",
|
},
|
||||||
"source": [
|
"outputs": [],
|
||||||
"# Chaining"
|
"source": [
|
||||||
],
|
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
||||||
"metadata": {
|
]
|
||||||
"id": "v3MzIUItJ8kV"
|
},
|
||||||
}
|
{
|
||||||
},
|
"cell_type": "code",
|
||||||
{
|
"execution_count": null,
|
||||||
"cell_type": "code",
|
"metadata": {
|
||||||
"source": [
|
"id": "suxw62y-J-bg"
|
||||||
"pgllm = PredictionGuard(model=\"OpenAI-text-davinci-003\")"
|
},
|
||||||
],
|
"outputs": [],
|
||||||
"metadata": {
|
"source": [
|
||||||
"id": "pPegEZExILrT"
|
"template = \"\"\"Question: {question}\n",
|
||||||
},
|
"\n",
|
||||||
"execution_count": null,
|
"Answer: Let's think step by step.\"\"\"\n",
|
||||||
"outputs": []
|
"prompt = PromptTemplate(template=template, input_variables=[\"question\"])\n",
|
||||||
},
|
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
||||||
{
|
"\n",
|
||||||
"cell_type": "code",
|
"question = \"What NFL team won the Super Bowl in the year Justin Beiber was born?\"\n",
|
||||||
"source": [
|
"\n",
|
||||||
"template = \"\"\"Question: {question}\n",
|
"llm_chain.predict(question=question)"
|
||||||
"\n",
|
]
|
||||||
"Answer: Let's think step by step.\"\"\"\n",
|
},
|
||||||
"prompt = PromptTemplate(template=template, input_variables=[\"question\"])\n",
|
{
|
||||||
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
"cell_type": "code",
|
||||||
"\n",
|
"execution_count": null,
|
||||||
"question = \"What NFL team won the Super Bowl in the year Justin Beiber was born?\"\n",
|
"metadata": {
|
||||||
"\n",
|
"id": "l2bc26KHKr7n"
|
||||||
"llm_chain.predict(question=question)"
|
},
|
||||||
],
|
"outputs": [],
|
||||||
"metadata": {
|
"source": [
|
||||||
"id": "suxw62y-J-bg"
|
"template = \"\"\"Write a {adjective} poem about {subject}.\"\"\"\n",
|
||||||
},
|
"prompt = PromptTemplate(template=template, input_variables=[\"adjective\", \"subject\"])\n",
|
||||||
"execution_count": null,
|
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
||||||
"outputs": []
|
"\n",
|
||||||
},
|
"llm_chain.predict(adjective=\"sad\", subject=\"ducks\")"
|
||||||
{
|
]
|
||||||
"cell_type": "code",
|
},
|
||||||
"source": [
|
{
|
||||||
"template = \"\"\"Write a {adjective} poem about {subject}.\"\"\"\n",
|
"cell_type": "code",
|
||||||
"prompt = PromptTemplate(template=template, input_variables=[\"adjective\", \"subject\"])\n",
|
"execution_count": null,
|
||||||
"llm_chain = LLMChain(prompt=prompt, llm=pgllm, verbose=True)\n",
|
"metadata": {
|
||||||
"\n",
|
"id": "I--eSa2PLGqq"
|
||||||
"llm_chain.predict(adjective=\"sad\", subject=\"ducks\")"
|
},
|
||||||
],
|
"outputs": [],
|
||||||
"metadata": {
|
"source": []
|
||||||
"id": "l2bc26KHKr7n"
|
}
|
||||||
},
|
],
|
||||||
"execution_count": null,
|
"metadata": {
|
||||||
"outputs": []
|
"colab": {
|
||||||
},
|
"provenance": []
|
||||||
{
|
},
|
||||||
"cell_type": "code",
|
"kernelspec": {
|
||||||
"source": [],
|
"display_name": "Python 3 (ipykernel)",
|
||||||
"metadata": {
|
"language": "python",
|
||||||
"id": "I--eSa2PLGqq"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
"execution_count": null,
|
"language_info": {
|
||||||
"outputs": []
|
"codemirror_mode": {
|
||||||
}
|
"name": "ipython",
|
||||||
]
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.10.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 4
|
||||||
}
|
}
|
Loading…
Reference in New Issue