Skip to content

Commit 0c11652

Browse files
committed
linted used black and ruff
1 parent fbd09b6 commit 0c11652

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
# "torchmetrics[image]",
2222
# "boto3",
2323
],
24-
)
24+
)

src/any_chatbot/agent.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import getpass
22
import os
3+
import random
34
from dotenv import load_dotenv
45
from pathlib import Path
56

@@ -41,7 +42,6 @@
4142

4243
# PROMPT
4344
# specify an ID for the thread
44-
import random
4545
# config = {"configurable": {"thread_id": "abc123"}}
4646
config = {"configurable": {"thread_id": random.random()}}
4747

@@ -57,4 +57,3 @@
5757
config=config,
5858
):
5959
event["messages"][-1].pretty_print()
60-

src/any_chatbot/indexing.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
BASE = Path(__file__).parent.parent.parent
1212
DATA = BASE / "data"
1313

14+
1415
def index_text_docs(
1516
data_pth: Path = DATA,
1617
):
@@ -32,27 +33,24 @@ def index_text_docs(
3233
"**/*.jpeg",
3334
"**/*.tiff",
3435
],
35-
loader_cls=UnstructuredFileLoader
36+
loader_cls=UnstructuredFileLoader,
3637
)
3738
print(f"Loading files from {data_pth}")
3839
docs = loader.load()
3940
print(f"Loaded {len(docs)} files")
4041

4142
# Split the texts
4243
text_splitter = RecursiveCharacterTextSplitter(
43-
chunk_size=1000,
44-
chunk_overlap=200,
44+
chunk_size=1000,
45+
chunk_overlap=200,
4546
add_start_index=True,
46-
separators=["\n\n", "\n", " ", ""],
47+
separators=["\n\n", "\n", " ", ""],
4748
)
4849
all_splits = text_splitter.split_documents(docs)
4950
print(len(all_splits))
5051

5152
# index the docs
5253
ids = vector_store.add_documents(documents=all_splits)
5354
print(len(ids))
54-
55-
return embeddings, vector_store
56-
57-
5855

56+
return embeddings, vector_store

src/any_chatbot/tools.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
from typing import Tuple, List
22
from langchain_core.tools import tool
33
from langchain.vectorstores.base import VectorStore
4-
from langchain.schema import Document
4+
from langchain.schema import Document
5+
56

67
def initialize_retrieve_tool(vector_store: VectorStore):
78
@tool(
89
description="Retrieve information related to a query",
910
response_format="content_and_artifact",
1011
)
11-
def retrieve(
12-
query: str
13-
) -> Tuple[str, List[Document]]:
12+
def retrieve(query: str) -> Tuple[str, List[Document]]:
1413
retrieved_docs = vector_store.similarity_search(query, k=3)
1514
serialized = "\n\n".join(
1615
(f"Source: {doc.metadata}\nContent: {doc.page_content}")

0 commit comments

Comments
 (0)