Overview

OpenAI tools allow you to interact with OpenAI’s language models, including GPT-3.5 and GPT-4. These tools support both simple text generation and structured output with JSON schemas.

Key Features

  • OPENAI_INVOKE
    • Send prompts to OpenAI models for text generation
    • Support for structured output with JSON schemas
  • OPENAI_INVOKE_WITH_FILE
    • Send files along with prompts for file-based analysis

Authentication

If you do not have an API key, you can still run OpenAI tools by using Jinba API credit. If you’d like to use your own API key, you can obtain one from the OpenAI API website. Note: Treat API keys as sensitive information and never commit them to public repositories.

Example: Basic Text Generation

- id: generate_summary
  name: generate_summary
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
    - name: temperature
      value: 0.7
  input:
    - name: prompt
      value: |
        Please summarize the following text in 3 key points:
        
        {{steps.previous_step.result.content}}

Example: Structured Output with JSON Schema

- id: extract_entities
  name: extract_entities
  tool: OPENAI_INVOKE
  config:
    - name: version
      value: gpt-4
    - name: temperature
      value: 0.1
  input:
    - name: prompt
      value: |
        Extract the following information from the text:
        - Names of people
        - Organizations
        - Locations
        - Dates
        
        Text: {{steps.input.result.content}}
    - name: json_schema
      value: |
        {
          "type": "object",
          "properties": {
            "entities": {
              "type": "object",
              "properties": {
                "people": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "organizations": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "locations": {
                  "type": "array",
                  "items": {"type": "string"}
                },
                "dates": {
                  "type": "array",
                  "items": {"type": "string"}
                }
              }
            }
          }
        }

Example: File Analysis

- id: analyze_document
  name: analyze_document
  tool: OPENAI_INVOKE_WITH_FILE
  config:
    - name: version
      value: gpt-4
  input:
    - name: prompt
      value: |
        Please analyze this document and provide:
        1. A brief summary
        2. Key topics discussed
        3. Any action items or recommendations
    - name: file_url
      value: "{{steps.upload_file.result.url}}"