Skip to content

Commit

Permalink
Merge branch 'main' into DEV-1962-implement-urlreplacemap
Browse files Browse the repository at this point in the history
  • Loading branch information
marcobottaro authored Oct 14, 2024
2 parents b94add9 + dcb7f89 commit e330123
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 79 deletions.
1 change: 0 additions & 1 deletion apps/chatbot/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CHB_AWS_ACCESS_KEY_ID=...
CHB_AWS_SECRET_ACCESS_KEY=...
CHB_AWS_DEFAULT_REGION=eu-south-1
CHB_AWS_BEDROCK_REGION=eu-west-3
CHB_AWS_S3_BUCKET=...
CHB_AWS_GUARDRAIL_ID=...
CHB_AWS_GUARDRAIL_VERSION=...
CHB_REDIS_URL=...
Expand Down
76 changes: 0 additions & 76 deletions apps/chatbot/src/modules/vector_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from bs4 import BeautifulSoup
from selenium import webdriver
import html2text
import s3fs

from llama_index.core import (
Settings,
Expand Down Expand Up @@ -266,81 +265,6 @@ def build_automerging_index_redis(
return automerging_index


def load_url_hash_table(
s3_bucket_name: str | None,
) -> dict:

if s3_bucket_name:
logging.info("Getting URLs hash table from S3 bucket...")
with FS.open(f"{s3_bucket_name}/hash_table.json", "r") as f:
hash_table = json.load(f)

else:
logging.info("Getting URLs hash table from local...")
with open("hash_table.json", "r") as f:
hash_table = json.load(f)

logging.info("Loaded URLs hash table successfully.")
return hash_table


def load_automerging_index_s3(
llm: BaseLLM,
embed_model: BaseEmbedding,
save_dir: str,
s3_bucket_name: str,
chunk_sizes: List[int],
chunk_overlap: int,
) -> VectorStoreIndex:

Settings.llm = llm
Settings.embed_model = embed_model
Settings.node_parser = HierarchicalNodeParser.from_defaults(
chunk_sizes=chunk_sizes,
chunk_overlap=chunk_overlap
)

logging.info(f"{save_dir} directory exists! Loading vector index...")
automerging_index = load_index_from_storage(
StorageContext.from_defaults(
persist_dir = f"{s3_bucket_name}/{save_dir}",
fs = FS
)
)

logging.info("Loaded vector index successfully!")

return automerging_index


def load_automerging_index(
llm: BaseLLM,
embed_model: BaseEmbedding,
save_dir: str,
chunk_sizes: List[int],
chunk_overlap: int,
) -> VectorStoreIndex:

Settings.llm = llm
Settings.embed_model = embed_model
Settings.node_parser = HierarchicalNodeParser.from_defaults(
chunk_sizes=chunk_sizes,
chunk_overlap=chunk_overlap
)

logging.info(f"{save_dir} directory exists! Loading vector index...")

automerging_index = load_index_from_storage(
StorageContext.from_defaults(
persist_dir=save_dir
)
)

logging.info("Loaded vector index successfully!")

return automerging_index


def load_automerging_index_redis(
llm: BaseLLM,
embed_model: BaseEmbedding,
Expand Down
4 changes: 2 additions & 2 deletions apps/infrastructure/src/modules/chatbot/api_gateway_rest.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ resource "aws_api_gateway_resource" "chatbot" {
}

resource "aws_api_gateway_method" "chatbot" {
for_each = toset(["GET", "POST", "PUT", "PATCH"])
for_each = toset(["GET", "POST", "PUT", "PATCH", "DELETE"])
rest_api_id = aws_api_gateway_rest_api.api.id
resource_id = aws_api_gateway_resource.chatbot.id
http_method = each.value
Expand Down Expand Up @@ -169,4 +169,4 @@ resource "aws_api_gateway_integration" "chatbot_cors" {

resource "aws_api_gateway_account" "chatbot" {
cloudwatch_role_arn = aws_iam_role.cloudwatch.arn
}
}

0 comments on commit e330123

Please sign in to comment.