openai-utilties


Nameopenai-utilties JSON
Version 3.6 PyPI version JSON
download
home_pagehttps://github.com/SimplyYourAverageDev/openai_utils
SummarySome external utilities to facilitate OpenAI's Utilites
upload_time2024-03-05 22:30:18
maintainer
docs_urlNone
authorYourAverageDev
requires_python
licenseMIT
keywords openai utilities
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OpenAI Utility Library

This library provides a set of utility functions to interact with OpenAI's API, focusing on generating chat responses, creating text embeddings, formatting response data, and generating images from prompts. It leverages the OpenAI Python client to facilitate these tasks.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Functions](#functions)
  - [generate_chat_response](#generate_chat_response)
  - [create_text_embedding](#create_text_embedding)
  - [format_response_data](#format_response_data)
  - [generate_image_from_prompt](#generate_image_from_prompt)
- [Examples](#examples)
- [Contributing](#contributing)
- [License](#license)

## Installation

To use this library, you need to have Python installed on your system. You also need to install the OpenAI Python client. You can do this by running the following command in your terminal:

```bash
pip install openai
```

## Usage

To use the functions provided by this library, you need to import the library and then call the desired function. Here's a basic example:

```python
import openai_utility_library as oai

# Generate a chat response
context = "Hello, how can I help you today?"
response = oai.generate_chat_response(context)
print(response)

# Create a text embedding
input_string = "This is a sample text."
embedding = oai.create_text_embedding(input_string)
print(embedding)

# Format response data
formatted_data = oai.format_response_data(response)
print(formatted_data)

# Generate an image from a prompt
prompt = "A beautiful sunset over the ocean."
image = oai.generate_image_from_prompt(prompt)
print(image)
```

## Functions

### generate_chat_response

This function generates a chat response based on the provided context. It supports both string and list inputs for the context.

- **Parameters:**
  - `context`: The context for the chat response. Can be a string or a list of message objects.
  - `model`: The model to use for generating the response. Default is "gpt-3.5-turbo-1106".
  - `temperature`: The temperature for the model. Default is  1.
- **Returns:** The generated chat response as a string.

### create_text_embedding

This function creates a text embedding for the given input string.

- **Parameters:**
  - `input_string`: The string for which to create the text embedding.
- **Returns:** A list representing the text embedding.

### format_response_data

This function formats the response data from OpenAI's API into a more readable format.

- **Parameters:**
  - `response`: The response object from OpenAI's API.
- **Returns:** A dictionary containing the formatted response data.

### generate_image_from_prompt

This function generates an image based on the provided prompt.

- **Parameters:**
  - `prompt`: The prompt for generating the image.
  - `quality`: The quality of the generated image. Default is 'standard'.
- **Returns:** The generated image.

## Examples

For detailed examples on how to use each function, refer to the [Usage](#usage) section.

## Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue if you find any bugs or have suggestions for improvements.

## License

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SimplyYourAverageDev/openai_utils",
    "name": "openai-utilties",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "openai,utilities",
    "author": "YourAverageDev",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/40/94/eab4be337d9f5b4d5400192b35a4fabbecc3b937a782b25e57ba1df34d03/openai-utilties-3.6.tar.gz",
    "platform": null,
    "description": "# OpenAI Utility Library\n\nThis library provides a set of utility functions to interact with OpenAI's API, focusing on generating chat responses, creating text embeddings, formatting response data, and generating images from prompts. It leverages the OpenAI Python client to facilitate these tasks.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Functions](#functions)\n  - [generate_chat_response](#generate_chat_response)\n  - [create_text_embedding](#create_text_embedding)\n  - [format_response_data](#format_response_data)\n  - [generate_image_from_prompt](#generate_image_from_prompt)\n- [Examples](#examples)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nTo use this library, you need to have Python installed on your system. You also need to install the OpenAI Python client. You can do this by running the following command in your terminal:\n\n```bash\npip install openai\n```\n\n## Usage\n\nTo use the functions provided by this library, you need to import the library and then call the desired function. Here's a basic example:\n\n```python\nimport openai_utility_library as oai\n\n# Generate a chat response\ncontext = \"Hello, how can I help you today?\"\nresponse = oai.generate_chat_response(context)\nprint(response)\n\n# Create a text embedding\ninput_string = \"This is a sample text.\"\nembedding = oai.create_text_embedding(input_string)\nprint(embedding)\n\n# Format response data\nformatted_data = oai.format_response_data(response)\nprint(formatted_data)\n\n# Generate an image from a prompt\nprompt = \"A beautiful sunset over the ocean.\"\nimage = oai.generate_image_from_prompt(prompt)\nprint(image)\n```\n\n## Functions\n\n### generate_chat_response\n\nThis function generates a chat response based on the provided context. It supports both string and list inputs for the context.\n\n- **Parameters:**\n  - `context`: The context for the chat response. Can be a string or a list of message objects.\n  - `model`: The model to use for generating the response. Default is \"gpt-3.5-turbo-1106\".\n  - `temperature`: The temperature for the model. Default is  1.\n- **Returns:** The generated chat response as a string.\n\n### create_text_embedding\n\nThis function creates a text embedding for the given input string.\n\n- **Parameters:**\n  - `input_string`: The string for which to create the text embedding.\n- **Returns:** A list representing the text embedding.\n\n### format_response_data\n\nThis function formats the response data from OpenAI's API into a more readable format.\n\n- **Parameters:**\n  - `response`: The response object from OpenAI's API.\n- **Returns:** A dictionary containing the formatted response data.\n\n### generate_image_from_prompt\n\nThis function generates an image based on the provided prompt.\n\n- **Parameters:**\n  - `prompt`: The prompt for generating the image.\n  - `quality`: The quality of the generated image. Default is 'standard'.\n- **Returns:** The generated image.\n\n## Examples\n\nFor detailed examples on how to use each function, refer to the [Usage](#usage) section.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a pull request or open an issue if you find any bugs or have suggestions for improvements.\n\n## License\n\nThis library is licensed under the MIT License. See the LICENSE file for more details.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Some external utilities to facilitate OpenAI's Utilites",
    "version": "3.6",
    "project_urls": {
        "Homepage": "https://github.com/SimplyYourAverageDev/openai_utils"
    },
    "split_keywords": [
        "openai",
        "utilities"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fb6fbdbb5e900891033851b90f7ebe843a2cee8e3ef2f46d6d16e9cc1b25f45d",
                "md5": "2574dd98935df585d76867c016f3c5fa",
                "sha256": "bfd9f80f90a99e6b83db993718fc895317df8dca7b91b5278b345aaa848542ff"
            },
            "downloads": -1,
            "filename": "openai_utilties-3.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2574dd98935df585d76867c016f3c5fa",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3231,
            "upload_time": "2024-03-05T22:30:16",
            "upload_time_iso_8601": "2024-03-05T22:30:16.981158Z",
            "url": "https://files.pythonhosted.org/packages/fb/6f/bdbb5e900891033851b90f7ebe843a2cee8e3ef2f46d6d16e9cc1b25f45d/openai_utilties-3.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4094eab4be337d9f5b4d5400192b35a4fabbecc3b937a782b25e57ba1df34d03",
                "md5": "8119e5a53c510096660fca6e52e1ab1d",
                "sha256": "299f08bdd08f2e733ab7ff76f56ab49aecc65161d6a5861a9261f861ad969448"
            },
            "downloads": -1,
            "filename": "openai-utilties-3.6.tar.gz",
            "has_sig": false,
            "md5_digest": "8119e5a53c510096660fca6e52e1ab1d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3304,
            "upload_time": "2024-03-05T22:30:18",
            "upload_time_iso_8601": "2024-03-05T22:30:18.908916Z",
            "url": "https://files.pythonhosted.org/packages/40/94/eab4be337d9f5b4d5400192b35a4fabbecc3b937a782b25e57ba1df34d03/openai-utilties-3.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-05 22:30:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SimplyYourAverageDev",
    "github_project": "openai_utils",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "openai-utilties"
}
        
Elapsed time: 0.19737s