id stringlengths 14 16 | text stringlengths 29 2.73k | source stringlengths 49 115 |
|---|---|---|
b7324fa37a68-2 | docs_and_scores = db.similarity_search_with_score(query)
docs_and_scores[0]
(Document(page_content='In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections. \n\nWe cannot let this happen. \n\nTonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
b7324fa37a68-3 | docs = new_db.similarity_search(query)
docs[0]
Document(page_content='In state after state, new laws have been passed, not only to suppress the vote, but to subvert entire elections. \n\nWe cannot let this happen. \n\nTonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act.... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
b7324fa37a68-4 | db1.merge_from(db2)
db1.docstore._dict
{'e0b74348-6c93-4893-8764-943139ec1d17': Document(page_content='foo', lookup_str='', metadata={}, lookup_index=0),
'd5211050-c777-493d-8825-4800e74cfdb6': Document(page_content='bar', lookup_str='', metadata={}, lookup_index=0)}
previous
ElasticSearch
next
LanceDB
Contents
Si... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/faiss.html |
210280daacf2-0 | .ipynb
.pdf
Zilliz
Zilliz#
Zilliz Cloud is a fully managed service on cloud for LF AI Milvus®,
This notebook shows how to use functionality related to the Zilliz Cloud managed vector database.
To run, you should have a Zilliz Cloud instance up and running. Here are the installation instructions
!pip install pymilvus
We... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/zilliz.html |
210280daacf2-1 | "secure": True
}
)
docs = vector_db.similarity_search(query)
docs[0]
previous
Weaviate
next
Retrievers
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/zilliz.html |
348008827e64-0 | .ipynb
.pdf
MyScale
Contents
Setting up envrionments
Get connection info and data schema
Filtering
Deleting your data
MyScale#
MyScale is a cloud-based database optimized for AI applications and solutions, built on the open-source ClickHouse.
This notebook shows how to use functionality related to the MyScale vector ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
348008827e64-1 | text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
for d in docs:
d.metadata = {'some': 'metadata'}
docsearch = MyScale.from_documents(docs, embeddings)
query = "What did the president say about Ketanji Brown Jackso... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
348008827e64-2 | NOTE: Please be aware of SQL injection, this interface must not be directly called by end-user.
If you custimized your column_map under your setting, you search with filter like this:
from langchain.vectorstores import MyScale, MyScaleSettings
from langchain.document_loaders import TextLoader
loader = TextLoader('../..... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
348008827e64-3 | docsearch.drop()
previous
Milvus
next
OpenSearch
Contents
Setting up envrionments
Get connection info and data schema
Filtering
Deleting your data
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/myscale.html |
adc3505b01c8-0 | .ipynb
.pdf
Tair
Tair#
This notebook shows how to use functionality related to the Tair vector database.
To run, you should have an Tair instance up and running.
from langchain.embeddings.fake import FakeEmbeddings
from langchain.text_splitter import CharacterTextSplitter
from langchain.vectorstores import Tair
from la... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/tair.html |
adc3505b01c8-1 | docs = vector_store.similarity_search(query)
docs[0]
Document(page_content='We’re going after the criminals who stole billions in relief money meant for small businesses and millions of Americans. \n\nAnd tonight, I’m announcing that the Justice Department will name a chief prosecutor for pandemic fraud. \n\nBy the en... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/tair.html |
e338232575b4-0 | .ipynb
.pdf
Qdrant
Contents
Connecting to Qdrant from LangChain
Local mode
In-memory
On-disk storage
On-premise server deployment
Qdrant Cloud
Reusing the same collection
Similarity search
Similarity search with score
Maximum marginal relevance search (MMR)
Qdrant as a Retriever
Customizing Qdrant
Qdrant#
Qdrant (rea... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
e338232575b4-1 | docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
Connecting to Qdrant from LangChain#
Local mode#
Python client allows you to run the same code in local mode without running the Qdrant server. That’s great for testing things out and debugging or if you plan to store just a small amount of... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
e338232575b4-2 | collection_name="my_documents",
)
Qdrant Cloud#
If you prefer not to keep yourself busy with managing the infrastructure, you can choose to set up a fully-managed Qdrant cluster on Qdrant Cloud. There is a free forever 1GB cluster included for trying out. The main difference with using a managed version of Qdrant is th... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
e338232575b4-3 | found_docs = qdrant.similarity_search(query)
print(found_docs[0].page_content)
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections.
Tonight, I’d like to honor someone who ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
e338232575b4-4 | One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
e338232575b4-5 | 2. We can’t change how divided we’ve been. But we can change how we move forward—on COVID-19 and other issues we must face together.
I recently visited the New York City Police Department days after the funerals of Officer Wilbert Mora and his partner, Officer Jason Rivera.
They were responding to a 9-1-1 call when a... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
e338232575b4-6 | query = "What did the president say about Ketanji Brown Jackson"
retriever.get_relevant_documents(query)[0]
Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
e338232575b4-7 | location=":memory:",
collection_name="my_documents_2",
content_payload_key="my_page_content_key",
metadata_payload_key="my_meta",
)
<langchain.vectorstores.qdrant.Qdrant at 0x7fc4e2baa230>
previous
Pinecone
next
Redis
Contents
Connecting to Qdrant from LangChain
Local mode
In-memory
On-disk storage
On-p... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/qdrant.html |
fe27a7433977-0 | .ipynb
.pdf
AnalyticDB
AnalyticDB#
AnalyticDB for PostgreSQL is a massively parallel processing (MPP) data warehousing service that is designed to analyze large volumes of data online.
AnalyticDB for PostgreSQL is developed based on the open source Greenplum Database project and is enhanced with in-depth extensions by ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/analyticdb.html |
fe27a7433977-1 | import os
connection_string = AnalyticDB.connection_string_from_db_params(
driver=os.environ.get("PG_DRIVER", "psycopg2cffi"),
host=os.environ.get("PG_HOST", "localhost"),
port=int(os.environ.get("PG_PORT", "5432")),
database=os.environ.get("PG_DATABASE", "postgres"),
user=os.environ.get("PG_USER", ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/analyticdb.html |
88595ad5f89f-0 | .ipynb
.pdf
Deep Lake
Contents
Retrieval Question/Answering
Attribute based filtering in metadata
Choosing distance function
Maximal Marginal relevance
Delete dataset
Deep Lake datasets on cloud (Activeloop, AWS, GCS, etc.) or local
Creating dataset on AWS S3
Deep Lake API
Transfer local dataset to cloud
Deep Lake#
D... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-1 | db.add_documents(docs)
# or shorter
# db = DeepLake.from_documents(docs, dataset_path="./my_deeplake/", embedding=embeddings, overwrite=True)
query = "What did the president say about Ketanji Brown Jackson"
docs = db.similarity_search(query)
/home/leo/.local/lib/python3.10/site-packages/deeplake/util/check_latest_versi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-2 | One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-3 | /home/leo/.local/lib/python3.10/site-packages/langchain/llms/openai.py:624: UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`
warnings.warn(
query = 'What did the president say about Ketanji Brown Ja... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-4 | 100%|██████████| 4/4 [00:00<00:00, 1080.24it/s]
[Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-5 | Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-6 | [Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-7 | Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-8 | Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-9 | Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-10 | [Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedicated his life to serve this country: Justic... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-11 | Document(page_content='Tonight, I’m announcing a crackdown on these companies overcharging American businesses and consumers. \n\nAnd as Wall Street firms take over more nursing homes, quality in those homes has gone down and costs have gone up. \n\nThat ends on my watch. \n\nMedicare is going to set higher standards ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-12 | Document(page_content='A former top litigator in private practice. A former federal public defender. And from a family of public school educators and police officers. A consensus builder. Since she’s been nominated, she’s received a broad range of support—from the Fraternal Order of Police to former judges appointed by... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-13 | Document(page_content='And for our LGBTQ+ Americans, let’s finally get the bipartisan Equality Act to my desk. The onslaught of state laws targeting transgender Americans and their families is wrong. \n\nAs I said last year, especially to our younger transgender Americans, I will always have your back as your President... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-14 | username = "<username>" # your username on app.activeloop.ai
dataset_path = f"hub://{username}/langchain_test" # could be also ./local/path (much faster locally), s3://bucket/path/to/dataset, gcs://path/to/dataset, etc.
embedding = OpenAIEmbeddings()
db = DeepLake(dataset_path=dataset_path, embedding_function=embedd... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-15 | 'd6d6ccb7-e187-11ed-b66d-41c5f7b85421']
query = "What did the president say about Ketanji Brown Jackson"
docs = db.similarity_search(query)
print(docs[0].page_content)
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-16 | })
s3://hub-2.0-datasets-n/langchain_test loaded successfully.
Evaluating ingest: 100%|██████████| 1/1 [00:10<00:00
\
Dataset(path='s3://hub-2.0-datasets-n/langchain_test', tensors=['embedding', 'ids', 'metadata', 'text'])
tensor htype shape dtype compression
------- ------- ------- ------- ----... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-17 | username = "davitbun" # your username on app.activeloop.ai
source = f"hub://{username}/langchain_test" # could be local, s3, gcs, etc.
destination = f"hub://{username}/langchain_test_copy" # could be local, s3, gcs, etc.
deeplake.deepcopy(src=source, dest=destination, overwrite=True)
Copying dataset: 100%|██████████... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
88595ad5f89f-18 | metadata json (4, 1) str None
text text (4, 1) str None
Evaluating ingest: 100%|██████████| 1/1 [00:31<00:00
-
Dataset(path='hub://davitbun/langchain_test_copy', tensors=['embedding', 'ids', 'metadata', 'text'])
tensor htype shape dtype compression
------- -... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/deeplake.html |
f680ef7b7274-0 | .ipynb
.pdf
Weaviate
Weaviate#
Weaviate is an open-source vector database. It allows you to store data objects and vector embeddings from your favorite ML-models, and scale seamlessly into billions of data objects.
This notebook shows how to use functionality related to the Weaviatevector database.
See the Weaviate ins... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
f680ef7b7274-1 | {
"class": "Paragraph",
"description": "A written paragraph",
"vectorizer": "text2vec-openai",
"moduleConfig": {
"text2vec-openai": {
"model": "ada",
"modelVersion": "002",
"type": "text"
... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/weaviate.html |
eae724cc0ec9-0 | .ipynb
.pdf
OpenSearch
Contents
similarity_search using Approximate k-NN Search with Custom Parameters
similarity_search using Script Scoring with Custom Parameters
similarity_search using Painless Scripting with Custom Parameters
Using a preexisting OpenSearch instance
OpenSearch#
OpenSearch is a scalable, flexible,... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
eae724cc0ec9-1 | docs = text_splitter.split_documents(documents)
embeddings = OpenAIEmbeddings()
docsearch = OpenSearchVectorSearch.from_documents(docs, embeddings, opensearch_url="http://localhost:9200")
query = "What did the president say about Ketanji Brown Jackson"
docs = docsearch.similarity_search(query)
print(docs[0].page_conten... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
eae724cc0ec9-2 | query = "What did the president say about Ketanji Brown Jackson"
docs = docsearch.similarity_search("What did the president say about Ketanji Brown Jackson", search_type="painless_scripting", space_type="cosineSimilarity", pre_filter=filter)
print(docs[0].page_content)
Using a preexisting OpenSearch instance#
It’s also... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/opensearch.html |
1dbd8201331c-0 | .ipynb
.pdf
Redis
Contents
RedisVectorStoreRetriever
Redis#
Redis (Remote Dictionary Server) is an in-memory data structure store, used as a distributed, in-memory key–value database, cache and message broker, with optional durability.
This notebook shows how to use functionality related to the Redis vector database.... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
1dbd8201331c-1 | One of the most serious constitutional responsibilities a President has is nominating someone to serve on the United States Supreme Court.
And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
1dbd8201331c-2 | RedisVectorStoreRetriever#
Here we go over different options for using the vector store as a retriever.
There are three different search methods we can use to do retrieval. By default, it will use semantic similarity.
retriever = rds.as_retriever()
docs = retriever.get_relevant_documents(query)
We can also use similari... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/redis.html |
e3c94cbc6d50-0 | .ipynb
.pdf
ElasticSearch
Contents
Installation
Example
ElasticSearch#
Elasticsearch is a distributed, RESTful search and analytics engine. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.
This notebook shows how to use functionality rel... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
e3c94cbc6d50-1 | Click “Reset password”
Follow the prompts to reset the password
Format for Elastic Cloud URLs is
https://username:password@cluster_id.region_id.gcp.cloud.es.io:9243.
Example:
from langchain import ElasticVectorSearch
from langchain.embeddings import OpenAIEmbeddings
embedding = OpenAIEmbeddings(... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
e3c94cbc6d50-2 | We cannot let this happen.
Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections.
Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/elasticsearch.html |
0d08186f0734-0 | .ipynb
.pdf
Milvus
Milvus#
Milvus is a database that stores, indexes, and manages massive embedding vectors generated by deep neural networks and other machine learning (ML) models.
This notebook shows how to use functionality related to the Milvus vector database.
To run, you should have a Milvus instance up and runni... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/milvus.html |
d518da70349e-0 | .ipynb
.pdf
Chroma
Contents
Similarity search with score
Persistance
Initialize PeristedChromaDB
Persist the Database
Load the Database from disk, and create the chain
Retriever options
MMR
Chroma#
Chroma is a database for building AI applications with embeddings.
This notebook shows how to use functionality related ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
d518da70349e-1 | Tonight, I’d like to honor someone who has dedicated his life to serve this country: Justice Stephen Breyer—an Army veteran, Constitutional scholar, and retiring Justice of the United States Supreme Court. Justice Breyer, thank you for your service.
One of the most serious constitutional responsibilities a President h... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
d518da70349e-2 | The below steps cover how to persist a ChromaDB instance
Initialize PeristedChromaDB#
Create embeddings for each chunk and insert into the Chroma vector database. The persist_directory argument tells ChromaDB where to store the database when it’s persisted.
# Embed and store the texts
# Supplying a persist_directory wi... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
d518da70349e-3 | retriever.get_relevant_documents(query)[0]
Document(page_content='Tonight. I call on the Senate to: Pass the Freedom to Vote Act. Pass the John Lewis Voting Rights Act. And while you’re at it, pass the Disclose Act so Americans can know who is funding our elections. \n\nTonight, I’d like to honor someone who has dedica... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/chroma.html |
5d04a524fa9c-0 | .ipynb
.pdf
Annoy
Contents
Create VectorStore from texts
Create VectorStore from docs
Create VectorStore via existing embeddings
Search via embeddings
Search via docstore id
Save and load
Construct from scratch
Annoy#
“Annoy (Approximate Nearest Neighbors Oh Yeah) is a C++ library with Python bindings to search for p... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-1 | # the score is a distance metric, so lower is better
vector_store.similarity_search_with_score("food", k=3)
[(Document(page_content='pizza is great', metadata={}), 1.0944390296936035),
(Document(page_content='I love salad', metadata={}), 1.1273186206817627),
(Document(page_content='my car', metadata={}), 1.1580758094... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-2 | docs = text_splitter.split_documents(documents)
docs[:5]
[Document(page_content='Madam Speaker, Madam Vice President, our First Lady and Second Gentleman. Members of Congress and the Cabinet. Justices of the Supreme Court. My fellow Americans. \n\nLast year COVID-19 kept us apart. This year we are finally together aga... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-3 | Document(page_content='Groups of citizens blocking tanks with their bodies. Everyone from students to retirees teachers turned soldiers defending their homeland. \n\nIn this struggle as President Zelenskyy said in his speech to the European Parliament “Light will win over darkness.” The Ukrainian Ambassador to the Unit... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-4 | Document(page_content='Putin’s latest attack on Ukraine was premeditated and unprovoked. \n\nHe rejected repeated efforts at diplomacy. \n\nHe thought the West and NATO wouldn’t respond. And he thought he could divide us at home. Putin was wrong. We were ready. Here is what we did. \n\nWe prepared extensively and ca... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-5 | Document(page_content='We are inflicting pain on Russia and supporting the people of Ukraine. Putin is now isolated from the world more than ever. \n\nTogether with our allies –we are right now enforcing powerful economic sanctions. \n\nWe are cutting off Russia’s largest banks from the international financial system. ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-6 | Document(page_content='And tonight I am announcing that we will join our allies in closing off American air space to all Russian flights – further isolating Russia – and adding an additional squeeze –on their economy. The Ruble has lost 30% of its value. \n\nThe Russian stock market has lost 40% of its value and tradin... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-7 | (Document(page_content='I love salad', metadata={}), 1.1273186206817627),
(Document(page_content='my car', metadata={}), 1.1580758094787598)]
Search via embeddings#
motorbike_emb = embeddings_func.embed_query("motorbike")
vector_store.similarity_search_by_vector(motorbike_emb, k=3)
[Document(page_content='my car', met... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-8 | Document(page_content='pizza is great', metadata={})
# same document has distance 0
vector_store.similarity_search_with_score_by_index(some_docstore_id, k=3)
[(Document(page_content='pizza is great', metadata={}), 0.0),
(Document(page_content='I love salad', metadata={}), 1.0734446048736572),
(Document(page_content='... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
5d04a524fa9c-9 | index.build(10)
# docstore
documents = []
for i, text in enumerate(texts):
metadata = metadatas[i] if metadatas else {}
documents.append(Document(page_content=text, metadata=metadata))
index_to_docstore_id = {i: str(uuid.uuid4()) for i in range(len(documents))}
docstore = InMemoryDocstore(
{index_to_docstor... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/annoy.html |
8c60ce1da1e8-0 | .ipynb
.pdf
PGVector
Contents
Similarity search with score
Similarity Search with Euclidean Distance (Default)
PGVector#
PGVector is an open-source vector similarity search for Postgres
It supports:
exact and approximate nearest neighbor search
L2 distance, inner product, and cosine distance
This notebook shows how t... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
8c60ce1da1e8-1 | user=os.environ.get("PGVECTOR_USER", "postgres"),
password=os.environ.get("PGVECTOR_PASSWORD", "postgres"),
)
## Example
# postgresql+psycopg2://username:password@localhost:5432/database_name
Similarity search with score#
Similarity Search with Euclidean Distance (Default)#
# The PGVector Module will try to create ... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
8c60ce1da1e8-2 | And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.
--------------------------------------------------------------------------------
-----------------------------------------------... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
8c60ce1da1e8-3 | And I did that 4 days ago, when I nominated Circuit Court of Appeals Judge Ketanji Brown Jackson. One of our nation’s top legal minds, who will continue Justice Breyer’s legacy of excellence.
--------------------------------------------------------------------------------
-----------------------------------------------... | https://python.langchain.com/en/latest/modules/indexes/vectorstores/examples/pgvector.html |
3e9bd7a2695c-0 | .md
.pdf
Locally Hosted Setup
Contents
Installation
Environment Setup
Locally Hosted Setup#
This page contains instructions for installing and then setting up the environment to use the locally hosted version of tracing.
Installation#
Ensure you have Docker installed (see Get Docker) and that it’s running.
Install th... | https://python.langchain.com/en/latest/tracing/local_installation.html |
3e9bd7a2695c-1 | By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/tracing/local_installation.html |
1b6354d46893-0 | .ipynb
.pdf
Tracing Walkthrough
Tracing Walkthrough#
There are two recommended ways to trace your LangChains:
Setting the LANGCHAIN_TRACING environment variable to “true”.
Using a context manager with tracing_enabled() to trace a particular block of code.
Note if the environment variable is set, all code will be traced... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
1b6354d46893-1 | I need to use a calculator to solve this.
Action: Calculator
Action Input: 2^.123243
Observation: Answer: 1.0891804557407723
Thought: I now know the final answer.
Final Answer: 1.0891804557407723
> Finished chain.
'1.0891804557407723'
# Agent run with tracing using a chat model
agent = initialize_agent(
tools, Chat... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
1b6354d46893-2 | Action: Calculator
Action Input: 5 ^ .123243
Observation: Answer: 1.2193914912400514
Thought:I now know the answer to the question.
Final Answer: 1.2193914912400514
> Finished chain.
# Now, we unset the environment variable and use a context manager.
if "LANGCHAIN_TRACING" in os.environ:
del os.environ["LANGCHAIN_... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
1b6354d46893-3 | del os.environ["LANGCHAIN_TRACING"]
questions = [f"What is {i} raised to .123 power?" for i in range(1,4)]
# start a background task
task = asyncio.create_task(agent.arun(questions[0])) # this should not be traced
with tracing_enabled() as session:
assert session
tasks = [agent.arun(q) for q in questions[... | https://python.langchain.com/en/latest/tracing/agent_with_tracing.html |
03a0ae1db37c-0 | .md
.pdf
Cloud Hosted Setup
Contents
Installation
Environment Setup
Cloud Hosted Setup#
We offer a hosted version of tracing at langchainplus.vercel.app. You can use this to view traces from your run without having to run the server locally.
Note: we are currently only offering this to a limited number of users. The ... | https://python.langchain.com/en/latest/tracing/hosted_installation.html |
03a0ae1db37c-1 | os.environ["LANGCHAIN_API_KEY"] = "my_api_key" # Don't commit this to your repo! Better to set it in your terminal.
Contents
Installation
Environment Setup
By Harrison Chase
© Copyright 2023, Harrison Chase.
Last updated on May 02, 2023. | https://python.langchain.com/en/latest/tracing/hosted_installation.html |
2c2ecee42317-0 | .md
.pdf
Extraction
Extraction#
Conceptual Guide
Most APIs and databases still deal with structured information.
Therefore, in order to better work with those, it can be useful to extract structured information from text.
Examples of this include:
Extracting a structured row to insert into a database from a sentence
Ex... | https://python.langchain.com/en/latest/use_cases/extraction.html |
8bbb3f0d176c-0 | .md
.pdf
Querying Tabular Data
Contents
Document Loading
Querying
Chains
Agents
Querying Tabular Data#
Conceptual Guide
Lots of data and information is stored in tabular data, whether it be csvs, excel sheets, or SQL tables.
This page covers all resources available in LangChain for working with data in this format.
D... | https://python.langchain.com/en/latest/use_cases/tabular.html |
1b92829d05fb-0 | .md
.pdf
Interacting with APIs
Contents
Chains
Agents
Interacting with APIs#
Conceptual Guide
Lots of data and information is stored behind APIs.
This page covers all resources available in LangChain for working with APIs.
Chains#
If you are just getting started, and you have relatively simple apis, you should get st... | https://python.langchain.com/en/latest/use_cases/apis.html |
e6ae67a9cee5-0 | .md
.pdf
Code Understanding
Contents
Conversational Retriever Chain
Code Understanding#
Overview
LangChain is a useful tool designed to parse GitHub code repositories. By leveraging VectorStores, Conversational RetrieverChain, and GPT-4, it can answer questions in the context of an entire GitHub repository or generat... | https://python.langchain.com/en/latest/use_cases/code.html |
e6ae67a9cee5-1 | The full tutorial is available below.
Twitter the-algorithm codebase analysis with Deep Lake: A notebook walking through how to parse github source code and run queries conversation.
LangChain codebase analysis with Deep Lake: A notebook walking through how to analyze and do question answering over THIS code base.
prev... | https://python.langchain.com/en/latest/use_cases/code.html |
7eef92193f4c-0 | .md
.pdf
Summarization
Summarization#
Conceptual Guide
Summarization involves creating a smaller summary of multiple longer documents.
This can be useful for distilling long documents into the core pieces of information.
The recommended way to get started using a summarization chain is:
from langchain.chains.summarize ... | https://python.langchain.com/en/latest/use_cases/summarization.html |
a5a373745abe-0 | .md
.pdf
Chatbots
Chatbots#
Conceptual Guide
Since language models are good at producing text, that makes them ideal for creating chatbots.
Aside from the base prompts/LLMs, an important concept to know for Chatbots is memory.
Most chat based applications rely on remembering what happened in previous interactions, whic... | https://python.langchain.com/en/latest/use_cases/chatbots.html |
ef0b05e60e5a-0 | .md
.pdf
Agent Simulations
Contents
Simulations with One Agent
Simulations with Two Agents
Simulations with Multiple Agents
Agent Simulations#
Agent simulations involve interacting one of more agents with each other.
Agent simulations generally involve two main components:
Long Term Memory
Simulation Environment
Spec... | https://python.langchain.com/en/latest/use_cases/agent_simulations.html |
ef0b05e60e5a-1 | Generative Agents: This notebook implements a generative agent based on the paper Generative Agents: Interactive Simulacra of Human Behavior by Park, et. al.
previous
Autonomous Agents
next
Question Answering over Docs
Contents
Simulations with One Agent
Simulations with Two Agents
Simulations with Multiple Agents
... | https://python.langchain.com/en/latest/use_cases/agent_simulations.html |
08af939c0173-0 | .md
.pdf
Personal Assistants (Agents)
Personal Assistants (Agents)#
Conceptual Guide
We use “personal assistant” here in a very broad sense.
Personal assistants have a few characteristics:
They can interact with the outside world
They have knowledge of your data
They remember your interactions
Really all of the functio... | https://python.langchain.com/en/latest/use_cases/personal_assistants.html |
abbd0d0b4a65-0 | .md
.pdf
Autonomous Agents
Contents
Baby AGI (Original Repo)
AutoGPT (Original Repo)
MetaPrompt (Original Repo)
Autonomous Agents#
Autonomous Agents are agents that designed to be more long running.
You give them one or multiple long term goals, and they independently execute towards those goals.
The applications com... | https://python.langchain.com/en/latest/use_cases/autonomous_agents.html |
6f471dc6f324-0 | .md
.pdf
Question Answering over Docs
Contents
Document Question Answering
Adding in sources
Additional Related Resources
End-to-end examples
Question Answering over Docs#
Conceptual Guide
Question answering in this context refers to question answering over your document data.
For question answering over other types ... | https://python.langchain.com/en/latest/use_cases/question_answering.html |
6f471dc6f324-1 | The LLM response will contain the answer to your question, based on the content of the documents.
The recommended way to get started using a question answering chain is:
from langchain.chains.question_answering import load_qa_chain
chain = load_qa_chain(llm, chain_type="stuff")
chain.run(input_documents=docs, question=... | https://python.langchain.com/en/latest/use_cases/question_answering.html |
6f471dc6f324-2 | Additional Related Resources#
Additional related resources include:
Utilities for working with Documents: Guides on how to use several of the utilities which will prove helpful for this task, including Text Splitters (for splitting up long documents) and Embeddings & Vectorstores (useful for the above Vector DB example... | https://python.langchain.com/en/latest/use_cases/question_answering.html |
b79bd32ce78a-0 | .rst
.pdf
Evaluation
Contents
The Problem
The Solution
The Examples
Other Examples
Evaluation#
Note
Conceptual Guide
This section of documentation covers how we approach and think about evaluation in LangChain.
Both evaluation of internal chains/agents, but also how we would recommend people building on top of LangCh... | https://python.langchain.com/en/latest/use_cases/evaluation.html |
b79bd32ce78a-1 | We intend this to be a collection of open source datasets for evaluating common chains and agents.
We have contributed five datasets of our own to start, but we highly intend this to be a community effort.
In order to contribute a dataset, you simply need to join the community and then you will be able to upload datase... | https://python.langchain.com/en/latest/use_cases/evaluation.html |
b79bd32ce78a-2 | SQL Question Answering (Chinook): A notebook showing evaluation of a question-answering task over a SQL database (the Chinook database).
Agent Vectorstore: A notebook showing evaluation of an agent doing question answering while routing between two different vector databases.
Agent Search + Calculator: A notebook showi... | https://python.langchain.com/en/latest/use_cases/evaluation.html |
6b873f2e777b-0 | .ipynb
.pdf
AutoGPT
Contents
Set up tools
Set up memory
Setup model and AutoGPT
Run an example
AutoGPT#
Implementation of https://github.com/Significant-Gravitas/Auto-GPT but with LangChain primitives (LLMs, PromptTemplates, VectorStores, Embeddings, Tools)
Set up tools#
We’ll set up an AutoGPT with a search tool, an... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6b873f2e777b-1 | ai_name="Tom",
ai_role="Assistant",
tools=tools,
llm=ChatOpenAI(temperature=0),
memory=vectorstore.as_retriever()
)
# Set verbose to be true
agent.chain.verbose = True
Run an example#
Here we will make it write a weather report for SF
agent.run(["write a weather report for SF today"])
> Entering new LLM... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6b873f2e777b-2 | 3. read_file: Read file from disk, args json schema: {"file_path": {"title": "File Path", "description": "name of file", "type": "string"}}
4. finish: use this to signal that you have finished all your objectives, args: "response": "final response to let people know you have finished your objectives"
Resources:
1. Inte... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6b873f2e777b-3 | System: This reminds you of these events from your past:
[]
Human: Determine which next command to use, and respond using the format specified above:
> Finished chain.
{
"thoughts": {
"text": "I will start by writing a weather report for San Francisco today. I will use the 'search' command to find the curre... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
6b873f2e777b-4 | 3. No user assistance
4. Exclusively use the commands listed in double quotes e.g. "command name"
Commands:
1. search: useful for when you need to answer questions about current events. You should ask targeted questions, args json schema: {"query": {"title": "Query", "type": "string"}}
2. write_file: Write file to disk... | https://python.langchain.com/en/latest/use_cases/autonomous_agents/autogpt.html |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.