INNER CODE UNIT · Python
get_chunks
eugeneyan/obsidian-copilot · src/app.py:160
def get_chunks(query: str):
if not query:
raise ValueError(
f"Query is empty: {query}. Did you try to draft using an empty selection?"
)
# Get hits from opensearch
os_response = query_opensearch(query, os_client, INDEX_NAME)
os_hits = parse_os_response(os_response)
logger.debug(f"OS hits: {os_hits}")
# Get hits from semantic index
semantic_response = query_semantic(query, tokenizer, model, doc_embeddings_array)
semantic_hits = parse_semantic_response(semantic_response, embedding_index)
logger.debug(f"Semantic hits: {semantic_hits}")
# Get context
context = get_chunks_from_hits(os_hits + semantic_hits)
return context