Skip to main content

AI Tasks

Generate Text

Inputs:

  • prompt - Prompt (required)
  • model - Model (required)
  • temperature - Temperature (optional)
  • maxTokens - Max tokens (optional)
  • attachmentIds - Attachment ids (optional)
  • client - Client (optional)

Outputs:

  • text - Text (required)

Example:

task: "AI/GenerateText@1"
name: generateText
inputs:
prompt:
- role: "system"
content: "You are a helpful assistant that can write a short description of the product."
- role: "user"
content:
[
{
"type": "input_image",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg",
},
]
model: "gpt-3.5-turbo"
client:
apiKey: "{{ secrets.OPENAI_API_KEY }}"
baseUrl: "https://api.openai.com/v1"
temperature: 0.5
maxTokens: 100
outputs:
text: "{{ parseJson result.text }}"

JSON response using parseJson

task: "AI/GenerateText@1"
name: generateJsonResponse
inputs:
prompt:
- role: "system"
content: >
You are a helpful data generator. Please respond **only** in valid JSON format without any extra text.
The JSON object must contain the following keys:
- "status": A string indicating the result (e.g., "success").
- "message": A concise message.
- "data": An object with arbitrary key-value pairs.
- role: "user"
content: >
Generate a JSON response that confirms a successful operation and includes the current date under the "data" key.
model: "gpt-3.5-turbo"
client:
apiKey: "{{ secrets.OPENAI_API_KEY }}"
baseUrl: "https://api.openai.com/v1"
temperature: 0.3
maxTokens: 120
outputs:
response: "{{ parseJson result.text }}"