| 1 | package Langertha::Engine::Mistral; | ||||||||||||||||||||
| 2 | # ABSTRACT: Mistral API | ||||||||||||||||||||
| 3 | 4 | our $VERSION = '0.502'; | |||||||||||||||||||
| 4 | 4 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 4 | ▶ | use Carp qw( croak ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 4 | ▶ | use File::ShareDir::ProjectDistDir qw( :all ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 4 | ▶ | use Module::Runtime qw( use_module ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 4 | extends 'Langertha::Engine::OpenAIBase'; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 4 | with map { 'Langertha::Role::'.$_ } qw( | |||||||||||||||||||
| 12 | Embedding | ||||||||||||||||||||
| 13 | Tools | ||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | has '+url' => ( | ||||||||||||||||||||
| 18 | lazy => 1, | ||||||||||||||||||||
| 19 | 3 | ▶ | default => sub { 'https://api.mistral.ai' }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 4 | ); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | sub _build_api_key { | ||||||||||||||||||||
| 23 | 1 | ▶ | my ( $self ) = @_; | ||||||||||||||||||
|
Subroutine
_build_api_key: called CC=2 SCAR=8.1
| |||||||||||||||||||||
| 24 | return $ENV{LANGERTHA_MISTRAL_API_KEY} | ||||||||||||||||||||
| 25 | 1 | ▶ | || croak "".(ref $self)." requires LANGERTHA_MISTRAL_API_KEY or api_key set"; | ||||||||||||||||||
|
Condition33%1/3
$ENV{'LANGERTHA_MISTRAL_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_MISTRAL_API_KEY or api_key set')
MC/DC0%0/2
$ENV{'LANGERTHA_MISTRAL_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_MISTRAL_API_KEY or api_key set')
$ENV{'LANGERTHA_MISTRAL_API_KEY'}
croak('' . ref($self) . ' requires LANGERTHA_MISTRAL_API_KEY or api_key set')
Truth table33%1/3
A || B
A= $ENV{'LANGERTHA_MISTRAL_API_KEY'}B= croak('' . ref($self) . ' requires LANGERTHA_MISTRAL_API_KEY or api_key set')
| |||||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub openapi_file { yaml => dist_file('Langertha','mistral.yaml') }; | ||||||||||||||||||
|
Subroutine
openapi_file: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | sub _build_openapi_operations { | ||||||||||||||||||||
| 31 | 2 | ▶ | return use_module('Langertha::Spec::Mistral')->data; | ||||||||||||||||||
|
Subroutine
_build_openapi_operations: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | ▶ | sub default_model { 'mistral-small-latest' } | ||||||||||||||||||
|
Subroutine
default_model: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 2 | ▶ | sub chat_operation_id { 'chat_completion_v1_chat_completions_post' } | ||||||||||||||||||
|
Subroutine
chat_operation_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 2 | ▶ | sub list_models_path { '/v1/models' } | ||||||||||||||||||
|
Subroutine
list_models_path: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | ▶ | sub embedding_operation_id { 'embeddings_v1_embeddings_post' } | ||||||||||||||||||
|
Subroutine
embedding_operation_id: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 4 | 1; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | __END__ | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =pod | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | =encoding UTF-8 | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =head1 NAME | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | Langertha::Engine::Mistral - Mistral API | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =head1 VERSION | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | version 0.502 | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =head1 SYNOPSIS | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | use Langertha::Engine::Mistral; | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | my $mistral = Langertha::Engine::Mistral->new( | ||||||||||||||||||||
| 66 | api_key => $ENV{MISTRAL_API_KEY}, | ||||||||||||||||||||
| 67 | model => 'mistral-large-latest', | ||||||||||||||||||||
| 68 | system_prompt => 'You are a helpful assistant', | ||||||||||||||||||||
| 69 | temperature => 0.5, | ||||||||||||||||||||
| 70 | ); | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | print $mistral->simple_chat('Say something nice'); | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | my $embedding = $mistral->embedding($content); | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | =head1 DESCRIPTION | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | Provides access to Mistral AI's models via their API. Composes | ||||||||||||||||||||
| 79 | L<Langertha::Role::OpenAICompatible> with Mistral's endpoint | ||||||||||||||||||||
| 80 | (C<https://api.mistral.ai>) and its OpenAPI spec. | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | Popular models: C<mistral-small-latest> (default, fast), C<mistral-large-latest> | ||||||||||||||||||||
| 83 | (most capable, 675B parameters), C<codestral-latest> (code generation), | ||||||||||||||||||||
| 84 | C<devstral-latest> (development workflows), C<pixtral-large-latest> (vision). | ||||||||||||||||||||
| 85 | Supports chat, embeddings, and tool calling; transcription is not available. | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | Dynamic model listing via C<list_models()>. Get your API key at | ||||||||||||||||||||
| 88 | L<https://docs.mistral.ai/getting-started/quickstart/> and set | ||||||||||||||||||||
| 89 | C<LANGERTHA_MISTRAL_API_KEY>. | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | B<THIS API IS WORK IN PROGRESS> | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | =head1 SEE ALSO | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =over | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =item * L<https://status.mistral.ai/> - Mistral service status | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | =item * L<https://mistral.ai/models> - Official Mistral models documentation | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =item * L<Langertha::Role::OpenAICompatible> - OpenAI API format role | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | =item * L<Langertha::Engine::DeepSeek> - Another OpenAI-compatible engine | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =back | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | =head1 SUPPORT | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | =head2 Issues | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||
| 112 | L<https://github.com/Getty/langertha/issues>. | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | =head2 IRC | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =head1 CONTRIBUTING | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =head1 AUTHOR | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | Torsten Raudssus <getty@cpan.org> | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 131 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | =cut | ||||||||||||||||||||