Name | nlp-interpreter JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | A package for translating Natural language using NLP processing with Ollama and Gemini into actions. |
upload_time | 2024-05-11 13:44:24 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License Copyright (c) [2024] [Iyaad Luqman K] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
nlp
ai
language-processing
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# NLP Interpreter Documentation
## Description
The NLP Interpreter is a system designed to leverage the power of natural language processing (NLP) to classify textual data into user-defined categories. It offers a flexible and dynamic approach to text analysis, allowing users to specify the categories or actions they are interested in. This system is particularly useful for applications that require the categorization of text into predefined options, enhancing the automation and understanding of textual data.
## Installation
- Install the library
```bash
pip3 install nlp_interpreter
```
- Add the GEMINI API key to the `.env` file, if you want to use the GEMINI API for text processing and classification.
```bash
GEMINI_API_KEY=your_gemini_api_key
```
## Usage
- The output of all the functions would be json
- NLP Processing Function to extract custom parameters from the user input.
```py
def nlp_process(data):
json_schema = '''{ "type": "object", "properties": { "name": { "type": "string" }, "emotion": { "type": "string" } }, "required": [ "name", "emotion" ]}'''
return process_prompt(data, model_name = "llama3", json_schema = json_schema)
```
- NLP Processing Function with GEMINI API
```py
def nlp_process(data):
json_schema = '''{ "type": "object", "properties": { "name": { "type": "string" }, "emotion": { "type": "string" } }, "required": [ "name", "emotion" ]}'''
return process_prompt(data, model_name = "gemini", json_schema = json_schema)
```
- NLP Classification Function to classify the user input into a single category.
```py
def nlp_classify(data):
options = ["create", "delete", "edit"]
return classify_prompt(data, model_name = "llama3", options = options)
```
- NLP Classification for Multiple Categories Function to classify the user input into multiple categories.
```py
def nlp_classify_into_multiple(data):
options = ["create", "delete", "edit"]
return classify_multiple_prompt(data, model_name = "llama3", options = options)
```
## Practical Use Case Example: Smart Home Assistant
### Scenario: Enhancing a Smart Home Assistant with NLP Interpretation
**Background**: Imagine a smart home ecosystem, HomeSmart, that allows users to control various IoT devices through a central assistant. Users can give voice commands to perform actions like adjusting the thermostat, turning lights on or off, playing music, or getting weather updates. However, the assistant's current command recognition system is rigid, requiring users to memorize specific phrases for each action, leading to a less user-friendly experience.
**Solution**: To make the assistant more intuitive and user-friendly, HomeSmart decides to integrate the NLP Interpreter. This integration aims to allow the assistant to understand commands given in natural language, eliminating the need for users to remember specific phrases and making the interaction more conversational.
**Implementation**:
1. **Command Definition**: HomeSmart defines a set of possible actions that the assistant can perform, such as "Adjust Temperature", "Control Lights", "Play Music", and "Weather Update".
2. **NLP Interpreter Integration**: The assistant is integrated with the NLP Interpreter, which is configured to classify user commands into one of the predefined actions based on natural language input.
3. **Dynamic Interaction**: When a user gives a command, the assistant uses the NLP Interpreter to understand the intent and context of the command, mapping it to the corresponding action.
4. **Action Execution**: Once the command is classified, the assistant executes the associated action, such as adjusting the thermostat or turning on the lights.
**Benefits**:
- **Improved User Experience**: Users can interact with the assistant in a more natural and intuitive way, without needing to remember specific command phrases.
- **Flexibility**: The system can easily adapt to new commands or actions as the product evolves, thanks to the dynamic classification capabilities of the NLP Interpreter.
- **Scalability**: The NLP Interpreter can handle a wide range of commands and variations in natural language, making the system robust and scalable.
- **Efficiency**: Automating command interpretation reduces the need for manual updates to the command recognition system, saving time and resources.
**Outcome**: After integrating the NLP Interpreter, HomeSmart notices a significant improvement in user satisfaction. Users find the assistant more responsive and easier to use, leading to increased engagement and usage of the smart home ecosystem. The assistant's ability to understand a wide range of natural language commands also reduces user frustration and enhances the overall smart home experience.
This practical use case demonstrates how the NLP Interpreter can be used to parse natural language input and provide applications with the context needed to take appropriate actions, acting as a bridge between human language and machine-executable commands.
## Use Cases
- **Dynamic Text Classification**: Allows users to define their own categories or options for classification, making the system highly adaptable to various needs.
- **GEMINI API Support**: Offers an alternative to the Ollama model for users who prefer or require GEMINI API for text processing and classification.
- **Content Moderation**: Analyze user-generated content to identify and categorize based on predefined criteria, aiding in moderation efforts.
- **Data Extraction**: Extract specific information from unstructured text inputs for data analysis or entry into structured databases.
## Functionalities
- **User-defined Classification**: Classifies text based on categories or options provided by the user.
- **Multiple Model Support**: Supports both the GEMINI API and the Ollama model for text classification, providing flexibility in choosing the underlying NLP technology.
- **Error Handling**: Implements robust error handling to ensure accurate and reliable classification results.
## Advantages
- **Customizability**: Users can define their own categories, making the system highly adaptable.
- **Flexibility**: Supports multiple NLP backends (GEMINI API and Ollama model), allowing users to choose the one that best fits their needs.
- **Ease of Integration**: The Flask-based API facilitates easy integration into existing systems or workflows.
## Error Handling
The system includes comprehensive error handling to ensure the accuracy of classifications. It checks the NLP model's response to ensure it aligns with the user-defined criteria. In cases where the response does not meet these criteria, the system can modify the prompt and retry or provide informative errors, enhancing reliability even in complex scenarios.
### Types of Cases It Can Handle:
- **Valid Responses**: Directly returns the model's response if it aligns with the user-defined criteria.
- **Invalid Responses**: Attempts to guide the model towards a valid output by modifying the prompt and retrying.
- **Error Conditions**: Provides detailed error messages if issues arise during model initialization or if the response does not meet the criteria after retries.
Raw data
{
"_id": null,
"home_page": null,
"name": "nlp-interpreter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "nlp, AI, language-processing",
"author": null,
"author_email": "Iyaad Luqman K <iyaadluq@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b1/fd/796f7f821ffe06609ddaca1885ed704f2e1d9fdcf0943a8dea1b2ca9959d/nlp_interpreter-1.0.0.tar.gz",
"platform": null,
"description": "# NLP Interpreter Documentation\n\n## Description\n\nThe NLP Interpreter is a system designed to leverage the power of natural language processing (NLP) to classify textual data into user-defined categories. It offers a flexible and dynamic approach to text analysis, allowing users to specify the categories or actions they are interested in. This system is particularly useful for applications that require the categorization of text into predefined options, enhancing the automation and understanding of textual data.\n\n## Installation\n- Install the library \n```bash\npip3 install nlp_interpreter\n```\n- Add the GEMINI API key to the `.env` file, if you want to use the GEMINI API for text processing and classification.\n```bash\nGEMINI_API_KEY=your_gemini_api_key\n```\n\n## Usage\n- The output of all the functions would be json \n\n- NLP Processing Function to extract custom parameters from the user input.\n \n```py\ndef nlp_process(data):\n json_schema = '''{ \"type\": \"object\", \"properties\": { \"name\": { \"type\": \"string\" }, \"emotion\": { \"type\": \"string\" } }, \"required\": [ \"name\", \"emotion\" ]}'''\n return process_prompt(data, model_name = \"llama3\", json_schema = json_schema)\n```\n- NLP Processing Function with GEMINI API\n \n```py\ndef nlp_process(data):\n json_schema = '''{ \"type\": \"object\", \"properties\": { \"name\": { \"type\": \"string\" }, \"emotion\": { \"type\": \"string\" } }, \"required\": [ \"name\", \"emotion\" ]}'''\n return process_prompt(data, model_name = \"gemini\", json_schema = json_schema)\n```\n\n- NLP Classification Function to classify the user input into a single category.\n \n```py\ndef nlp_classify(data):\n options = [\"create\", \"delete\", \"edit\"]\n return classify_prompt(data, model_name = \"llama3\", options = options)\n```\n\n- NLP Classification for Multiple Categories Function to classify the user input into multiple categories.\n \n```py\ndef nlp_classify_into_multiple(data):\n options = [\"create\", \"delete\", \"edit\"]\n return classify_multiple_prompt(data, model_name = \"llama3\", options = options)\n```\n\n## Practical Use Case Example: Smart Home Assistant\n\n### Scenario: Enhancing a Smart Home Assistant with NLP Interpretation\n\n**Background**: Imagine a smart home ecosystem, HomeSmart, that allows users to control various IoT devices through a central assistant. Users can give voice commands to perform actions like adjusting the thermostat, turning lights on or off, playing music, or getting weather updates. However, the assistant's current command recognition system is rigid, requiring users to memorize specific phrases for each action, leading to a less user-friendly experience.\n\n**Solution**: To make the assistant more intuitive and user-friendly, HomeSmart decides to integrate the NLP Interpreter. This integration aims to allow the assistant to understand commands given in natural language, eliminating the need for users to remember specific phrases and making the interaction more conversational.\n\n**Implementation**:\n1. **Command Definition**: HomeSmart defines a set of possible actions that the assistant can perform, such as \"Adjust Temperature\", \"Control Lights\", \"Play Music\", and \"Weather Update\".\n2. **NLP Interpreter Integration**: The assistant is integrated with the NLP Interpreter, which is configured to classify user commands into one of the predefined actions based on natural language input.\n3. **Dynamic Interaction**: When a user gives a command, the assistant uses the NLP Interpreter to understand the intent and context of the command, mapping it to the corresponding action.\n4. **Action Execution**: Once the command is classified, the assistant executes the associated action, such as adjusting the thermostat or turning on the lights.\n\n**Benefits**:\n- **Improved User Experience**: Users can interact with the assistant in a more natural and intuitive way, without needing to remember specific command phrases.\n- **Flexibility**: The system can easily adapt to new commands or actions as the product evolves, thanks to the dynamic classification capabilities of the NLP Interpreter.\n- **Scalability**: The NLP Interpreter can handle a wide range of commands and variations in natural language, making the system robust and scalable.\n- **Efficiency**: Automating command interpretation reduces the need for manual updates to the command recognition system, saving time and resources.\n\n**Outcome**: After integrating the NLP Interpreter, HomeSmart notices a significant improvement in user satisfaction. Users find the assistant more responsive and easier to use, leading to increased engagement and usage of the smart home ecosystem. The assistant's ability to understand a wide range of natural language commands also reduces user frustration and enhances the overall smart home experience.\n\nThis practical use case demonstrates how the NLP Interpreter can be used to parse natural language input and provide applications with the context needed to take appropriate actions, acting as a bridge between human language and machine-executable commands.\n\n\n\n## Use Cases\n\n- **Dynamic Text Classification**: Allows users to define their own categories or options for classification, making the system highly adaptable to various needs.\n- **GEMINI API Support**: Offers an alternative to the Ollama model for users who prefer or require GEMINI API for text processing and classification.\n- **Content Moderation**: Analyze user-generated content to identify and categorize based on predefined criteria, aiding in moderation efforts.\n- **Data Extraction**: Extract specific information from unstructured text inputs for data analysis or entry into structured databases.\n\n## Functionalities\n\n- **User-defined Classification**: Classifies text based on categories or options provided by the user.\n- **Multiple Model Support**: Supports both the GEMINI API and the Ollama model for text classification, providing flexibility in choosing the underlying NLP technology.\n- **Error Handling**: Implements robust error handling to ensure accurate and reliable classification results.\n\n## Advantages\n\n- **Customizability**: Users can define their own categories, making the system highly adaptable.\n- **Flexibility**: Supports multiple NLP backends (GEMINI API and Ollama model), allowing users to choose the one that best fits their needs.\n- **Ease of Integration**: The Flask-based API facilitates easy integration into existing systems or workflows.\n\n## Error Handling\n\nThe system includes comprehensive error handling to ensure the accuracy of classifications. It checks the NLP model's response to ensure it aligns with the user-defined criteria. In cases where the response does not meet these criteria, the system can modify the prompt and retry or provide informative errors, enhancing reliability even in complex scenarios.\n\n### Types of Cases It Can Handle:\n\n- **Valid Responses**: Directly returns the model's response if it aligns with the user-defined criteria.\n- **Invalid Responses**: Attempts to guide the model towards a valid output by modifying the prompt and retrying.\n- **Error Conditions**: Provides detailed error messages if issues arise during model initialization or if the response does not meet the criteria after retries.\n\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) [2024] [Iyaad Luqman K] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "A package for translating Natural language using NLP processing with Ollama and Gemini into actions.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/Iyaad-luqman/nlp_interpreter"
},
"split_keywords": [
"nlp",
" ai",
" language-processing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "fad03f095401c028e2316736ab132c7024ab5739f48469ec7e6d54487b970094",
"md5": "28af3b3ae20185a70f5927f9a3a60d6c",
"sha256": "767bbfcc0e212657d1994ddefbca8608eefdb293edadd2e0de3db4acd934e9c3"
},
"downloads": -1,
"filename": "nlp_interpreter-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "28af3b3ae20185a70f5927f9a3a60d6c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9210,
"upload_time": "2024-05-11T13:44:22",
"upload_time_iso_8601": "2024-05-11T13:44:22.383810Z",
"url": "https://files.pythonhosted.org/packages/fa/d0/3f095401c028e2316736ab132c7024ab5739f48469ec7e6d54487b970094/nlp_interpreter-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b1fd796f7f821ffe06609ddaca1885ed704f2e1d9fdcf0943a8dea1b2ca9959d",
"md5": "c0df1da0fe67be073759aa1768826ab7",
"sha256": "6b3f3c1039964f62e80cff78b2cbdd8279d027e8fefbf1227831d60a0ce56449"
},
"downloads": -1,
"filename": "nlp_interpreter-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "c0df1da0fe67be073759aa1768826ab7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 10686,
"upload_time": "2024-05-11T13:44:24",
"upload_time_iso_8601": "2024-05-11T13:44:24.714626Z",
"url": "https://files.pythonhosted.org/packages/b1/fd/796f7f821ffe06609ddaca1885ed704f2e1d9fdcf0943a8dea1b2ca9959d/nlp_interpreter-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-11 13:44:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Iyaad-luqman",
"github_project": "nlp_interpreter",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "nlp-interpreter"
}