mirror of
https://github.com/hwchase17/langchain.git
synced 2025-05-13 11:07:41 +00:00
…tch]: import models from community ran ```bash git grep -l 'from langchain\.chat_models' | xargs -L 1 sed -i '' "s/from\ langchain\.chat_models/from\ langchain_community.chat_models/g" git grep -l 'from langchain\.llms' | xargs -L 1 sed -i '' "s/from\ langchain\.llms/from\ langchain_community.llms/g" git grep -l 'from langchain\.embeddings' | xargs -L 1 sed -i '' "s/from\ langchain\.embeddings/from\ langchain_community.embeddings/g" git checkout master libs/langchain/tests/unit_tests/llms git checkout master libs/langchain/tests/unit_tests/chat_models git checkout master libs/langchain/tests/unit_tests/embeddings/test_imports.py make format cd libs/langchain; make format cd ../experimental; make format cd ../core; make format ```
112 lines
2.4 KiB
Plaintext
112 lines
2.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "b14a24db",
|
|
"metadata": {},
|
|
"source": [
|
|
"# AwaDB\n",
|
|
"\n",
|
|
">[AwaDB](https://github.com/awa-ai/awadb) is an AI Native database for the search and storage of embedding vectors used by LLM Applications.\n",
|
|
"\n",
|
|
"This notebook explains how to use `AwaEmbeddings` in LangChain."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "0ab948fc",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# pip install awadb"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "67c637ca",
|
|
"metadata": {},
|
|
"source": [
|
|
"## import the library"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "5709b030",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from langchain_community.embeddings import AwaEmbeddings"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "1756b1ba",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"Embedding = AwaEmbeddings()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "4a2a098d",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Set embedding model\n",
|
|
"Users can use `Embedding.set_model()` to specify the embedding model. \\\n",
|
|
"The input of this function is a string which represents the model's name. \\\n",
|
|
"The list of currently supported models can be obtained [here](https://github.com/awa-ai/awadb) \\ \\ \n",
|
|
"\n",
|
|
"The **default model** is `all-mpnet-base-v2`, it can be used without setting."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 4,
|
|
"id": "584b9af5",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"text = \"our embedding test\"\n",
|
|
"\n",
|
|
"Embedding.set_model(\"all-mpnet-base-v2\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"id": "be18b873",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"res_query = Embedding.embed_query(\"The test information\")\n",
|
|
"res_document = Embedding.embed_documents([\"test1\", \"another test\"])"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3 (ipykernel)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.10.12"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|