#!/usr/bin/env perl
# ABSTRACT: Simple chat with OpenAI
# PODNAME: langertha_chat_openai

use strict;
use warnings;
use Langertha::Engine::OpenAI;
use Carp qw( croak );
use Time::HiRes qw( time );

binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");

my $start = time;
my $openai = Langertha::Engine::OpenAI->new(
  $ENV{OPENAI_MODEL} ? ( model => $ENV{OPENAI_MODEL} ) : (),
);
print $openai->simple_chat(join(" ",@ARGV));
my $end = time;
printf("\n -- %.3f seconds (%s)\n", ($end - $start), $openai->model) unless $ENV{LANGERTHA_NO_TIME};

__END__

=pod

=encoding UTF-8

=head1 NAME

langertha_chat_openai - Simple chat with OpenAI

=head1 VERSION

version 0.100

=head1 SYNOPSIS

  bash$ langertha_chat_openai write a bash command that lists files older than
  5 days

  find /path/to/directory -type f -mtime +5 -exec ls -l {} \;
   -- 12.542 seconds (gpt-3.5-turbo)

=head1 DESCRIPTION

Requires OPENAI_API_KEY environment to be set.

=head1 SUPPORT

Repository

  https://github.com/Getty/langertha
  Pull request and additional contributors are welcome

Issue Tracker

  https://github.com/Getty/langertha/issues

Discord

  https://discord.gg/Y2avVYpquV 🤖

IRC

  irc://irc.perl.org/ai 🤖

=cut

=head1 SUPPORT

=head2 Issues

Please report bugs and feature requests on GitHub at
L<https://github.com/Getty/langertha/issues>.

=head1 CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

=head1 AUTHOR

Torsten Raudssus <torsten@raudssus.de> L<https://raudss.us/>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

=cut
