Class: ActiveAgent::Providers::Ollama
- Defined in:
- lib/active_agent/providers/ollama.rb
Constant Summary collapse
- DEFAULT_URL =
'http://localhost:11434/v1/chat/completions'
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #chat(messages:, tools: []) ⇒ Object
-
#initialize(model: 'llama3', api_key: nil, api_url: nil) ⇒ Ollama
constructor
A new instance of Ollama.
Constructor Details
#initialize(model: 'llama3', api_key: nil, api_url: nil) ⇒ Ollama
Returns a new instance of Ollama.
10 11 12 13 |
# File 'lib/active_agent/providers/ollama.rb', line 10 def initialize(model: 'llama3', api_key: nil, api_url: nil) url = api_url || DEFAULT_URL super(model: model, api_key: api_key, api_url: url) end |
Instance Method Details
#chat(messages:, tools: []) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_agent/providers/ollama.rb', line 15 def chat(messages:, tools: []) headers = { 'Content-Type' => 'application/json' } payload = { model: @model, messages: , temperature: 0.2 } data = http_post(@api_url, headers, payload) = data.dig('choices', 0, 'message') || {} { content: ['content'], tool_calls: nil } end |