Class: SmartPrompt::OllamaAdapter
- Inherits:
-
LLMAdapter
- Object
- LLMAdapter
- SmartPrompt::OllamaAdapter
- Defined in:
- lib/smart_prompt/llm_adapter.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ OllamaAdapter
constructor
A new instance of OllamaAdapter.
- #send_request(messages, model = nil) ⇒ Object
Constructor Details
#initialize(config) ⇒ OllamaAdapter
Returns a new instance of OllamaAdapter.
75 76 77 78 |
# File 'lib/smart_prompt/llm_adapter.rb', line 75 def initialize(config) super @client = Ollama.new(credentials: { address: @config['url'] }) end |
Instance Method Details
#send_request(messages, model = nil) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/smart_prompt/llm_adapter.rb', line 80 def send_request(, model=nil) SmartPrompt.logger.info "OllamaAdapter: Sending request to Ollama" if model model_name = model else model_name = @config['model'] end SmartPrompt.logger.info "OllamaAdapter: Using model #{model_name}" response = @client.generate( { model: model_name, prompt: .to_s, stream: false } ) SmartPrompt.logger.info "OllamaAdapter: Received response from Ollama" return response[0]["response"] end |