mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-11 07:25:29 +00:00
fix integration tests (#10952)
This commit is contained in:
parent
6f781902ae
commit
1b65779905
@ -1,7 +1,6 @@
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from qdrant_client import models
|
|
||||||
|
|
||||||
from langchain.schema import Document
|
from langchain.schema import Document
|
||||||
from langchain.vectorstores import Qdrant
|
from langchain.vectorstores import Qdrant
|
||||||
@ -21,6 +20,8 @@ def test_qdrant_max_marginal_relevance_search(
|
|||||||
vector_name: Optional[str],
|
vector_name: Optional[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test end to end construction and MRR search."""
|
"""Test end to end construction and MRR search."""
|
||||||
|
from qdrant_client import models
|
||||||
|
|
||||||
filter = models.Filter(
|
filter = models.Filter(
|
||||||
must=[
|
must=[
|
||||||
models.FieldCondition(
|
models.FieldCondition(
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
# flake8: noqa
|
||||||
|
|
||||||
from langchain.docstore.document import Document
|
from langchain.docstore.document import Document
|
||||||
from langchain.vectorstores.vearch import VearchDb
|
from langchain.vectorstores.vearch import Vearch
|
||||||
from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings
|
from tests.integration_tests.vectorstores.fake_embeddings import FakeEmbeddings
|
||||||
|
|
||||||
|
|
||||||
@ -14,16 +16,22 @@ def test_vearch() -> None:
|
|||||||
]
|
]
|
||||||
metadatas = [
|
metadatas = [
|
||||||
{
|
{
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": (
|
||||||
|
"/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
||||||
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": (
|
||||||
|
"/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
||||||
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": (
|
||||||
|
"/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
||||||
|
)
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
vearch_db = VearchDb.from_texts(
|
vearch_db = Vearch.from_texts(
|
||||||
texts=texts,
|
texts=texts,
|
||||||
embedding=FakeEmbeddings(),
|
embedding=FakeEmbeddings(),
|
||||||
metadatas=metadatas,
|
metadatas=metadatas,
|
||||||
@ -37,7 +45,10 @@ def test_vearch() -> None:
|
|||||||
Document(
|
Document(
|
||||||
page_content="Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库",
|
page_content="Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库",
|
||||||
metadata={
|
metadata={
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": (
|
||||||
|
"/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/"
|
||||||
|
"three_body.txt"
|
||||||
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@ -46,23 +57,26 @@ def test_vearch() -> None:
|
|||||||
def test_vearch_add_texts() -> None:
|
def test_vearch_add_texts() -> None:
|
||||||
"""Test end to end adding of texts."""
|
"""Test end to end adding of texts."""
|
||||||
texts = [
|
texts = [
|
||||||
"Vearch 是一款存储大语言模型数据的向量数据库,用于存储和快速搜索模型embedding后的向量,可用于基于个人知识库的大模型应用",
|
("Vearch 是一款存储大语言模型数据的向量数据库,用于存储和快速搜索模型embedding后的向量," "可用于基于个人知识库的大模型应用"),
|
||||||
"Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库",
|
"Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库",
|
||||||
"vearch 是基于C语言,go语言开发的,并提供python接口,可以直接通过pip安装",
|
"vearch 是基于C语言,go语言开发的,并提供python接口,可以直接通过pip安装",
|
||||||
]
|
]
|
||||||
|
|
||||||
metadatas = [
|
metadatas = [
|
||||||
{
|
{
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/"
|
||||||
|
"three_body.txt"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/"
|
||||||
|
"three_body.txt"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/"
|
||||||
|
"three_body.txt"
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
vearch_db = VearchDb.from_texts(
|
vearch_db = Vearch.from_texts(
|
||||||
texts=texts,
|
texts=texts,
|
||||||
embedding=FakeEmbeddings(),
|
embedding=FakeEmbeddings(),
|
||||||
metadatas=metadatas,
|
metadatas=metadatas,
|
||||||
@ -72,9 +86,11 @@ def test_vearch_add_texts() -> None:
|
|||||||
|
|
||||||
vearch_db.add_texts(
|
vearch_db.add_texts(
|
||||||
texts=["Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库"],
|
texts=["Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库"],
|
||||||
metadatas={
|
metadatas=[
|
||||||
|
{
|
||||||
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
"source": "/data/zhx/zhx/langchain-ChatGLM_new/knowledge_base/santi/three_body.txt"
|
||||||
},
|
},
|
||||||
|
],
|
||||||
)
|
)
|
||||||
result = vearch_db.similarity_search(
|
result = vearch_db.similarity_search(
|
||||||
"Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库", 2
|
"Vearch 支持OpenAI, Llama, ChatGLM等模型,以及LangChain库", 2
|
||||||
@ -94,4 +110,3 @@ def test_vearch_add_texts() -> None:
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user