Skip to content

Beginner friendly version of the Gemini AQA Python. Its really a bit of a mess. Now you can use this wrapper to use Gemini AQA

License

Notifications You must be signed in to change notification settings

legojrp/Gemini-AQA-Client-Wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GeminiAQA

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.

Features

  • 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.

Installation

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.

Usage

Initialization

from gemini_aqa import GeminiAQA

# Initialize the GeminiAQA client
gemini = GeminiAQA()

Create a Corpus

corpus = gemini.create_corpus(display_name="MyCorpus")

List Corpora

corpora = gemini.list_corpora()

Delete a Corpus

gemini.delete_corpus(corpus_resource_name="corpus_resource_name")

Create a Document

document = corpus.create_document(document_display_name="MyDocument")

List Documents in a Corpus

documents = corpus.list_documents()

Generate an Answer

answer = corpus.generate_answer(user_query="What is the capital of France?")

Ingest Text as a Chunk

response = document.ingest_chunk(text="This is a sample text to ingest.")

Ingest Content from a URL

response = document.ingest_url(url="https://example.com")

Ingest a Wikipedia Article

response = document.ingest_wikipedia(wikipedia_url="https://en.wikipedia.org/wiki/Python_(programming_language)")

Suppressing Logs

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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributions

Contributions are welcome! Please feel free to submit a pull request or open an issue.

Contact

Just use Github Issues to contact me honestly. If its private, use [email protected]

About

Beginner friendly version of the Gemini AQA Python. Its really a bit of a mess. Now you can use this wrapper to use Gemini AQA

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages