% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/groq_function.R
\name{groq_func}
\alias{groq_func}
\title{Process Text Data Using GROQ AI API}
\usage{
groq_func(data_subset, n_post, coding_instruction, worker_env = NULL)
}
\arguments{
\item{data_subset}{Data frame. Subset of text data to process. Must contain
columns specified by \code{id_column} and \code{text_column} parameters (set via \code{set_parameters()}).}

\item{n_post}{Integer. Number of posts to process in this batch.}

\item{coding_instruction}{Character. Instructions for the AI model specifying
how to extract and format variables from the text.}

\item{worker_env}{Environment or NULL. When running in a parallel worker, the worker's
package environment. If NULL (default), \code{.package_env} is used.}
}
\value{
Data frame. Each row contains the AI's response for one post,
with columns named Var1, Var2, etc. Returns NULL if no posts remain after filtering.
}
\description{
This function sends text data to the GROQ AI API for variable extraction,
optimized for speed and cost efficiency. It formats the data for API consumption
and parses the CSV-formatted response.
}
\details{
The function performs several optimizations:
\itemize{
\item Filters out very short posts (< 4 characters) to reduce noise
\item Sanitizes text by replacing problematic characters (semicolons, quotes)
\item Constructs a single prompt with multiple posts for batch processing
\item Calls GROQ API with parameters from set_api_specs() (e.g. temperature, top_p)
\item Parses the response assuming CSV format with newline separators
\item Always returns a dataframe (single rows become 1-row dataframes)
}

The function expects the AI to return one line per input post in CSV format.
Trailing semicolons are automatically removed from the response.
}
\seealso{
\code{\link[=ask_groq]{ask_groq()}}, \code{\link[=gpt_func]{gpt_func()}}
}
\keyword{internal}
