ConnectorTypeOPENAI
class connector_types.connector_type_openai.ConnectorTypeOPENAI
Access OpenAI APIs
Inputs
Name | Type | Default | Description |
---|---|---|---|
action | String | edit | The action to perform. Supported actions: complete and edit . |
api_key | String | Your OpenAI api key. Visit https://platform.openai.com/account/api-keys to create an API key. | |
engine | String | code-davinci-002 | The name of the language model to use. See https://platform.openai.com/docs/models/overview. Must be set for action complete . |
input | String | None | The input text to use as a starting point for the edit. Must be set for action edit . |
instruction | String | None | The instruction that tells the model how to edit the input text. Must be set for action edit . |
max_tokens | Integer | 500 | The maximum number of tokens that the API uses for the response. Only used for action complete . |
model | String | code-davinci-edit-001 | The name of the language model to use. See https://platform.openai.com/docs/models/overview. Must be set for action edit . |
prompt | String | None | The prompt to send. Must be set for action complete . |
Outputs
Name | Type | Default | Description |
---|---|---|---|
result | object | The 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 = 1Methods
execute
details
log
details
one_of_inputs
details
run
details
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)