openaiunlimitedfun


Nameopenaiunlimitedfun JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/maestromaximo/OpenAiUnlimitedFuncWrapper
SummaryA comprehensive wrapper for the OpenAI API, facilitating seamless interaction with GPT models. Features include conversation management, dynamic function execution, and tools for creating JSON schemas for function descriptions. Simplifies setting API keys and managing chat contexts for enhanced GPT-based applications.
upload_time2024-01-14 02:13:38
maintainer
docs_urlNone
authorAlejandro Garcia Polo
requires_python>=3.6
license
keywords openai api wrapper function_calling vectors pseudo_func
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenAI Unlimited Function Wrapper

The `openaiunlimitedfuncwrapper` is a Python package that simplifies interaction with the OpenAI API, providing easy access to various models of GPT, including conversational capabilities, dynamic function calling, and pseudo-function execution to elicit specific responses based on parameter modification.

## Features

- Single-question querying to any GPT model and receiving a response.
- Engaging in a conversation with context management.
- Dynamically adding callable functions within the code.
- Forcing execution of real or pseudo-functions to steer responses.
- Automatic and manual creation of JSON schemas for function descriptions.
- Setting the OpenAI API key via code for environment preparation.

## Installation

To install `openaiunlimitedfuncwrapper`, simply run:

```
pip install openaiunlimitedfun
```

## Setting Up Your OpenAI API Key

Before you start using the package, you need to set your OpenAI API key. You can do this by running:

```
from openaiunlimitedfun import set_openai_api_key

set_openai_api_key('your-api-key-here')
```

This will create or append to a `.env` file in your current directory, storing your API key.

## Managing Available Functions

To make custom functions available for the OpenAI API to call during a conversation, use the `manage_available_functions` function:

```
from openaiunlimitedfun import manage_available_functions

# To save current module's functions
manage_available_functions(retrieve=False)

# To retrieve available functions
functions = manage_available_functions()
```

## Adding Functions to the Function List

If you want to add specific functions to be accessible during the conversation, use `manage_function_list`:

```
from openaiunlimitedfun import manage_function_list

# To add a function to the list
manage_function_list(function_to_add='your_function_name')

# To retrieve the list of functions
function_list = manage_function_list(retrieve=True)
```

## Generating JSON Schemas for Functions

You can create JSON schemas for your functions automatically or manually. This can be used to generate function descriptions for use within the wrapper.

### Automatic JSON Schema Generation

Automatically generate a JSON schema based on user input:

```
from openaiunlimitedfun import create_json_autoagent

schema = create_json_autoagent('Describe a function that calculates the sum of two numbers.')
print(schema)
```

### Manual JSON Schema Creation

Manually create a JSON schema through an interactive prompt:

```
from openaiunlimitedfun import create_function_json_manual

create_function_json_manual()
# Follow the interactive prompts to create your function JSON schema.
```

## Usage Examples

### Single Question

Query a single question and get a response:

```
from openaiunlimitedfun import single_question

response = single_question("What is the capital of France?")
print(response)
```

### Conversational Context

Engage in a conversation with the ability to maintain context:

```
from openaiunlimitedfun import chat_context_function_bank

question = "Who wrote the play Hamlet?"
context = []  # This should be a list of previous messages if you have them

response, updated_context = chat_context_function_bank(question, context)
print(response)
```

### Pseudo-Function Execution

Force the execution of a pseudo-function to get a desired response:

```
from openaiunlimitedfun import single_turn_pseudofunction

# Define a pseudo-function
pseudo_function = {
    "name": "calculate_sum",
    "parameters": {
        "number1": 5,
        "number2": 3
    }
}

# Use the pseudo-function in a prompt
response = single_turn_pseudofunction("What is the sum of the numbers?", pseudo_function)
print(response)
```

## Contributing

Contributions are welcome! Please feel free to submit pull requests, report bugs, and suggest features.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

#### Build

