textEmbedding {chatAI4R}R Documentation

Text Embedding from OpenAI Embeddings API

Description

This function calls the OpenAI Embeddings API to get the multidimensional vector via text embedding of the input text. This function uses the 'text-embedding-ada-002' model.

Usage

textEmbedding(text, api_key = Sys.getenv("OPENAI_API_KEY"))

Arguments

text

A string. The input text to get the embedding for. This should be a character string.

api_key

A string. The API key for the OpenAI API. Defaults to the value of the environment variable "OPENAI_API_KEY".

Value

A vector representing the text embeddings.

Author(s)

Satoshi Kume

Examples

## Not run: 
Sys.setenv(OPENAI_API_KEY = "Your API key")
textEmbedding("Hello, world!")

## End(Not run)

[Package chatAI4R version 0.2.10 Index]