tha::Role::JSON;
our $AUTHORITY = 'cpan:GETTY';
# ABSTRACT: Role for JSON
$Langertha::Role::JSON::VERSION = '0.008';
use Moose::Role;
use JSON::MaybeXS;
sub json { shift->_json }
has _json => (
is
_build => 1,
);
sub _build__json { JSON::MaybeXS->new( utf8 => 1, canonical => 1 ) }
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Langertha::Role::JSON - Role for JSON
=head1 VERSION
version 0.
ict;
use warnings;
use Data::Dumper;
use JSON::MaybeXS;
use Carp qw( croak );
use DDP;
use Langertha::Engine::Ollama;
use Langertha::Engine::OpenAI;
my $jsonschema = {
type => 'object',
properti
['time','action'],
additionalProperties => JSON->false,
},
},
},
required => [qw( activities )],
additionalProperties => JSON->false,
};
my $prompt = <<"__EOP__";
I want to i
nai( response_format => {
type => "json_schema",
json_schema => {
name => "training",
schema => $jsonschema,
strict => JSON->true,
},
});
my $structs
ne::Anthropic::VERSION = '0.008';
use Moose;
use Carp qw( croak );
use JSON::MaybeXS;
with 'Langertha::Role::'.$_ for (qw(
JSON
HTTP
Models
Chat
Temperature
ResponseSize
SystemPrompt
))
$request->header('x-api-key', $self->api_key);
$request->header('content-type', 'application/json');
$request->header('anthropic-version', $self->api_version);
}
has '+url' => (
lazy => 1,
mperature => 0.5,
);
print($claude->simple_chat('Generate Perl Moose classes to represent GeoJSON data types'));
=head1 DESCRIPTION
B<THIS API IS WORK IN PROGRESS>
=head1 HOW TO GET ANTHROPIC
rp qw( croak );
use JSON::MaybeXS ();
use JSON::PP ();
use OpenAPI::Modern;
use Path::Tiny;
use URI;
use YAML::PP;
requires qw(
openapi_file
generate_http_request
url
json
);
has openapi =>
n OpenAPI::Modern->new(
openapi_uri => $yaml,
openapi_schema => YAML::PP->new(boolean => 'JSON::PP')->load_string(path($yaml)->slurp_utf8),
);
}
has supported_operations => (
is => 'ro',
->{requestBody}->{content} )
? $operation->{requestBody}->{content}->{'application/json'} ? 'application/json'
: $operation->{requestBody}->{content}->{'multipart/form-data'} ? 'multipart/fo
e File::ShareDir::ProjectDistDir qw( :all );
use Carp qw( croak );
use JSON::MaybeXS;
with 'Langertha::Role::'.$_ for (qw(
JSON
HTTP
OpenAPI
Models
Temperature
ResponseSize
ResponseForm
at ) : (),
$self->has_temperature ? ( temperature => $self->temperature ) : (),
stream => JSON->false,
# $self->has_seed ? ( seed => $self->seed )
# : $self->randomize_seed ? ( seed
::ProjectDistDir qw( :all );
use Carp qw( croak );
use JSON::MaybeXS;
use Langertha::Engine::OpenAI;
with 'Langertha::Role::'.$_ for (qw(
JSON
HTTP
OpenAPI
Models
Seed
Temperature
Cont
') };
has keep_alive => (
isa => 'Str',
is => 'ro',
predicate => 'has_keep_alive',
);
has json_format => (
isa => 'Bool',
is => 'ro',
default => sub {0},
);
sub embedding_request {
my
model => $self->chat_model,
messages => $messages,
stream => JSON->false,
$self->json_format ? ( format => 'json' ) : (),
$self->has_keep_alive ? ( keep_alive => $self->keep_alive
rl
# ABSTRACT: JSON grammar test
$|=1;
use FindBin;
use lib "$FindBin::Bin/../lib";
use utf8;
use open ':std', ':encoding(UTF-8)';
use strict;
use warnings;
use Data::Dumper;
use JSON::MaybeXS;
use
s $ENV{OLLAMA_URL};
my $model = $ENV{OLLAMA_MODEL} || 'gemma2:2b';
my $jsonschema = <<'__EOS__';
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
s JSON, and your JSON always follows this specific JSON Schema:
$jsonschema
__EOP__
{
my $start = time;
my $ollamajson = Langertha::Engine::Ollama->new(
url => $ENV{OLLAMA_URL},
json_f
UTF-8)';
use strict;
use warnings;
use Data::Dumper;
use JSON::MaybeXS;
use Carp qw( croak );
use DDP;
use Langertha::Engine::Ollama;
my $jsonschema = {
type => 'object',
properties => {
des
le remove )],
additionalProperties => JSON->false,
},
},
},
required => [qw( files planning notes )],
additionalProperties => JSON->false,
};
if ($ENV{OLLAMA_URL}) {
my $ol
a->openai( response_format => {
type => "json_schema",
json_schema => {
name => "codefiles",
schema => $jsonschema,
strict => JSON->true,
},
});
my $structstart = ti
UTF-8)';
use strict;
use warnings;
use Data::Dumper;
use JSON::MaybeXS;
use Carp qw( croak );
use DDP;
use Langertha::Engine::Ollama;
my $jsonschema = {
type => 'object',
properties => {
sen
ect verb object )],
additionalProperties => JSON->false,
},
},
},
required => [qw( sentences )],
additionalProperties => JSON->false,
};
if ($ENV{OLLAMA_URL}) {
my $ollama
S response in JSON.
);
my $structured = $ollama->openai( response_format => {
type => "json_schema",
json_schema => {
name => "sentences_schema",
schema => $jsonschema,
});
my $response = $ollama->user_agent->request($request);
my $data = $ollama->json->decode($response->content);
my $reply = $request->response_call->($response);
my
ings;
use Data::Dumper;
use JSON::MaybeXS;
use POSIX qw( ceil );
use Time::HiRes qw( time );
use URI;
use Langertha::Engine::Ollama;
use Text::ASCIITable;
my $json = JSON::MaybeXS->new( utf8 => 1 )
',
});
my $response = $ollama->user_agent->request($request);
my $data = $json->decode($response->content);
my $reply = $request->response_call->($response);
my
ommon;
requires qw(
json
);
has url => (
is => 'ro',
isa => 'Str',
predicate => 'has_url',
);
sub generate_json_body {
my ( $self, %args ) = @_;
return $self->json->encode({ %args });
}
/json; charset=utf-8' )
];
my $request = Langertha::Request::HTTP->new(
http => [ uc($method), $uri, $headers, ( scalar %args > 0 ?
( !$content_type or $content_type eq 'application/json
' )
? $self->generate_json_body(%args)
: ()
: ()
) ],
request_source => $self,
response_call => $response_call,
);
if ($content_type and $content_type eq 'multi