- If you want to run a new pip build make sure to actiavte an enviroment, run pip install -r requirement.txt
- Then be sure to run ```Remove-Item -Recurse -Force build, dist, *.egg-info``` if you had run a build before, else it would return an error
- Then run python ```setup.py sdist bdist_wheel```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/maestromaximo/OpenAiUnlimitedFuncWrapper",
    "name": "openaiunlimitedfun",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "openai,api,wrapper,function_calling,vectors,pseudo_func",
    "author": "Alejandro Garcia Polo",
    "author_email": "alejandrogarcia2423@hotmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ea/78/862a8a48816f9c3bcb4d20bafd95075532353defa343c8d42c1dec9bb8aa/openaiunlimitedfun-0.1.1.tar.gz",
    "platform": null,
    "description": "# OpenAI Unlimited Function Wrapper\r\n\r\nThe `openaiunlimitedfuncwrapper` is a Python package that simplifies interaction with the OpenAI API, providing easy access to various models of GPT, including conversational capabilities, dynamic function calling, and pseudo-function execution to elicit specific responses based on parameter modification.\r\n\r\n## Features\r\n\r\n- Single-question querying to any GPT model and receiving a response.\r\n- Engaging in a conversation with context management.\r\n- Dynamically adding callable functions within the code.\r\n- Forcing execution of real or pseudo-functions to steer responses.\r\n- Automatic and manual creation of JSON schemas for function descriptions.\r\n- Setting the OpenAI API key via code for environment preparation.\r\n\r\n## Installation\r\n\r\nTo install `openaiunlimitedfuncwrapper`, simply run:\r\n\r\n```\r\npip install openaiunlimitedfun\r\n```\r\n\r\n## Setting Up Your OpenAI API Key\r\n\r\nBefore you start using the package, you need to set your OpenAI API key. You can do this by running:\r\n\r\n```\r\nfrom openaiunlimitedfun import set_openai_api_key\r\n\r\nset_openai_api_key('your-api-key-here')\r\n```\r\n\r\nThis will create or append to a `.env` file in your current directory, storing your API key.\r\n\r\n## Managing Available Functions\r\n\r\nTo make custom functions available for the OpenAI API to call during a conversation, use the `manage_available_functions` function:\r\n\r\n```\r\nfrom openaiunlimitedfun import manage_available_functions\r\n\r\n# To save current module's functions\r\nmanage_available_functions(retrieve=False)\r\n\r\n# To retrieve available functions\r\nfunctions = manage_available_functions()\r\n```\r\n\r\n## Adding Functions to the Function List\r\n\r\nIf you want to add specific functions to be accessible during the conversation, use `manage_function_list`:\r\n\r\n```\r\nfrom openaiunlimitedfun import manage_function_list\r\n\r\n# To add a function to the list\r\nmanage_function_list(function_to_add='your_function_name')\r\n\r\n# To retrieve the list of functions\r\nfunction_list = manage_function_list(retrieve=True)\r\n```\r\n\r\n## Generating JSON Schemas for Functions\r\n\r\nYou can create JSON schemas for your functions automatically or manually. This can be used to generate function descriptions for use within the wrapper.\r\n\r\n### Automatic JSON Schema Generation\r\n\r\nAutomatically generate a JSON schema based on user input:\r\n\r\n```\r\nfrom openaiunlimitedfun import create_json_autoagent\r\n\r\nschema = create_json_autoagent('Describe a function that calculates the sum of two numbers.')\r\nprint(schema)\r\n```\r\n\r\n### Manual JSON Schema Creation\r\n\r\nManually create a JSON schema through an interactive prompt:\r\n\r\n```\r\nfrom openaiunlimitedfun import create_function_json_manual\r\n\r\ncreate_function_json_manual()\r\n# Follow the interactive prompts to create your function JSON schema.\r\n```\r\n\r\n## Usage Examples\r\n\r\n### Single Question\r\n\r\nQuery a single question and get a response:\r\n\r\n```\r\nfrom openaiunlimitedfun import single_question\r\n\r\nresponse = single_question(\"What is the capital of France?\")\r\nprint(response)\r\n```\r\n\r\n### Conversational Context\r\n\r\nEngage in a conversation with the ability to maintain context:\r\n\r\n```\r\nfrom openaiunlimitedfun import chat_context_function_bank\r\n\r\nquestion = \"Who wrote the play Hamlet?\"\r\ncontext = []  # This should be a list of previous messages if you have them\r\n\r\nresponse, updated_context = chat_context_function_bank(question, context)\r\nprint(response)\r\n```\r\n\r\n### Pseudo-Function Execution\r\n\r\nForce the execution of a pseudo-function to get a desired response:\r\n\r\n```\r\nfrom openaiunlimitedfun import single_turn_pseudofunction\r\n\r\n# Define a pseudo-function\r\npseudo_function = {\r\n    \"name\": \"calculate_sum\",\r\n    \"parameters\": {\r\n        \"number1\": 5,\r\n        \"number2\": 3\r\n    }\r\n}\r\n\r\n# Use the pseudo-function in a prompt\r\nresponse = single_turn_pseudofunction(\"What is the sum of the numbers?\", pseudo_function)\r\nprint(response)\r\n```\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please feel free to submit pull requests, report bugs, and suggest features.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\r\n\r\n#### Build\r\n\r\n- If you want to run a new pip build make sure to actiavte an enviroment, run pip install -r requirement.txt\r\n- Then be sure to run ```Remove-Item -Recurse -Force build, dist, *.egg-info``` if you had run a build before, else it would return an error\r\n- Then run python ```setup.py sdist bdist_wheel```\r\n\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A comprehensive wrapper for the OpenAI API, facilitating seamless interaction with GPT models. Features include conversation management, dynamic function execution, and tools for creating JSON schemas for function descriptions. Simplifies setting API keys and managing chat contexts for enhanced GPT-based applications.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/maestromaximo/OpenAiUnlimitedFuncWrapper"
    },
    "split_keywords": [
        "openai",
        "api",
        "wrapper",
        "function_calling",
        "vectors",
        "pseudo_func"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7c8eb49feb2d716497cb4e4369f96babf4948a367b9eaca825272f523bb38bea",
                "md5": "60e7712160a399348b62205967535d8b",
                "sha256": "75fa048c355151d398f03b581f040dbac9015387bf6ab7859ca1482556dd8917"
            },
            "downloads": -1,
            "filename": "openaiunlimitedfun-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "60e7712160a399348b62205967535d8b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 9737,
            "upload_time": "2024-01-14T02:13:36",
            "upload_time_iso_8601": "2024-01-14T02:13:36.784907Z",
            "url": "https://files.pythonhosted.org/packages/7c/8e/b49feb2d716497cb4e4369f96babf4948a367b9eaca825272f523bb38bea/openaiunlimitedfun-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ea78862a8a48816f9c3bcb4d20bafd95075532353defa343c8d42c1dec9bb8aa",
                "md5": "cb571075df60fd92bd10e9f42f8037fa",
                "sha256": "6c2b9e22694199346627bd11d2b8a0247c7526f55cfc77064f9978951f3c95c0"
            },
            "downloads": -1,
            "filename": "openaiunlimitedfun-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "cb571075df60fd92bd10e9f42f8037fa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 11144,
            "upload_time": "2024-01-14T02:13:38",
            "upload_time_iso_8601": "2024-01-14T02:13:38.579727Z",
            "url": "https://files.pythonhosted.org/packages/ea/78/862a8a48816f9c3bcb4d20bafd95075532353defa343c8d42c1dec9bb8aa/openaiunlimitedfun-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-14 02:13:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "maestromaximo",
    "github_project": "OpenAiUnlimitedFuncWrapper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "openaiunlimitedfun"
}
        
Elapsed time: 0.16471s