Skip to content

Commit

Permalink
reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
hsm207 committed May 24, 2023
1 parent 8627594 commit 550a166
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 6 additions & 5 deletions docs/modules/indexes/vectorstores/examples/weaviate.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"import os\n",
"import getpass\n",
"\n",
"os.environ['OPENAI_API_KEY'] = getpass.getpass('OpenAI API Key:')"
"os.environ[\"OPENAI_API_KEY\"] = getpass.getpass(\"OpenAI API Key:\")"
]
},
{
Expand All @@ -74,7 +74,7 @@
"metadata": {},
"outputs": [],
"source": [
"WEAVIATE_URL = getpass.getpass('WEAVIATE_URL:')"
"WEAVIATE_URL = getpass.getpass(\"WEAVIATE_URL:\")"
]
},
{
Expand All @@ -84,7 +84,7 @@
"metadata": {},
"outputs": [],
"source": [
"os.environ['WEAVIATE_API_KEY'] = getpass.getpass('WEAVIATE_API_KEY:')"
"os.environ[\"WEAVIATE_API_KEY\"] = getpass.getpass(\"WEAVIATE_API_KEY:\")"
]
},
{
Expand All @@ -110,7 +110,8 @@
"outputs": [],
"source": [
"from langchain.document_loaders import TextLoader\n",
"loader = TextLoader('../../../state_of_the_union.txt')\n",
"\n",
"loader = TextLoader(\"../../../state_of_the_union.txt\")\n",
"documents = loader.load()\n",
"text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)\n",
"docs = text_splitter.split_documents(documents)\n",
Expand All @@ -125,7 +126,7 @@
"metadata": {},
"outputs": [],
"source": [
"db = Weaviate.from_documents(docs, embeddings, weaviate_url = WEAVIATE_URL, by_text=False)"
"db = Weaviate.from_documents(docs, embeddings, weaviate_url=WEAVIATE_URL, by_text=False)"
]
},
{
Expand Down
13 changes: 9 additions & 4 deletions langchain/vectorstores/weaviate.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def similarity_search_with_score(
if kwargs.get("search_distance"):
content["certainty"] = kwargs.get("search_distance")
query_obj = self._client.query.get(self._index_name, self._query_attrs)

if not self._by_text:
embedding = self._embedding.embed_query(query)
vector = {"vector": embedding}
Expand Down Expand Up @@ -452,6 +452,11 @@ def from_texts(
by_text = kwargs.get("by_text")

return cls(
client, index_name, text_key, embedding=embedding, attributes=attributes,
relevance_score_fn=relevance_score_fn, by_text=by_text
)
client,
index_name,
text_key,
embedding=embedding,
attributes=attributes,
relevance_score_fn=relevance_score_fn,
by_text=by_text,
)

0 comments on commit 550a166

Please sign in to comment.