Class: RSpec::LLM::Adapters::Langchain

Inherits:
Base
  • Object
show all
Defined in:
lib/rspec/llm/adapters/langchain.rb

Overview

Adapter for the langchainrb gem (github.com/patterns-ai-core/langchainrb). Wraps a Langchain::LLM::* instance.

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize, wrap

Constructor Details

This class inherits a constructor from RSpec::LLM::Adapters::Base

Instance Method Details

#chat(messages) ⇒ Object



9
10
11
12
13
# File 'lib/rspec/llm/adapters/langchain.rb', line 9

def chat(messages)
  normalized = normalize_messages(messages)
  response = client.chat(messages: normalized)
  extract_content(response)
end

#embed(text) ⇒ Object



15
16
17
18
# File 'lib/rspec/llm/adapters/langchain.rb', line 15

def embed(text)
  response = client.embed(text: text)
  extract_vector(response)
end