Closed eliranwong closed 1 year ago
an example to search commentary on James: https://github.com/BibleTools/commentary_59_James_English/blob/main/semantic_search.py
example of search sqlite bible module:
from sqlalchemy import create_engine from llama_index import SQLDatabase, GPTSQLStructStoreIndex, StorageContext, load_index_from_storage import config, openai, os
""" An example of searching via llama_index
documentation: https://gpt-index.readthedocs.io/en/latest/index.html """
openai.api_key = os.environ["OPENAI_API_KEY"] = config.openaiApiKey openai.organization = config.openaiApiOrganization
engine = create_engine("sqlite:///AGB.bible") sql_database = SQLDatabase(engine=engine, include_tables=["Verses"])
""" index = GPTSQLStructStoreIndex( [], sql_database=sql_database, table_name="Verses", ) index.storage_context.persist(persist_dir="storage") """
storage_context = StorageContext.from_defaults(persist_dir="storage")
index = load_index_from_storage(storage_context, sql_database=sql_database)
query_engine = index.as_query_engine() response = query_engine.query("book=43, scripture contains Jesus and love") print(response) print(type(response))
will explore the possibility of using LlamaIndex for searching bibles
https://gpt-index.readthedocs.io/en/stable/