Class: LightGptProxy::Templates::OllamaTemplate

Inherits:
LightGptProxy::Template show all
Defined in:
lib/light_gpt_proxy/templates/ollama_template.rb

Instance Attribute Summary

Attributes inherited from LightGptProxy::Template

#attributes, #params

Class Method Summary collapse

Methods inherited from LightGptProxy::Template

#initialize, #save, #to_h, #to_yaml

Constructor Details

This class inherits a constructor from LightGptProxy::Template

Class Method Details

.optionalObject



12
13
14
15
16
17
18
# File 'lib/light_gpt_proxy/templates/ollama_template.rb', line 12

def self.optional
  {
    model: 'llama3.2',
    stream: false,
    port: 11_434
  }
end

.requiredObject



8
9
10
# File 'lib/light_gpt_proxy/templates/ollama_template.rb', line 8

def self.required
  []
end

.templateObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/light_gpt_proxy/templates/ollama_template.rb', line 20

def self.template
  {
    'host' => 'http://localhost:<%= attributes[:port] %>',
    'endpoints' => {
      'chat' => {
        'path' => 'api/chat',
        'method' => 'POST',
        'defaults' => {
          'model' => '<%= attributes[:model] %>',
          'messages' => [
            {
              'role' => 'user',
              'content' => 'why is the sky blue?'
            }
          ],
          'stream' => '<%= attributes[:stream] %>'
        },
        'body_schema' => {
          'model' => { 'type' => 'string', 'required' => true, 'default' => '<%= attributes[:model] %>' },
          'messages' => {
            'type' => 'array',
            'schema' => {
              'role' => { 'type' => 'string', 'required' => true },
              'content' => { 'type' => 'string', 'required' => true, 'default' => 'user' }
            },
            'default' => [{ 'role' => 'user', 'content' => 'why is the sky blue?' }],
            'required' => true
          },
          'stream' => { 'type' => 'boolean', 'required' => false, 'default' => false }
        }
      }
    }
  }.freeze
end