Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting #1

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ Pre commit hooks run after commit to fix up formatting and other issues. Install
pre-commit install
```

You can then run:

```sh
pre-commit run --all-files
```

and commit any changes made to files in the repo.

## 6. Add secrets into .env

- Run `cp .env.template .env` and update the secrets.
Expand Down
5 changes: 1 addition & 4 deletions app/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@

from config.logging import setup_logging
from config.settings import ENV
from hackathon.streamlit.utils import (
check_password,
)
from hackathon.streamlit.utils import check_password

get_logger = setup_logging()
logger = get_logger(__name__)
Expand Down Expand Up @@ -155,4 +153,3 @@ def image_to_base64(image):
"""
)
# * [Initialise the data](/initialise_the_data) will load in the previous vacancies from s3.

4 changes: 1 addition & 3 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
PROJECT_PATH = os.environ.get("PROJECT_PATH")
OPENSEARCH_URL = os.environ.get("OPENSEARCH_URL")
OPENSEARCH_BATCH_SIZE = int(os.environ.get("OPENSEARCH_BATCH_SIZE", 500))
OPENSEARCH_ENDPOINT_NAME = os.environ.get(
"OPENSEARCH_ENDPOINT_NAME", "vstore"
)
OPENSEARCH_ENDPOINT_NAME = os.environ.get("OPENSEARCH_ENDPOINT_NAME", "vstore")
OPENSEARCH_INDEX_NAME = os.environ.get("OPENSEARCH_INDEX_NAME", "vacancies")
OPENSEARCH_SKILLS_INDEX_NAME = os.environ.get(
"OPENSEARCH_SKILLS_INDEX_NAME", "unique_skills"
Expand Down
5 changes: 1 addition & 4 deletions hackathon/llm/chain_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
from langchain.schema.output_parser import StrOutputParser
from langchain_core.output_parsers.transform import BaseTransformOutputParser

from hackathon.llm.prompts.core import (

PromptTemplate,
)
from hackathon.llm.prompts.core import PromptTemplate


@dataclass
Expand Down
5 changes: 4 additions & 1 deletion hackathon/llm/llm_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class LLMRunner:
"""

def __init__(
self, llm: LLM, vectorstore: VectorStore, chain_configs: List[ChainConfig]
self,
llm: LLM,
vectorstore: VectorStore,
chain_configs: List[ChainConfig],
) -> None:
"""
Sets up runner with required components of an llm, vectorstore and a list of llm chain configs.
Expand Down
1 change: 0 additions & 1 deletion hackathon/llm/prompts/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@
"""
"""
)

26 changes: 17 additions & 9 deletions hackathon/streamlit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
S3_LOADER_FILE_NAME,
VECTOR_STORE_CONFIG,
)
from hackathon.llm.chain_config import (

)
# from hackathon.llm.chain_config import (
# # Empty for now
# )
from hackathon.llm.llm import LLama2, SagemakerHostedLLM
from hackathon.llm.llm_handler import LLMRunner
from hackathon.loader.chunker import TextChunker
Expand Down Expand Up @@ -128,20 +129,25 @@ def initialise_llm_runner():

if VECTOR_STORE_CONFIG == "chroma":
vector_store = ChromaStore(
embedding_function=st_embedder, collection_name=OPENSEARCH_INDEX_NAME
embedding_function=st_embedder,
collection_name=OPENSEARCH_INDEX_NAME,
)
else:
if "skills_os_client" not in st.session_state:
st.session_state["skills_os_client"] = OpensearchClient(
OPENSEARCH_SKILLS_INDEX_NAME, OPENSEARCH_ENDPOINT_NAME, AWS_REGION
OPENSEARCH_SKILLS_INDEX_NAME,
OPENSEARCH_ENDPOINT_NAME,
AWS_REGION,
)
if "vacancy_os_client" not in st.session_state:
st.session_state["vacancy_os_client"] = OpensearchClient(
OPENSEARCH_INDEX_NAME, OPENSEARCH_ENDPOINT_NAME, AWS_REGION
)

vector_store = OpenSearchStore(
st_embedder, OPENSEARCH_INDEX_NAME, st.session_state["vacancy_os_client"]
st_embedder,
OPENSEARCH_INDEX_NAME,
st.session_state["vacancy_os_client"],
)

if LLM_MODEL == "local_llm":
Expand All @@ -156,11 +162,11 @@ def initialise_llm_runner():
llm_runner = LLMRunner(
llm=llm,
vectorstore=vector_store,
chain_configs=[
],
chain_configs=[],
)
st.session_state["runner"] = llm_runner


def initialise_vector_store_loader():
if LLM_MODEL == "local_llm":
st_embedder = SentenceTransformerEmbeddings(
Expand All @@ -179,7 +185,9 @@ def initialise_vector_store_loader():
OPENSEARCH_INDEX_NAME, OPENSEARCH_ENDPOINT_NAME, AWS_REGION
)
vector_store = OpensearchClientStore(
st_embedder, OPENSEARCH_INDEX_NAME, st.session_state["vacancy_os_client"]
st_embedder,
OPENSEARCH_INDEX_NAME,
st.session_state["vacancy_os_client"],
)

if LOADER_CONFIG == "file_loader":
Expand All @@ -197,9 +205,9 @@ def initialise_vector_store_loader():
chunker=TextChunker(chunk_size=1000, overlap=10),
)


def safe_literal_eval(x):
try:
return literal_eval(x)
except (SyntaxError, ValueError):
return None

7 changes: 6 additions & 1 deletion hackathon/vectorstore/vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ def retrieve_data_with_score(self, query):
return self.vectorstore.similarity_search_with_score(query, k=10)

def retrieve_data(
self, query: str, search_type: str, space_type: str, pre_filter, k: int = 5
self,
query: str,
search_type: str,
space_type: str,
pre_filter,
k: int = 5,
):
"""
Similarity search which returns values with score attachmend with up to k results,
Expand Down
Loading
Loading