riffer 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Riffer::Agents
4
- class Base
5
- class << self
6
- def model(model_string = nil)
7
- return @model if model_string.nil?
8
-
9
- raise ArgumentError, "model must be a String" unless model_string.is_a?(String)
10
- raise ArgumentError, "model cannot be empty" if model_string.strip.empty?
11
-
12
- @model = model_string
13
- end
14
-
15
- def instructions(instructions_text = nil)
16
- return @instructions if instructions_text.nil?
17
-
18
- raise ArgumentError, "instructions must be a String" unless instructions_text.is_a?(String)
19
- raise ArgumentError, "instructions cannot be empty" if instructions_text.strip.empty?
20
-
21
- @instructions = instructions_text
22
- end
23
- end
24
-
25
- attr_reader :messages
26
-
27
- def initialize
28
- @messages = []
29
- @model_string = self.class.model
30
- @instructions_text = self.class.instructions
31
-
32
- provider_name, model_name = @model_string.split("/", 2)
33
-
34
- raise ArgumentError, "Invalid model string: #{@model_string}" unless [provider_name, model_name].all? { |part| part.is_a?(String) && !part.strip.empty? }
35
-
36
- @provider_name = provider_name
37
- @model_name = model_name
38
- end
39
-
40
- def generate(prompt)
41
- initialize_messages(prompt)
42
-
43
- loop do
44
- response = call_llm
45
- @messages << response
46
-
47
- break unless has_tool_calls?(response)
48
-
49
- execute_tool_calls(response)
50
- end
51
-
52
- extract_final_response
53
- end
54
-
55
- private
56
-
57
- def initialize_messages(prompt)
58
- @messages = [] # Reset messages for each generation call
59
- @messages << Riffer::Messages::System.new(@instructions_text) if @instructions_text
60
- @messages << Riffer::Messages::User.new(prompt)
61
- end
62
-
63
- def call_llm
64
- provider_instance.generate_text(messages: @messages, model: @model_name)
65
- end
66
-
67
- def provider_instance
68
- @provider_instance ||= Riffer::Providers::Base.find_provider(@provider_name).new
69
- end
70
-
71
- def has_tool_calls?(response)
72
- response.is_a?(Riffer::Messages::Assistant) && !response.tool_calls.empty?
73
- end
74
-
75
- def execute_tool_calls(response)
76
- response.tool_calls.each do |tool_call|
77
- tool_result = execute_tool_call(tool_call)
78
- @messages << Riffer::Messages::Tool.new(
79
- tool_result,
80
- tool_call_id: tool_call[:id],
81
- name: tool_call[:name]
82
- )
83
- end
84
- end
85
-
86
- def execute_tool_call(tool_call)
87
- "Tool execution not implemented yet"
88
- end
89
-
90
- def extract_final_response
91
- last_assistant_message = @messages.reverse.find { |msg| msg.is_a?(Riffer::Messages::Assistant) }
92
- last_assistant_message&.content || ""
93
- end
94
- end
95
- end
data/lib/riffer/agents.rb DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Riffer::Agents
4
- class Error < StandardError; end
5
- class InvalidInputError < Error; end
6
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Riffer::Storage
4
- class Base
5
- def initialize(**options)
6
- @options = options
7
- end
8
-
9
- def save(key, value)
10
- raise NotImplementedError, "Subclasses must implement #save"
11
- end
12
-
13
- def load(key)
14
- raise NotImplementedError, "Subclasses must implement #load"
15
- end
16
-
17
- def delete(key)
18
- raise NotImplementedError, "Subclasses must implement #delete"
19
- end
20
- end
21
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Riffer::Storage
4
- class Error < StandardError; end
5
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Riffer::Tools
4
- class Base
5
- attr_reader :name, :description
6
-
7
- def initialize(name:, description:, **options)
8
- @name = name
9
- @description = description
10
- @options = options
11
- end
12
-
13
- def call(**params)
14
- raise NotImplementedError, "Subclasses must implement #call"
15
- end
16
-
17
- def schema
18
- {
19
- name: @name,
20
- description: @description,
21
- parameters: parameters_schema
22
- }
23
- end
24
-
25
- private
26
-
27
- def parameters_schema
28
- {}
29
- end
30
- end
31
- end
data/lib/riffer/tools.rb DELETED
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Riffer::Tools
4
- class Error < StandardError; end
5
- end