> Markdown versions of all pages of this connector library are available by appending `.md` to the page URL. For the full index of connectors, see [llms.txt](https://connectors.appmixer.com/llms.txt).

# appmixer.ai.openai.GenerateEmbeddingsFromFile

- Component: `appmixer.ai.openai.GenerateEmbeddingsFromFile`
- Kind: Action
- Version: 1.0.0
- Visibility: Public
- Connector: [appmixer.ai.openai 2.1.3](https://connectors.appmixer.com/connector/appmixer.ai.openai/2.1.3.md)
- Component page: <https://connectors.appmixer.com/connector/appmixer.ai.openai/2.1.3/component/appmixer.ai.openai.GenerateEmbeddingsFromFile>

Generate embeddings for a text file. The text is split into parts, each part is split into chunks and embedding is returned for each chunk. The component emits embeddings array for each file part (1MB).
The returned embeddings is an array of the form: `[{ "index": 0, "text": "chunk1", "vector": [1.1, 1.2, 1.3] }]`.
TIP: use the **JSONata modifier** to convert the embeddings array into custom formats.

## Input ports

### Port `in`

| Field | Type | Description |
| --- | --- | --- |
| File ID (`fileId`) | filepicker | The text file to generate embeddings for. Use plain text or CSV files only. |
| Model (`model`) | text | ID of the model to use. |
| Chunk Size (`chunkSize`) | number | Maximum size of each chunk for text splitting. The default is 500. |
| Chunk Overlap (`chunkOverlap`) | number | Overlap between chunks for text splitting to maintain context. The default is 50. |

## Output ports

### Port `out`

| Field | Type | Description |
| --- | --- | --- |
| Embeddings (`embeddings`) | array | - |
| First Vector (`firstVector`) | array | - |

## Full metadata (component.json)

```json
{
  "name": "appmixer.ai.openai.GenerateEmbeddingsFromFile",
  "author": "Appmixer <info@appmixer.com>",
  "description": "Generate embeddings for a text file. The text is split into parts, each part is split into chunks and embedding is returned for each chunk. The component emits embeddings array for each file part (1MB). <br/>The returned embeddings is an array of the form: <code>[{ \"index\": 0, \"text\": \"chunk1\", \"vector\": [1.1, 1.2, 1.3] }]</code>.<br/>TIP: use the <b>JSONata modifier</b> to convert the embeddings array into custom formats.",
  "auth": {
    "service": "appmixer:ai:openai"
  },
  "inPorts": [
    {
      "name": "in",
      "schema": {
        "type": "object",
        "properties": {
          "fileId": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "chunkSize": {
            "type": "integer"
          },
          "chunkOverlap": {
            "type": "integer"
          }
        },
        "required": [
          "fileId"
        ]
      },
      "inspector": {
        "inputs": {
          "fileId": {
            "label": "File ID",
            "type": "filepicker",
            "index": 1,
            "tooltip": "The text file to generate embeddings for. Use plain text or CSV files only."
          },
          "model": {
            "type": "text",
            "index": 2,
            "label": "Model",
            "tooltip": "ID of the model to use.",
            "defaultValue": "text-embedding-ada-002",
            "source": {
              "url": "/component/appmixer/ai/openai/ListModels?outPort=out",
              "data": {
                "transform": "./ListModels#toSelectOptions"
              }
            }
          },
          "chunkSize": {
            "type": "number",
            "label": "Chunk Size",
            "defaultValue": 500,
            "tooltip": "Maximum size of each chunk for text splitting. The default is 500.",
            "index": 3
          },
          "chunkOverlap": {
            "type": "number",
            "label": "Chunk Overlap",
            "defaultValue": 50,
            "tooltip": "Overlap between chunks for text splitting to maintain context. The default is 50.",
            "index": 4
          }
        }
      }
    }
  ],
  "outPorts": [
    {
      "name": "out",
      "options": [
        {
          "label": "Embeddings",
          "value": "embeddings",
          "schema": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer",
                  "title": "Index",
                  "example": 0
                },
                "vector": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  },
                  "title": "Vector",
                  "example": [
                    1.1,
                    1.2,
                    1.3
                  ]
                },
                "text": {
                  "type": "string",
                  "title": "Text",
                  "example": "chunk1"
                }
              }
            },
            "example": [
              {
                "index": 0,
                "text": "chunk1",
                "vector": [
                  1.1,
                  1.2,
                  1.3
                ]
              },
              {
                "index": 1,
                "text": "chunk2",
                "vector": [
                  2.1,
                  2.2,
                  2.3
                ]
              }
            ]
          }
        },
        {
          "label": "First Vector",
          "value": "firstVector",
          "schema": {
            "type": "array",
            "items": {
              "type": "number"
            },
            "example": [
              -0.0120379254,
              -0.0376950279,
              -0.0133513855,
              -0.0365983546,
              -0.0247007012,
              0.0158507861,
              -0.0143460445,
              0.00486809108
            ]
          }
        }
      ]
    }
  ],
  "icon": "(data URI omitted)"
}
```
