Some external utilities to facilitate OpenAI's Utilites
Project description
OpenAI Utilities README
Package Name: openai-utilities
When imported, the package is referred to as openai_utils
.
Installation
To install the package, run:
pip install openai-utilities
Overview
This Python package provides utility functions for interacting with OpenAI's GPT-3.5-turbo and GPT-4 models to generate text completions and embeddings. It simplifies the process of generating text completions and embeddings.
Dependencies
openai
numpy
Importing
After installation, import the package using:
import openai_utils
Functions
AskGPT
Description
Generates text completions using OpenAI's GPT-3.5-turbo or GPT-4 models.
Parameters
model
: The GPT model to use for text generation. Available options: "gpt-3.5-turbo", "gpt-4".Context
: Can be either a string or a list of message objects.- If a string, it serves as the prompt for the text completion.
- If a list, it should contain message objects in the format
{"role": "user/system", "content": "message content"}
.
temperature
: Controls the randomness of the output (default is 1).
Returns
Returns a string containing the generated text.
Example
response = openai_utils.AskGPT(model="gpt-4", Context="How are you?", temperature=0.7)
CreateEmbedding
Description
Generates text embeddings for a given string using OpenAI's text-embedding models.
Parameters
String
: The input string for which the embedding will be generated.
Returns
Returns a list representing the generated text embedding.
Example
embedding = openai_utils.CreateEmbedding(String="Hello, world!")
Usage
First, ensure you have the openai
and numpy
packages installed. Then import the openai_utils
package and use the functions as demonstrated in the examples above.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for openai_utilties-2.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20b7f09b76e992183327ddf802b8e3993a91cbf71516eab0be9b01ad7d0d7949 |
|
MD5 | 57e6c357eaddb3f2e45d47e76158e429 |
|
BLAKE2b-256 | d17e9038172ffcf38db891fe409ebb13d823d808896edc510bf90fce04943baa |