| 1 | package Langertha::Engine::LMStudioAnthropic; | ||||||||||||
| 2 | # ABSTRACT: LM Studio via Anthropic-compatible API | ||||||||||||
| 3 | 3 | our $VERSION = '0.502'; | |||||||||||
| 4 | 3 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 3 | extends 'Langertha::Engine::AnthropicBase'; | |||||||||||
| 7 | |||||||||||||
| 8 | |||||||||||||
| 9 | has '+url' => ( | ||||||||||||
| 10 | lazy => 1, | ||||||||||||
| 11 | 1 | ▶ | default => sub { 'http://localhost:1234' }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 3 | ); | |||||||||||
| 13 | |||||||||||||
| 14 | sub _build_api_key { | ||||||||||||
| 15 | 3 | ▶ | return $ENV{LANGERTHA_LMSTUDIO_API_KEY} || 'lmstudio'; | ||||||||||
|
Subroutine
_build_api_key: called CC=2 SCAR=6.9
Condition100%2/2
$ENV{'LANGERTHA_LMSTUDIO_API_KEY'} || 'lmstudio'
MC/DC100%1/1
$ENV{'LANGERTHA_LMSTUDIO_API_KEY'} || 'lmstudio'
$ENV{'LANGERTHA_LMSTUDIO_API_KEY'}
Truth table100%2/2
A
A= $ENV{'LANGERTHA_LMSTUDIO_API_KEY'}
| |||||||||||||
| 16 | } | ||||||||||||
| 17 | |||||||||||||
| 18 | |||||||||||||
| 19 | 1 | ▶ | sub default_model { 'default' } | ||||||||||
|
Subroutine
default_model: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 20 | |||||||||||||
| 21 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 22 | |||||||||||||
| 23 | |||||||||||||
| 24 | 3 | 1; | |||||||||||
| 25 | |||||||||||||
| 26 | __END__ | ||||||||||||
| 27 | |||||||||||||
| 28 | =pod | ||||||||||||
| 29 | |||||||||||||
| 30 | =encoding UTF-8 | ||||||||||||
| 31 | |||||||||||||
| 32 | =head1 NAME | ||||||||||||
| 33 | |||||||||||||
| 34 | Langertha::Engine::LMStudioAnthropic - LM Studio via Anthropic-compatible API | ||||||||||||
| 35 | |||||||||||||
| 36 | =head1 VERSION | ||||||||||||
| 37 | |||||||||||||
| 38 | version 0.502 | ||||||||||||
| 39 | |||||||||||||
| 40 | =head1 SYNOPSIS | ||||||||||||
| 41 | |||||||||||||
| 42 | use Langertha::Engine::LMStudioAnthropic; | ||||||||||||
| 43 | |||||||||||||
| 44 | my $lm_anthropic = Langertha::Engine::LMStudioAnthropic->new( | ||||||||||||
| 45 | url => 'http://localhost:1234', | ||||||||||||
| 46 | model => 'qwen2.5-7b-instruct-1m', | ||||||||||||
| 47 | ); | ||||||||||||
| 48 | |||||||||||||
| 49 | print $lm_anthropic->simple_chat('Hello from Anthropic-compatible endpoint'); | ||||||||||||
| 50 | |||||||||||||
| 51 | =head1 DESCRIPTION | ||||||||||||
| 52 | |||||||||||||
| 53 | Adapter for LM Studio's Anthropic-compatible local endpoint | ||||||||||||
| 54 | (C<POST /v1/messages> on the LM Studio server URL, default | ||||||||||||
| 55 | C<http://localhost:1234>). | ||||||||||||
| 56 | |||||||||||||
| 57 | LM Studio requires a non-empty C<x-api-key> header for this endpoint, but the | ||||||||||||
| 58 | value is not validated against Anthropic. This class defaults to C<lmstudio> | ||||||||||||
| 59 | when no API key is configured. | ||||||||||||
| 60 | |||||||||||||
| 61 | B<THIS API IS WORK IN PROGRESS> | ||||||||||||
| 62 | |||||||||||||
| 63 | =head2 api_key | ||||||||||||
| 64 | |||||||||||||
| 65 | API key sent as C<x-api-key> to the Anthropic-compatible endpoint. | ||||||||||||
| 66 | LM Studio accepts arbitrary non-empty values. Defaults to C<lmstudio> when | ||||||||||||
| 67 | no explicit C<api_key> and no C<LANGERTHA_LMSTUDIO_API_KEY> are set. | ||||||||||||
| 68 | |||||||||||||
| 69 | =head1 SEE ALSO | ||||||||||||
| 70 | |||||||||||||
| 71 | =over | ||||||||||||
| 72 | |||||||||||||
| 73 | =item * L<Langertha::Engine::LMStudio> - Native LM Studio API (C</api/v1/chat>) | ||||||||||||
| 74 | |||||||||||||
| 75 | =item * L<Langertha::Engine::AnthropicBase> - Base Anthropic-compatible engine | ||||||||||||
| 76 | |||||||||||||
| 77 | =back | ||||||||||||
| 78 | |||||||||||||
| 79 | =head1 SUPPORT | ||||||||||||
| 80 | |||||||||||||
| 81 | =head2 Issues | ||||||||||||
| 82 | |||||||||||||
| 83 | Please report bugs and feature requests on GitHub at | ||||||||||||
| 84 | L<https://github.com/Getty/langertha/issues>. | ||||||||||||
| 85 | |||||||||||||
| 86 | =head2 IRC | ||||||||||||
| 87 | |||||||||||||
| 88 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||
| 89 | |||||||||||||
| 90 | =head1 CONTRIBUTING | ||||||||||||
| 91 | |||||||||||||
| 92 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||
| 93 | |||||||||||||
| 94 | =head1 AUTHOR | ||||||||||||
| 95 | |||||||||||||
| 96 | Torsten Raudssus <getty@cpan.org> | ||||||||||||
| 97 | |||||||||||||
| 98 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 99 | |||||||||||||
| 100 | This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>. | ||||||||||||
| 101 | |||||||||||||
| 102 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 103 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 104 | |||||||||||||
| 105 | =cut | ||||||||||||