Aiology


NameAiology JSON
Version 0.0.6 PyPI version JSON
download
home_pageNone
SummaryAi library
upload_time2025-08-10 18:36:14
maintainerNone
docs_urlNone
authorSeyed Moied Seyedi (Single Star)
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Aiology
This is an easy to use ai communication package which you can easily setting it up and start working with it !!

To download ,and use this package : `pip install Aiology`
Have a look to our [website](https://aiology.pythonanywhere.com/) here

This package includes four modules :


## AI
By using this module you can start a text base communication with *Gemini* ai

## PDF
By using this module you can extract pdf files text (it works for Persian pdf too !!)

## TOOLS
Including Chunk ,and Database to chunk contents ,or save/remove data from database 

## Audio
Easily ask AI about your audio file or communicate by AI throw your microphone !!

Use Whisper , Google , Audio modules to communicate by AI base on audio

### Using PDF module :
This module needs four parameters which is your pdf path , use_for_telegram , collection_name ,and collection_directory:

> [!NOTE]
>
>`use_for_telegram` -> This argument isn't crucial , if you use this module for telegram bot you should set it as
>
>True ,otherwise it's False as default 
>
>`collection_name` -> This argument is used as vector database **name** when you wanna pass pdf object to AI module
>
>`collection_directory` -> This argument is used for set **vector database saving location** when you wanna pass pdf 
>
>object to AI module

```Python
#import our PDF module
from Aiology import PDF

#specify your pdf location
pdf_path = "YOUR_PDF_PATH"

#set up
pdf = PDF(pdf_path)
```

Then you can get your pdf content by using these three functions :
*get_pdf_content*
*get_pdf_page_content*
*chunk_pdf_content*

`get_pdf_content` -> extract all pdf pages content
`get_pdf_page_content` -> extract specific pdf page content
`chunk_pdf_content` -> extract pdf content (also by page number) ,then return a list of content chunks (used for AI module)

```Python
pdf.get_pdf_content() #will extract all pdf pages content
pdf.get_pdf_page_content() #will extract specific pdf page content
pdf.chunk_pdf_content() #return a list of content chunks which be used for AI module
```


If you wanna use AI module , you should use `prepare_for_ai` function before that :
*prepare_for_ai*

`prepare_for_ai` -> This function is used to make vector database for AI module ,and it gets three arguments which are **chunk_size** , **chunks_ids** ,and **page_num**

`chunk_size` -> The size of the content chunks which stored in database
`chunks_ids` -> You can pass ids for each chunks
`page_num` -> You can define a pdf page to extract and save in database

> [!WARNING]
>
>Use this function before using AI module !!

```Python
pdf.prepare_for_ai() #it will make a vector database for AI module
```


### Using AI module :
This module needs two parameters which is your *Gemini* api key , and use_for_telegram:

> [!NOTE]
>
>`use_for_telegram` -> This argument isn't crucial , if you use this module for telegram bot you should set it as
>
>True ,otherwise it's False as default 

```Python
#import our AI module
from Aiology import AI

#specify your Gemini api key
api_key = "YOUR_GEMINI_API_KEY"

#set up
ai = AI(api_key)
```

Then you can start communication by ai by these two functions :
*ask_question*
*ask_pdf_question*

`ask_question` -> Ask anything you want from Gemini by your api token
`ask_pdf_question` -> Ask about your pdf contents from Gemini by your api token

```Python
#ask anything from ai
result = ai.ask_question("YOUR_TEXT_HERE")

#print ai answer
print(result)
```

If you want to ask ai questions about your pdf file ,you should pass `PDF` which is represents your collection data to `ask_pdf_question` ,also you need to call `PDF.prepare_for_ai` before using AI module :

> [!NOTE] :
>
> `ask_pdf_question` takes 4 arguments :
>
> text -> Your text
>
> pdf -> PDF object which represent your collection data
>
>language -> You can define your output language as string (e.g "English")
>
> sensitivity -> You can define search sensitivity that how many chosen chunks of content send to ai

```Python
#import modules
from Aiology import PDF , AI

#variables
pdf_path = "YOUR_PDF_PATH"
api_key = "YOUR_GEMINI_API_KEY"

vector_database_save_address = "ADDRESS_TO_SAVE_DATABASE"
vector_database_name = "A_NAME_FOR_DATABASE"

#PDF set up
pdf = PDF(pdf_path , collection_name=vector_database_name , collection_directory=vector_database_save_address)

#Ai set up
ai = AI(api_key)

#ask about your pdf content
result = ai.ask_pdf_question("YOUR_QUESTION",[pdf],language="Persian")

#print result
print(result)
```

### Audio 
just some tips when wanna ask AI about an audio or microphone input :

> [!NOTE] :
>
>You can pass audio file to Audio module ,or you can get inputs from your microphone by setting `use_microphone` to True
>
>Then you need a model to analyze your audio ,or microphone input for AI module ,you have two options (Whisper,Google)
>
>Whisper -> Will download whisper model for the first of usage ,set `whisper_model` to any whisper model you want ,and >set `download_root` to download your whisper model there
>
>Google -> Google module doesn't need any requirements
>
>pass your audio object ,and audio modules to AI when using these two functions `ask_voice_question` ,and >`ask_question_from_voice`


# Advanced

you can do different tricks like this :

```Python
#variables
gemini_api_key = "YOUR_GEMINI_API_KEY"

#Our pdf files (when their collection name and collection directory are the same , so they are in a group)
pdf_files = [PDF("test1.pdf",collection_name="Collection-1"),PDF("test2.pdf",collection_name="Collection-1"),PDF("test3.pdf",collection_name="Collection-2"),PDF("test4.pdf",collection_name="Collection-2")]

#prepare each pdf for ai
for pdf in pdf_files:
    pdf.prepare_for_ai()

#AI
ai = AI(gemini_api_key)

#ask your question (we use pdf_paths[0] ,and pdf_paths[2] ,because their collection groups)
result = ai.ask_pdf_question("Do you know about Aiology library ?",[pdf_files[0] , pdf_files[2]],language="English")

#print result
print(result)
```

This is how to pass pdf list to ask_pdf_question function :
![pdf files with the same collection name ,and directory are in the same group](pdf-description-image.png)

# What's new ?
Reduce package size ,and fix all errors

# Conclusion
This is a powerful ,but small ai package which provide you useful tools

I hope this will be useful for you

### Single Star
### Seyed Moied Seyedi 

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "Aiology",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Seyed Moied Seyedi (Single Star)",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/d0/c4/75262616e5a554c03d61a595f57094c87bb8dce5daa67e9fa6115f62ca44/aiology-0.0.6.tar.gz",
    "platform": null,
    "description": "# Aiology\r\nThis is an easy to use ai communication package which you can easily setting it up and start working with it !!\r\n\r\nTo download ,and use this package : `pip install Aiology`\r\nHave a look to our [website](https://aiology.pythonanywhere.com/) here\r\n\r\nThis package includes four modules :\r\n\r\n\r\n## AI\r\nBy using this module you can start a text base communication with *Gemini* ai\r\n\r\n## PDF\r\nBy using this module you can extract pdf files text (it works for Persian pdf too !!)\r\n\r\n## TOOLS\r\nIncluding Chunk ,and Database to chunk contents ,or save/remove data from database \r\n\r\n## Audio\r\nEasily ask AI about your audio file or communicate by AI throw your microphone !!\r\n\r\nUse Whisper , Google , Audio modules to communicate by AI base on audio\r\n\r\n### Using PDF module :\r\nThis module needs four parameters which is your pdf path , use_for_telegram , collection_name ,and collection_directory:\r\n\r\n> [!NOTE]\r\n>\r\n>`use_for_telegram` -> This argument isn't crucial , if you use this module for telegram bot you should set it as\r\n>\r\n>True ,otherwise it's False as default \r\n>\r\n>`collection_name` -> This argument is used as vector database **name** when you wanna pass pdf object to AI module\r\n>\r\n>`collection_directory` -> This argument is used for set **vector database saving location** when you wanna pass pdf \r\n>\r\n>object to AI module\r\n\r\n```Python\r\n#import our PDF module\r\nfrom Aiology import PDF\r\n\r\n#specify your pdf location\r\npdf_path = \"YOUR_PDF_PATH\"\r\n\r\n#set up\r\npdf = PDF(pdf_path)\r\n```\r\n\r\nThen you can get your pdf content by using these three functions :\r\n*get_pdf_content*\r\n*get_pdf_page_content*\r\n*chunk_pdf_content*\r\n\r\n`get_pdf_content` -> extract all pdf pages content\r\n`get_pdf_page_content` -> extract specific pdf page content\r\n`chunk_pdf_content` -> extract pdf content (also by page number) ,then return a list of content chunks (used for AI module)\r\n\r\n```Python\r\npdf.get_pdf_content() #will extract all pdf pages content\r\npdf.get_pdf_page_content() #will extract specific pdf page content\r\npdf.chunk_pdf_content() #return a list of content chunks which be used for AI module\r\n```\r\n\r\n\r\nIf you wanna use AI module , you should use `prepare_for_ai` function before that :\r\n*prepare_for_ai*\r\n\r\n`prepare_for_ai` -> This function is used to make vector database for AI module ,and it gets three arguments which are **chunk_size** , **chunks_ids** ,and **page_num**\r\n\r\n`chunk_size` -> The size of the content chunks which stored in database\r\n`chunks_ids` -> You can pass ids for each chunks\r\n`page_num` -> You can define a pdf page to extract and save in database\r\n\r\n> [!WARNING]\r\n>\r\n>Use this function before using AI module !!\r\n\r\n```Python\r\npdf.prepare_for_ai() #it will make a vector database for AI module\r\n```\r\n\r\n\r\n### Using AI module :\r\nThis module needs two parameters which is your *Gemini* api key , and use_for_telegram:\r\n\r\n> [!NOTE]\r\n>\r\n>`use_for_telegram` -> This argument isn't crucial , if you use this module for telegram bot you should set it as\r\n>\r\n>True ,otherwise it's False as default \r\n\r\n```Python\r\n#import our AI module\r\nfrom Aiology import AI\r\n\r\n#specify your Gemini api key\r\napi_key = \"YOUR_GEMINI_API_KEY\"\r\n\r\n#set up\r\nai = AI(api_key)\r\n```\r\n\r\nThen you can start communication by ai by these two functions :\r\n*ask_question*\r\n*ask_pdf_question*\r\n\r\n`ask_question` -> Ask anything you want from Gemini by your api token\r\n`ask_pdf_question` -> Ask about your pdf contents from Gemini by your api token\r\n\r\n```Python\r\n#ask anything from ai\r\nresult = ai.ask_question(\"YOUR_TEXT_HERE\")\r\n\r\n#print ai answer\r\nprint(result)\r\n```\r\n\r\nIf you want to ask ai questions about your pdf file ,you should pass `PDF` which is represents your collection data to `ask_pdf_question` ,also you need to call `PDF.prepare_for_ai` before using AI module :\r\n\r\n> [!NOTE] :\r\n>\r\n> `ask_pdf_question` takes 4 arguments :\r\n>\r\n> text -> Your text\r\n>\r\n> pdf -> PDF object which represent your collection data\r\n>\r\n>language -> You can define your output language as string (e.g \"English\")\r\n>\r\n> sensitivity -> You can define search sensitivity that how many chosen chunks of content send to ai\r\n\r\n```Python\r\n#import modules\r\nfrom Aiology import PDF , AI\r\n\r\n#variables\r\npdf_path = \"YOUR_PDF_PATH\"\r\napi_key = \"YOUR_GEMINI_API_KEY\"\r\n\r\nvector_database_save_address = \"ADDRESS_TO_SAVE_DATABASE\"\r\nvector_database_name = \"A_NAME_FOR_DATABASE\"\r\n\r\n#PDF set up\r\npdf = PDF(pdf_path , collection_name=vector_database_name , collection_directory=vector_database_save_address)\r\n\r\n#Ai set up\r\nai = AI(api_key)\r\n\r\n#ask about your pdf content\r\nresult = ai.ask_pdf_question(\"YOUR_QUESTION\",[pdf],language=\"Persian\")\r\n\r\n#print result\r\nprint(result)\r\n```\r\n\r\n### Audio \r\njust some tips when wanna ask AI about an audio or microphone input :\r\n\r\n> [!NOTE] :\r\n>\r\n>You can pass audio file to Audio module ,or you can get inputs from your microphone by setting `use_microphone` to True\r\n>\r\n>Then you need a model to analyze your audio ,or microphone input for AI module ,you have two options (Whisper,Google)\r\n>\r\n>Whisper -> Will download whisper model for the first of usage ,set `whisper_model` to any whisper model you want ,and >set `download_root` to download your whisper model there\r\n>\r\n>Google -> Google module doesn't need any requirements\r\n>\r\n>pass your audio object ,and audio modules to AI when using these two functions `ask_voice_question` ,and >`ask_question_from_voice`\r\n\r\n\r\n# Advanced\r\n\r\nyou can do different tricks like this :\r\n\r\n```Python\r\n#variables\r\ngemini_api_key = \"YOUR_GEMINI_API_KEY\"\r\n\r\n#Our pdf files (when their collection name and collection directory are the same , so they are in a group)\r\npdf_files = [PDF(\"test1.pdf\",collection_name=\"Collection-1\"),PDF(\"test2.pdf\",collection_name=\"Collection-1\"),PDF(\"test3.pdf\",collection_name=\"Collection-2\"),PDF(\"test4.pdf\",collection_name=\"Collection-2\")]\r\n\r\n#prepare each pdf for ai\r\nfor pdf in pdf_files:\r\n    pdf.prepare_for_ai()\r\n\r\n#AI\r\nai = AI(gemini_api_key)\r\n\r\n#ask your question (we use pdf_paths[0] ,and pdf_paths[2] ,because their collection groups)\r\nresult = ai.ask_pdf_question(\"Do you know about Aiology library ?\",[pdf_files[0] , pdf_files[2]],language=\"English\")\r\n\r\n#print result\r\nprint(result)\r\n```\r\n\r\nThis is how to pass pdf list to ask_pdf_question function :\r\n![pdf files with the same collection name ,and directory are in the same group](pdf-description-image.png)\r\n\r\n# What's new ?\r\nReduce package size ,and fix all errors\r\n\r\n# Conclusion\r\nThis is a powerful ,but small ai package which provide you useful tools\r\n\r\nI hope this will be useful for you\r\n\r\n### Single Star\r\n### Seyed Moied Seyedi \r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Ai library",
    "version": "0.0.6",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5bf3b122983178d93ccf69684a0f890002cb18e5f2371345a106f0da885e647e",
                "md5": "794175e97010d99af1a827d99bb0dea7",
                "sha256": "9c139aacbe9cdd599256b3c05dd12118f18c7dc3b46eeb24df2a252706543103"
            },
            "downloads": -1,
            "filename": "aiology-0.0.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "794175e97010d99af1a827d99bb0dea7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10432,
            "upload_time": "2025-08-10T18:36:13",
            "upload_time_iso_8601": "2025-08-10T18:36:13.299868Z",
            "url": "https://files.pythonhosted.org/packages/5b/f3/b122983178d93ccf69684a0f890002cb18e5f2371345a106f0da885e647e/aiology-0.0.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d0c475262616e5a554c03d61a595f57094c87bb8dce5daa67e9fa6115f62ca44",
                "md5": "331b249140c032628743cfd312667bf1",
                "sha256": "ea7ba86aa637ab9debb3c7a7ec8b1487e80d31d5ffa104109176a95b2b1b08dc"
            },
            "downloads": -1,
            "filename": "aiology-0.0.6.tar.gz",
            "has_sig": false,
            "md5_digest": "331b249140c032628743cfd312667bf1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 9282,
            "upload_time": "2025-08-10T18:36:14",
            "upload_time_iso_8601": "2025-08-10T18:36:14.657208Z",
            "url": "https://files.pythonhosted.org/packages/d0/c4/75262616e5a554c03d61a595f57094c87bb8dce5daa67e9fa6115f62ca44/aiology-0.0.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-10 18:36:14",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "aiology"
}
        
Elapsed time: 0.95425s