Skip to main content
Version: 7 - Gugelhupf

ConnectorTypeOPENAI

class connector_types.connector_type_openai.ConnectorTypeOPENAI

Access OpenAI APIs

Inputs

NameTypeDefaultDescription
actionStringeditThe action to perform. Supported actions: complete and edit.
api_keyStringYour OpenAI api key. Visit https://platform.openai.com/account/api-keys to create an API key.
engineStringcode-davinci-002The name of the language model to use. See https://platform.openai.com/docs/models/overview. Must be set for action complete.
inputStringNoneThe input text to use as a starting point for the edit. Must be set for action edit.
instructionStringNoneThe instruction that tells the model how to edit the input text. Must be set for action edit.
max_tokensInteger500The maximum number of tokens that the API uses for the response. Only used for action complete.
modelStringcode-davinci-edit-001The name of the language model to use. See https://platform.openai.com/docs/models/overview. Must be set for action edit.
promptStringNoneThe prompt to send. Must be set for action complete.

Outputs

NameTypeDefaultDescription
resultobjectThe response from the OpenAI API.

Constants

input_list = ['action', 'api_key', 'engine', 'input', 'instruction', 'max_tokens', 'model', 'prompt'] output_list = ['result'] ssl_context_inputs = ['check_hostname', 'client_cert', 'client_key', 'server_ca'] version = 1

Methods

execute

log

one_of_inputs

run

Example

import flow_api

def handler(system: flow_api.System, this: flow_api.Execution):
response = this.connect(
connector_type='OPENAI',
api_key='*your secret openai api key*',
engine='text-davinci-003',
prompt='Hello world',
).get('output_value')['response']
return this.success(response)