GeminiAQA is a Python module that interacts with Google’s AI Generative Language Model. It allows you to create and manage corpora, documents, and their respective chunks. The module also provides functionalities to generate answers based on user queries and manage different Google Cloud resources.
I have not seen any other support outside of this. If there is, tell me.
- Create, List, and Delete Corpora: Easily manage corpora resources.
- Create, List, and Delete Documents: Manage documents within a corpus.
- Chunk Management: Ingest, list, and delete chunks within a document.
- Text Generation: Generate answers based on user queries.
- HTML & Wikipedia Ingestion: Ingest content from URLs and Wikipedia articles.
To use GeminiAQA, you must first install the necessary dependencies:
pip install google-auth google-cloud google-labs-html-chunker wikipedia
Make sure to set up a Google Cloud service account and save the service account key in programs/gemini/service_account_key.json
. You can find detailed instructions and documentation on how to set up a Google Cloud service account here.
from gemini_aqa import GeminiAQA
# Initialize the GeminiAQA client
gemini = GeminiAQA()
corpus = gemini.create_corpus(display_name="MyCorpus")
corpora = gemini.list_corpora()
gemini.delete_corpus(corpus_resource_name="corpus_resource_name")
document = corpus.create_document(document_display_name="MyDocument")
documents = corpus.list_documents()
answer = corpus.generate_answer(user_query="What is the capital of France?")
response = document.ingest_chunk(text="This is a sample text to ingest.")
response = document.ingest_url(url="https://example.com")
response = document.ingest_wikipedia(wikipedia_url="https://en.wikipedia.org/wiki/Python_(programming_language)")
To suppress unnecessary logs, the environment variables are set as follows:
import os
os.environ["GRPC_VERBOSITY"] = "ERROR"
os.environ["GLOG_minloglevel"] = "2"
If you dont want to deal with these envs, just delete them in the code.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please feel free to submit a pull request or open an issue.
Just use Github Issues to contact me honestly. If its private, use [email protected]