Skip to contents

Ask ChatGPT any question you want about the text from a search_text()

Usage

gpt(
  text,
  query,
  context = "You are a scientist",
  text_col = "text",
  group_by = "id",
  CHATGPT_KEY = Sys.getenv("CHATGPT_KEY"),
  gpt_model = "gpt-3.5-turbo-1106",
  chunk_size = 500,
  chunk_overlap = 100,
  temperature = 0,
  include_query = FALSE
)

Arguments

text

The text to send to chatGPT (vector of strings, or data frame with the text in a column)

query

The query to ask of chatGPT

context

The context to send to chatGPT

text_col

The name of the text column if text is a data frame

group_by

the column(s) to group by if text is a data frame

CHATGPT_KEY

your API key for ChatGPT

gpt_model

the model name to pass to ChatOpenAI

chunk_size

text chunk size for embeddings

chunk_overlap

overlap between text chunks for embeddings

temperature

temperature value for ChatGPT (0.0 to 2.0)

include_query

Whether to include the query and context strings in the returned table

Value

a list of results

Details

You need to use your own ChatGPT API key. To avoid having to type it out, add it to the .Renviron file in the following format (you can use usethis::edit_r_environ() to access the .Renviron file)

CHATGPT_KEY="key_value_asdf"