Langertha/Engine/LMStudioOpenAI.pm

filter: Statementstmt 92.8% 13 / 14 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 83.3% 5 / 6 Podpod 50.0% 1 / 2 totaltotal 88.0% 22 / 25 CC 2 SCAR 3.6
CC
2
Cov
94%
_build_api_key
2.0
default_embedding_model
2.0
BEGIN
1.0
CRAP 1.4
« Langertha/Engine/OpenAI.pm ↑ Summary Langertha/Engine/OllamaOpenAI.pm »
1 package Langertha::Engine::LMStudioOpenAI;
2 # ABSTRACT: LM Studio via OpenAI-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::OpenAIBase';
7  
8 3 with 'Langertha::Role::Embedding', 'Langertha::Role::Tools';
9  
10  
11 has '+url' => (
12 lazy => 1,
13 1 ▶ default => sub { 'http://localhost:1234/v1' },
Subroutine __ANON__: called CC=1 SCAR=0.0
14 3 );
15  
16 sub _build_api_key {
17 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'
l!l
12
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'}
Aresult
11
00
18 }
19  
20  
21 1 ▶sub default_model { 'default' }
Subroutine default_model: called CC=1 SCAR=0.0
Pod documented
22 0 ▶sub default_embedding_model { 'default' }
Subroutine default_embedding_model: not called CC=1 SCAR=6.9
Pod undocumented
23  
24  
25 2 ▶sub _build_supported_operations {[qw(
Subroutine _build_supported_operations: called CC=1 SCAR=0.0
26 createChatCompletion
27 createEmbedding
28 )]}
29  
30 3 __PACKAGE__->meta->make_immutable;
31  
32  
33 3 1;
34  
35 __END__
36  
37 =pod
38  
39 =encoding UTF-8
40  
41 =head1 NAME
42  
43 Langertha::Engine::LMStudioOpenAI - LM Studio via OpenAI-compatible API
44  
45 =head1 VERSION
46  
47 version 0.502
48  
49 =head1 SYNOPSIS
50  
51 use Langertha::Engine::LMStudioOpenAI;
52  
53 my $lm_oai = Langertha::Engine::LMStudioOpenAI->new(
54 url => 'http://localhost:1234/v1',
55 model => 'qwen2.5-7b-instruct-1m',
56 );
57  
58 print $lm_oai->simple_chat('Hello from OpenAI-compatible endpoint');
59  
60 =head1 DESCRIPTION
61  
62 Adapter for LM Studio's OpenAI-compatible local endpoint
63 (C</v1/chat/completions>, C</v1/models>, C</v1/embeddings>).
64  
65 Authentication is optional. If C<api_key> (or C<LANGERTHA_LMSTUDIO_API_KEY>)
66 is set, it is sent as a bearer token.
67  
68 B<THIS API IS WORK IN PROGRESS>
69  
70 =head2 api_key
71  
72 Optional bearer token for LM Studio's OpenAI-compatible endpoint.
73 If not provided, reads from C<LANGERTHA_LMSTUDIO_API_KEY> and otherwise
74 defaults to C<lmstudio>.
75  
76 =head2 model
77  
78 Chat model name. Defaults to C<default>. For real requests, set this to
79 an actually loaded LM Studio model key (for example
80 C<qwen2.5-7b-instruct-1m>).
81  
82 =head1 SEE ALSO
83  
84 =over
85  
86 =item * L<Langertha::Engine::LMStudio> - Native LM Studio API
87  
88 =item * L<Langertha::Engine::OpenAIBase> - Base class for OpenAI-compatible engines
89  
90 =back
91  
92 =head1 SUPPORT
93  
94 =head2 Issues
95  
96 Please report bugs and feature requests on GitHub at
97 L<https://github.com/Getty/langertha/issues>.
98  
99 =head2 IRC
100  
101 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
102  
103 =head1 CONTRIBUTING
104  
105 Contributions are welcome! Please fork the repository and submit a pull request.
106  
107 =head1 AUTHOR
108  
109 Torsten Raudssus <getty@cpan.org>
110  
111 =head1 COPYRIGHT AND LICENSE
112  
113 This software is copyright (c) 2026 by Torsten Raudssus L<https://raudssus.de/>.
114  
115 This is free software; you can redistribute it and/or modify it under
116 the same terms as the Perl 5 programming language system itself.
117  
118 =cut
« Langertha/Engine/OpenAI.pm ↑ Summary Langertha/Engine/OllamaOpenAI.pm »