OpenAI

The OpenAI AI connector enables you to connect the AI models served on the OpenAI Platform for the following tasks:

#Release Stage

Alpha

#Resource Configuration

The up-to-date configuration is maintained here.

FieldTypeNote
api_key*stringEnter your OpenAI API key. To find your keys, go to your OpenAI's Account page.

#No-code Setup

PREREQUISITES

To create a OpenAI AI connector, you'll first need to create a OpenAI account by visiting openai.com. Access to your API keys can then be managed through OpenAI's Account page.

To create a OpenAI AI connector:

  1. Go to the AI page and click Set up new AI

  2. In the Set Up New AI Connector page, fill an ID for your model, this will be the unique identifier of this connector

  3. [Optional] Give a short description of your connector in the Description field

  4. Click the AI Connector Type ▾ drop-down and choose OpenAI

  5. Fill the following information and click Set up

    • Fill API Key. Follow the OpenAI documentation to find your API key
  6. By default, the connector is disconnected. To connect and use AI connector, go to the connector page and click Connect.

#Low-code Setup

cURL(Instill-Cloud)
cURL(Instill-Core)
Copy

curl -X POST https://api.instill.tech/vdp/v1alpha/users/<user-id>/connector-resources \
--header 'Authorization: Bearer <Instill-Cloud-API-Token>' \
--data '{
"id": "my-openai",
"connector_definition_name": "connector-definitions/ai-openai",
"configuration": {
"api_key": "<open-ai-api-key>"
}
}'

For other operations, please refer to the VDP Protobufs.

#Connector Configuration

When using the OpenAI AI connector in your pipeline, certain fields of the input data need to be filled to trigger the pipeline effectively. Here are the expected input and output data fields for the OpenAI AI connector.

#Text Generation

If task is set to TASK_TEXT_GENERATION

InputTypeDescription
taskstringTASK_TEXT_GENERATION
promptstringText prompt
modelstringThe model that you want to use. eg., gpt-4 and gpt-3.5-turbo .
system_messagestringThe system message helps set the behavior of the assistant. For example, you can modify the personality of the assistant or provide specific instructions about how it should behave throughout the conversation. By default, the model's behavior is using a generic message as "You are a helpful assistant."
temperaturefloatThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
nintHow many chat completion choices to generate for each input message.
max_tokensintThe maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. Example Python code for counting tokens.
OutputTypeDescription
textsarray[string]Generated text array

#Text Embeddings

InputTypeDescription
taskstringTASK_TEXT_EMBEDDINGS
textstringText to be converted to dense vector
modelstringThe model that you want to use. eg. text-embedding-ada-002
OutputTypeDescription
embeddingarray[float]A vector embeddings

#Speech Recognition

InputTypeDescription
taskstringTASK_SPEECH_RECOGNITION
modelstringThe model that you want to use, e.g., whisper-1.
audiostringBase64 encoded audio recording to transcribe
temperaturefloatThe sampling temperature, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. If set to 0, the model will use log probability to automatically increase the temperature until certain thresholds are hit.
languagestringThe language of the input audio. Supplying the input language in ISO-639-1 format will improve accuracy and latency.
promptstringAn optional text to guide the model's style or continue a previous audio segment. The prompt should match the audio language.
OutputTypeDescription
textstringTranscribed text

#Example

Example input and output data for each task:

TASK_TEXT_GENERATION
TASK_TEXT_EMBEDDINGS
TASK_SPEECH_RECOGNITION
Copy

// Input
{
"task": "TASK_TEXT_GENERATION",
"model": "gpt-3.5-turbo",
"prompt": "Write me a story about London"
}
// Output
{
"texts": [
"Once upon a time, in the heart of England, there stood a vibrant city named London. It was a place of rich history, diverse culture, and endless possibilities. From its iconic landmarks to its bustling streets, the city had a unique charm that drew people from all walks of life..."
]
}

Last updated: 10/31/2023, 10:43:34 AM