| 1 | package Langertha::Engine::Groq; | ||||||||||||||||||||
| 2 | # ABSTRACT: GroqCloud API | ||||||||||||||||||||
| 3 | 7 | our $VERSION = '0.502'; | |||||||||||||||||||
| 4 | 7 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 7 | ▶ | use Carp qw( croak ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 7 | extends 'Langertha::Engine::OpenAIBase'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 7 | with map { 'Langertha::Role::'.$_ } qw( | |||||||||||||||||||
| 10 | Transcription | ||||||||||||||||||||
| 11 | Tools | ||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | sub _build_api_key { | ||||||||||||||||||||
| 16 | 1 | ▶ | my ( $self ) = @_; | ||||||||||||||||||
|
Subroutine
_build_api_key: called CC=2 SCAR=8.1
| |||||||||||||||||||||
| 17 | return $ENV{LANGERTHA_GROQ_API_KEY} | ||||||||||||||||||||
| 18 | 1 | ▶ | || croak "".(ref $self)." requires LANGERTHA_GROQ_API_KEY or api_key set"; | ||||||||||||||||||
|
Condition33%1/3
$ENV{'LANGERTHA_GROQ_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_GROQ_API_KEY or api_key set')
MC/DC0%0/2
$ENV{'LANGERTHA_GROQ_API_KEY'} || croak('' . ref($self) . ' requires LANGERTHA_GROQ_API_KEY or api_key set')
$ENV{'LANGERTHA_GROQ_API_KEY'}
croak('' . ref($self) . ' requires LANGERTHA_GROQ_API_KEY or api_key set')
Truth table33%1/3
A || B
A= $ENV{'LANGERTHA_GROQ_API_KEY'}B= croak('' . ref($self) . ' requires LANGERTHA_GROQ_API_KEY or api_key set')
| |||||||||||||||||||||
| 19 | } | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | has '+url' => ( | ||||||||||||||||||||
| 22 | lazy => 1, | ||||||||||||||||||||
| 23 | 4 | ▶ | default => sub { 'https://api.groq.com/openai/v1' }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 24 | 7 | ); | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub default_model { croak "".(ref $_[0])." requires a default_model" } | ||||||||||||||||||
|
Subroutine
default_model: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 0 | ▶ | sub default_transcription_model { 'whisper-large-v3' } | ||||||||||||||||||
|
Subroutine
default_transcription_model: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 3 | ▶ | sub _build_supported_operations {[qw( | ||||||||||||||||||
|
Subroutine
_build_supported_operations: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | createChatCompletion | ||||||||||||||||||||
| 32 | createTranscription | ||||||||||||||||||||
| 33 | )]} | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 7 | 1; | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | __END__ | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =pod | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | =encoding UTF-8 | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =head1 NAME | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | Langertha::Engine::Groq - GroqCloud API | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 VERSION | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | version 0.502 | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =head1 SYNOPSIS | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | use Langertha::Engine::Groq; | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | my $groq = Langertha::Engine::Groq->new( | ||||||||||||||||||||
| 59 | api_key => $ENV{GROQ_API_KEY}, | ||||||||||||||||||||
| 60 | model => 'llama-3.3-70b-versatile', | ||||||||||||||||||||
| 61 | system_prompt => 'You are a helpful assistant', | ||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | print $groq->simple_chat('Say something nice'); | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | # Audio transcription | ||||||||||||||||||||
| 67 | my $text = $groq->transcription('/path/to/audio.mp3'); | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =head1 DESCRIPTION | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | Provides access to Groq's ultra-fast LLM inference via their GroqCloud API. | ||||||||||||||||||||
| 72 | Composes L<Langertha::Role::OpenAICompatible> with Groq's endpoint | ||||||||||||||||||||
| 73 | (C<https://api.groq.com/openai/v1>) and API key handling. | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | Popular models: C<llama-3.3-70b-versatile>, C<llama-3-groq-70b-tool-use>, | ||||||||||||||||||||
| 76 | C<deepseek-r1-distill-llama-70b>, C<qwen-2.5-coder-32b>. Audio transcription | ||||||||||||||||||||
| 77 | uses C<whisper-large-v3> by default. No default chat model is set; C<model> | ||||||||||||||||||||
| 78 | must be specified explicitly. | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | Dynamic model listing via C<list_models()>. Get your API key at | ||||||||||||||||||||
| 81 | L<https://console.groq.com/keys> and set C<LANGERTHA_GROQ_API_KEY>. | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | B<THIS API IS WORK IN PROGRESS> | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | =head1 SEE ALSO | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =over | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =item * L<https://groqstatus.com/> - Groq service status | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =item * L<https://console.groq.com/docs/models> - Official Groq models documentation | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | =item * L<Langertha::Role::OpenAICompatible> - OpenAI API format role | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =item * L<Langertha::Role::Transcription> - Transcription role (Groq hosts Whisper) | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =item * L<Langertha::Engine::DeepSeek> - Another OpenAI-compatible engine | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | =back | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =head1 SUPPORT | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | =head2 Issues | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||
| 106 | L<https://github.com/Getty/langertha/issues>. | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | =head2 IRC | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =head1 CONTRIBUTING | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | =head1 AUTHOR | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | Torsten Raudssus <getty@cpan.org> | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 125 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | =cut | ||||||||||||||||||||