This release is a pre-release and may not be stable for production use.
knowledgegpt
knowledgegpt is designed to gather information from various sources, including the internet and local data, which can be used to create prompts. These prompts can then be utilized by OpenAI's GPT-3 model to generate answers that are subsequently stored in a database for future reference.
To accomplish this, the text is first transformed into a fixed-size vector using either open source or OpenAI models. When a query is submitted, the text is also transformed into a vector and compared to the stored knowledge embeddings. The most relevant information is then selected and used to generate a prompt context.
knowledgegpt supports various information sources including websites, PDFs, PowerPoint files (PPTX), and documents (Docs). Additionally, it can extract text from YouTube subtitles and audio (using speech-to-text technology) and use it as a source of information. This allows for a diverse range of information to be gathered and used for generating prompts and answers.
Installation
-
PyPI installation, run in terminal:
pip install knowledgegpt -
Or you can use the latest version from the repository:
pip install -r requirements.txtand thenpip install . -
Download needed language model for parsing:
python3 -m spacy download en_core_web_sm
Set Your API Key
- Go to OpenAI > Account > Api Keys
- Create new secret key and copy
- Enter the key to example_config.py
How to use the library
# Import the library
from knowledgegpt.extractors.web_scrape_extractor import WebScrapeExtractor
# Import OpenAI and Set the API Key
import openai
from example_config import SECRET_KEY
openai.api_key = SECRET_KEY
# Define target website
url = "https://en.wikipedia.org/wiki/Bombard_(weapon)"
# Initialize the WebScrapeExtractor
scrape_website = WebScrapeExtractor( url=url, embedding_extractor="hf", model_lang="en")
# Prompt the OpenAI Model
answer, prompt, messages = scrape_website.extract(query="What is a bombard?",max_tokens=300, to_save=True, mongo_client=db)
# See the answer
print(answer)
# Output: 'A bombard is a type of large cannon used during the 14th to 15th centuries.'
Other examples can be found in the examples folder. But to give a better idea of how to use the library, here is a simple example:
# Basic Usage
basic_extractor = BaseExtractor(df)
answer, prompt, messages = basic_extractor.extract("What is the title of this PDF?", max_tokens=300)
# PDF Extraction
pdf_extractor = PDFExtractor( pdf_file_path, extraction_type="page", embedding_extractor="hf", model_lang="en")
answer, prompt, messages = pdf_extractor.extract(query, max_tokens=1500)
# PPTX Extraction
ppt_extractor = PowerpointExtractor(file_path=ppt_file_path, embedding_extractor="hf", model_lang="en")
answer, prompt, messages = ppt_extractor.extract( query,max_tokens=500)
# DOCX Extraction
docs_extractor = DocsExtractor(file_path="../example.docx", embedding_extractor="hf", model_lang="en", is_turbo=False)
answer, prompt, messages = \
docs_extractor.extract( query="What is an object detection system?", max_tokens=300)
# Extraction from Youtube video (audio)
scrape_yt_audio = YoutubeAudioExtractor(video_id=url, model_lang='tr', embedding_extractor='hf')
answer, prompt, messages = scrape_yt_audio.extract( query=query, max_tokens=1200)
# Extraction from Youtube video (transcript)
scrape_yt_subs = YTSubsExtractor(video_id=url, embedding_extractor='hf', model_lang='en')
answer, prompt, messages = scrape_yt_subs.extract( query=query, max_tokens=1200)
Docker Usage
docker build -t knowledgegptimage .
docker run -p 8888:8888 knowledgegptimage
Metadata
Release files for knowledgegpt 0.0.7b0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| knowledgegpt-0.0.7b0.tar.gz | 16.4 kB | Without provenance | Details for knowledgegpt-0.0.7b0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| knowledgegpt-0.0.7b0-py3-none-any.whl | Python 3 | none | any | Details for knowledgegpt-0.0.7b0-py3-none-any.whl |
Total release size: 39.7 kB
Release files / knowledgegpt-0.0.7b0.tar.gz
| Download URL | knowledgegpt-0.0.7b0.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8067ca980b8c38e96be6f0df23f9fda80a502541c9e132b578863000440e159
|
|
BLAKE2b-256 checksum How to use checksums |
2137595169b1857c8a26e62451ebfb8a01a5145b83a4fb30c56e47377611e008
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / knowledgegpt-0.0.7b0-py3-none-any.whl
| Download URL | knowledgegpt-0.0.7b0-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
27ff046784619e31f9b6e0a4ff19deb01dc0a90b69ca824c28872f890cfa40a9
|
|
BLAKE2b-256 checksum How to use checksums |
2da62cd778ff4288498d162388eccb6597ba46888207d98bfdbec44a1e3b0698
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for knowledgegpt 0.0.7b0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.