App-Chit

 view release on metacpan or  search on metacpan

lib/App/Chit.pm  view on Meta::CPAN

use v5.20;
use strict;
use warnings;
use experimental qw( signatures lexical_subs postderef );
use utf8::all;

package App::Chit;

use App::Cmd::Setup -app;
use App::Chit::Util ();

our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION   = '0.001001';

sub default_command {
	return "chat";
}

sub run ( $self, @args ) {
	$self->usage_error( "Set the @{[ App::Chit::Util::CHIT_KEY_VAR() ]} environment variable" )
		unless $ENV{App::Chit::Util::CHIT_KEY_VAR()};
	$self->SUPER::run( @args );
}

sub _prepare_command ( $self, $command, $opt, @args ) {
	if ( my $plugin = $self->plugin_for( $command ) ) {
		return $plugin->prepare( $self, @args );
	}
	elsif ( length $command and App::Chit::Util::find_chit_dir() ) {
		my $plugin = $self->plugin_for( $self->default_command );
		return $plugin->prepare( $self, $command, @args );
	}
	else {
		return $self->_bad_command( $command, $opt, @args );
	}
}

1;

__END__

=pod

=encoding utf-8

=head1 NAME

App::Chit - chat with AI from the command line

=head1 SYNOPSIS

  $ cd ~/Documents
  
  $ chit init --clean
  ok
  
  $ chit temperature --set 1.5
  Previous temperature:   0.99
  Setting temperature to: 1.5
  
  $ chit chat "What if I mix blue and yellow?"
  Mixing blue and yellow produces green. The exact shade of green can vary
  depending on the proportions of blue and yellow used.
  
  $ chit chat "Can you write a haiku about that colour?"
  Blue and yellow blend,
  Nature's hue emerges bright,
  Verdant whispers sing.
  
  $ chit chat "What were we just talking about?"
  We were discussing the color produced by mixing blue and yellow, which
  is green. I also wrote a haiku about that color. If you have more
  questions or want to talk about something else, feel free to let me
  know!
  
  $ cd ~/tmp
  
  $ chit init --clean
  
  $ chit chat "What were we just talking about?"
  I don't have the ability to recall past conversations. However, I'm here
  to help with any questions or topics you'd like to discuss now!



( run in 0.629 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )