llm_chain 0.5.4 → 0.5.5

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.
data/lib/llm_chain.rb CHANGED
@@ -23,6 +23,7 @@ require_relative "llm_chain/embeddings/clients/local/weaviate_retriever"
23
23
  require_relative "llm_chain/embeddings/clients/local/ollama_client"
24
24
 
25
25
  module LLMChain
26
+ # Exception classes
26
27
  class Error < StandardError; end
27
28
  class UnknownModelError < Error; end
28
29
  class InvalidModelVersion < Error; end
@@ -32,20 +33,34 @@ module LLMChain
32
33
  class MemoryError < Error; end
33
34
  end
34
35
 
35
- # Загружаем валидатор после определения базовых классов
36
+ # Load validator and diagnostics after base classes are defined
36
37
  require_relative "llm_chain/configuration_validator"
38
+ require_relative "llm_chain/system_diagnostics"
37
39
 
38
40
  module LLMChain
39
-
40
- # Простая система конфигурации
41
+ # Simple configuration system for LLMChain
41
42
  class Configuration
43
+ # Configuration constants
44
+ DEFAULT_MODEL = "qwen3:1.7b"
45
+ DEFAULT_TIMEOUT = 30
46
+ DEFAULT_MEMORY_SIZE = 100
47
+ DEFAULT_SEARCH_ENGINE = :google
48
+
42
49
  attr_accessor :default_model, :timeout, :memory_size, :search_engine
43
50
 
44
51
  def initialize
45
- @default_model = "qwen3:1.7b"
46
- @timeout = 30
47
- @memory_size = 100
48
- @search_engine = :google
52
+ @default_model = DEFAULT_MODEL
53
+ @timeout = DEFAULT_TIMEOUT
54
+ @memory_size = DEFAULT_MEMORY_SIZE
55
+ @search_engine = DEFAULT_SEARCH_ENGINE
56
+ end
57
+
58
+ def reset_to_defaults
59
+ initialize
60
+ end
61
+
62
+ def valid?
63
+ default_model && timeout.positive? && memory_size.positive?
49
64
  end
50
65
  end
51
66
 
@@ -60,61 +75,46 @@ module LLMChain
60
75
  yield(configuration)
61
76
  end
62
77
 
63
- # Быстрое создание цепочки с настройками по умолчанию
78
+ def reset_configuration
79
+ @configuration = nil
80
+ end
81
+
82
+ # Quick chain creation with default settings
64
83
  def quick_chain(model: nil, tools: true, memory: true, validate_config: true, **options)
65
- model ||= configuration.default_model
66
-
67
- chain_options = {
68
- model: model,
84
+ chain_options = build_chain_options(model, tools, memory, validate_config, **options)
85
+ Chain.new(**chain_options)
86
+ end
87
+
88
+ # System diagnostics
89
+ def diagnose_system
90
+ SystemDiagnostics.run
91
+ end
92
+
93
+ private
94
+
95
+ def build_chain_options(model, tools, memory, validate_config, **options)
96
+ {
97
+ model: model || configuration.default_model,
98
+ tools: build_tools(tools),
99
+ memory: build_memory(memory),
69
100
  retriever: false,
70
101
  validate_config: validate_config,
71
102
  **options
72
103
  }
73
-
74
- if tools
75
- tool_manager = Tools::ToolManager.create_default_toolset
76
- chain_options[:tools] = tool_manager
77
- end
78
-
79
- if memory
80
- chain_options[:memory] = Memory::Array.new(max_size: configuration.memory_size)
81
- end
82
-
83
- Chain.new(**chain_options)
84
104
  end
85
105
 
86
- # Диагностика системы
87
- def diagnose_system
88
- puts "🔍 LLMChain System Diagnostics"
89
- puts "=" * 50
90
-
91
- results = ConfigurationValidator.validate_environment
92
-
93
- puts "\n📋 System Components:"
94
- puts " Ruby: #{results[:ruby] ? '✅' : '❌'} (#{RUBY_VERSION})"
95
- puts " Python: #{results[:python] ? '✅' : '❌'}"
96
- puts " Node.js: #{results[:node] ? '✅' : '❌'}"
97
- puts " Internet: #{results[:internet] ? '✅' : '❌'}"
98
- puts " Ollama: #{results[:ollama] ? '✅' : '❌'}"
99
-
100
- puts "\n🔑 API Keys:"
101
- results[:apis].each do |api, available|
102
- puts " #{api.to_s.capitalize}: #{available ? '✅' : '❌'}"
103
- end
104
-
105
- if results[:warnings].any?
106
- puts "\n⚠️ Warnings:"
107
- results[:warnings].each { |warning| puts " • #{warning}" }
108
- end
109
-
110
- puts "\n💡 Recommendations:"
111
- puts " • Install missing components for full functionality"
112
- puts " • Configure API keys for enhanced features"
113
- puts " • Start Ollama server: ollama serve" unless results[:ollama]
114
-
115
- puts "\n" + "=" * 50
116
-
117
- results
106
+ def build_tools(tools)
107
+ return Tools::ToolManagerFactory.create_default_toolset if tools == true
108
+ return nil if tools == false
109
+
110
+ tools
111
+ end
112
+
113
+ def build_memory(memory)
114
+ return Memory::Array.new(max_size: configuration.memory_size) if memory == true
115
+ return nil if memory == false
116
+
117
+ memory
118
118
  end
119
119
  end
120
120
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: llm_chain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - FuryCow
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-08 00:00:00.000000000 Z
11
+ date: 2025-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -127,6 +127,11 @@ files:
127
127
  - examples/tools_example.rb
128
128
  - exe/llm-chain
129
129
  - lib/llm_chain.rb
130
+ - lib/llm_chain/builders/memory_context.rb
131
+ - lib/llm_chain/builders/prompt.rb
132
+ - lib/llm_chain/builders/rag_documents.rb
133
+ - lib/llm_chain/builders/retriever_context.rb
134
+ - lib/llm_chain/builders/tool_responses.rb
130
135
  - lib/llm_chain/chain.rb
131
136
  - lib/llm_chain/client_registry.rb
132
137
  - lib/llm_chain/clients/base.rb
@@ -140,14 +145,23 @@ files:
140
145
  - lib/llm_chain/embeddings/clients/local/ollama_client.rb
141
146
  - lib/llm_chain/embeddings/clients/local/weaviate_retriever.rb
142
147
  - lib/llm_chain/embeddings/clients/local/weaviate_vector_store.rb
148
+ - lib/llm_chain/interfaces/builders/memory_context_builder.rb
149
+ - lib/llm_chain/interfaces/builders/prompt_builder.rb
150
+ - lib/llm_chain/interfaces/builders/rag_documents_builder.rb
151
+ - lib/llm_chain/interfaces/builders/retriever_context_builder.rb
152
+ - lib/llm_chain/interfaces/builders/tool_responses_builder.rb
153
+ - lib/llm_chain/interfaces/memory.rb
154
+ - lib/llm_chain/interfaces/tool_manager.rb
143
155
  - lib/llm_chain/memory/array.rb
144
156
  - lib/llm_chain/memory/redis.rb
157
+ - lib/llm_chain/system_diagnostics.rb
145
158
  - lib/llm_chain/tools/base.rb
146
159
  - lib/llm_chain/tools/base_tool.rb
147
160
  - lib/llm_chain/tools/calculator.rb
148
161
  - lib/llm_chain/tools/code_interpreter.rb
149
162
  - lib/llm_chain/tools/date_time.rb
150
163
  - lib/llm_chain/tools/tool_manager.rb
164
+ - lib/llm_chain/tools/tool_manager_factory.rb
151
165
  - lib/llm_chain/tools/web_search.rb
152
166
  - lib/llm_chain/version.rb
153
167
  - sig/llm_chain.rbs