NAME

vim-xai.pl - A Perl script for interacting with Grok AI completion service

SYNOPSIS

use LWP::UserAgent;
use HTTP::Request;
use JSON;
use utf8;
use open ':std', ':encoding(UTF-8)';

main();

DESCRIPTION

This script is designed to interact with an AI completion service, for use within a Vim plugin. It sends a request to an AI service with user-defined parameters and processes the streaming response to update the Vim buffer in real-time.

TEASER



FUNCTIONS

main()

The main function orchestrates the script's operation:

do_msg($chunk)

Processes chunks of the streaming response:

VARIABLES

$chunk_buffer

Stores incomplete chunks of the streaming response.

$collect_messages

Accumulates the content of the AI's response for display.

@evals

An array of Vim variables to evaluate for configuration.

$xai_xd_obj

A JSON object representing the request to the AI service.

$json_string

The JSON encoded string of the request object.

$headers

HTTP headers for the request, including authentication.

$ua

An instance of LWP::UserAgent for making HTTP requests.

$req

The HTTP request object.

$response

The HTTP response object from the AI service.

DEPENDENCIES

AUTHOR

Albert Mendes <tray.mendes@gmail.com>

SEE ALSO

Vim, Perl, JSON, LWP::UserAgent