litellm 1.0.0.rc2 → 1.0.0.rc3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/VERSION +1 -1
- data/lib/litellm/client.rb +31 -5
- data/lib/litellm/configuration.rb +1 -2
- data/lib/litellm/errors.rb +0 -2
- data/lib/litellm/tool_handler.rb +1 -3
- data/lib/litellm/utils/tool_definition.rb +4 -4
- data/lib/litellm.rb +12 -12
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb06b016eabb824459cdcc8f9dd9a7636284346fcf7b5f57fcf435f7148e585a
|
4
|
+
data.tar.gz: 76848f873c82509bcb3e70d656f106e73b269e5e48249fb15b453e2a03ee9cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90849406acc2b27e863121f699d5a37e9bc28d2d9b45a86a39938a49e9928800cd544a8d0e13462715a4b867a92dbe63756b39549c1c67cfdbe595fcfc2e43ca
|
7
|
+
data.tar.gz: 3e1cb93c2a6c32ac01368ead65b41925efd7c0bb916b92ce9cc5a60b991a5b6a7911d8a97fa3ee61b17145e143bf63042f514cd3a8a2404767230eca6b8bb9da
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 1.0.0.rc3 (2025-04-06)
|
2
|
+
|
3
|
+
- Added rspec test suite with vcr, covering current functionality:
|
4
|
+
- Chat and Multi-turn conversation tests
|
5
|
+
- Streaming response tests
|
6
|
+
- Tools calling functionality tests
|
7
|
+
- Embedding generation tests
|
8
|
+
- Image generation tests
|
9
|
+
- Added GitHub workflows for:
|
10
|
+
- CI testing across Ruby versions 3.1, 3.2, 3.3, and 3.4
|
11
|
+
- Automated gem release process
|
12
|
+
- Issue templates for bug reports
|
13
|
+
|
1
14
|
## 1.0.0.rc2 (2025-03-16)
|
2
15
|
|
3
16
|
- Minor improvements to README documentation and fixes to GitHub repository links.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.rc3
|
data/lib/litellm/client.rb
CHANGED
@@ -16,6 +16,14 @@ module LiteLLM
|
|
16
16
|
validate_configuration!
|
17
17
|
end
|
18
18
|
|
19
|
+
# Get a list of available models from the LiteLLM server
|
20
|
+
# @return [Array<String>] Array of model names
|
21
|
+
def models
|
22
|
+
response = make_get_request("/models")
|
23
|
+
parsed_response = handle_json_response(response)
|
24
|
+
parsed_response["data"].map { |model| model["id"] }
|
25
|
+
end
|
26
|
+
|
19
27
|
# Make a completion request
|
20
28
|
# @param messages [Array<Hash>] Array of message objects
|
21
29
|
# @param model [String, nil] Optional model override
|
@@ -131,13 +139,13 @@ module LiteLLM
|
|
131
139
|
end
|
132
140
|
end
|
133
141
|
|
134
|
-
def make_request(endpoint, payload, &block)
|
142
|
+
def make_request(endpoint, payload, method: :post, &block)
|
135
143
|
request_id = SecureRandom.uuid
|
136
144
|
log_request(request_id, endpoint, payload)
|
137
145
|
|
138
|
-
response = connection.
|
146
|
+
response = connection.send(method, endpoint) do |req|
|
139
147
|
req.headers["X-Request-ID"] = request_id
|
140
|
-
req.body = payload.to_json
|
148
|
+
req.body = payload.to_json if method == :post
|
141
149
|
req.options.on_data = Streaming.process_stream(&block) if payload[:stream]
|
142
150
|
end
|
143
151
|
|
@@ -148,7 +156,25 @@ module LiteLLM
|
|
148
156
|
raise
|
149
157
|
end
|
150
158
|
|
151
|
-
|
159
|
+
# Make a GET request to the specified endpoint
|
160
|
+
# @param endpoint [String] The API endpoint to call
|
161
|
+
# @param payload [Hash] The request payload
|
162
|
+
# @param block [Proc] Optional block for handling streaming responses
|
163
|
+
# @return [Faraday::Response] The API response
|
164
|
+
def make_get_request(endpoint, payload = {}, &)
|
165
|
+
make_request(endpoint, payload, method: :get, &)
|
166
|
+
end
|
167
|
+
|
168
|
+
# Make a POST request to the specified endpoint
|
169
|
+
# @param endpoint [String] The API endpoint to call
|
170
|
+
# @param payload [Hash] The request payload
|
171
|
+
# @param block [Proc] Optional block for handling streaming responses
|
172
|
+
# @return [Faraday::Response] The API response
|
173
|
+
def make_post_request(endpoint, payload = {}, &)
|
174
|
+
make_request(endpoint, payload, method: :post, &)
|
175
|
+
end
|
176
|
+
|
177
|
+
def handle_tool_calls(response_data, tools, model, stream, &)
|
152
178
|
LiteLLM.logger.debug "Handling tool calls, stream=#{stream}"
|
153
179
|
|
154
180
|
begin
|
@@ -160,7 +186,7 @@ module LiteLLM
|
|
160
186
|
|
161
187
|
LiteLLM.logger.debug "Tool handler generated messages: #{@messages.inspect}"
|
162
188
|
|
163
|
-
completion(messages: @messages, model: model, tools: tools, stream: stream, &
|
189
|
+
completion(messages: @messages, model: model, tools: tools, stream: stream, &)
|
164
190
|
rescue StandardError => e
|
165
191
|
LiteLLM.logger.error "Error in handle_tool_calls: #{e.message}\n#{e.backtrace.join("\n")}"
|
166
192
|
raise
|
@@ -32,8 +32,7 @@ module LiteLLM
|
|
32
32
|
end
|
33
33
|
|
34
34
|
class Configuration
|
35
|
-
attr_reader :base_url, :timeout, :model, :embedding_model, :image_model, :embedding_dimensions,
|
36
|
-
:debug, :logger, :enable_message_redaction, :api_key
|
35
|
+
attr_reader :base_url, :timeout, :model, :embedding_model, :image_model, :embedding_dimensions, :debug, :logger, :enable_message_redaction, :api_key
|
37
36
|
|
38
37
|
def initialize
|
39
38
|
@base_url = DEFAULTS[:base_url]
|
data/lib/litellm/errors.rb
CHANGED
data/lib/litellm/tool_handler.rb
CHANGED
@@ -11,7 +11,7 @@ module LiteLLM
|
|
11
11
|
# Build a mapping of function names to tools
|
12
12
|
@available_tools = {}
|
13
13
|
available_tools.each do |tool|
|
14
|
-
tool.class.function_definitions.each do |
|
14
|
+
tool.class.function_definitions.each do |_function_name, definition|
|
15
15
|
@available_tools[definition[:name]] = tool
|
16
16
|
end
|
17
17
|
end
|
@@ -28,8 +28,6 @@ module LiteLLM
|
|
28
28
|
messages
|
29
29
|
end
|
30
30
|
|
31
|
-
private
|
32
|
-
|
33
31
|
def self.execute_tool_calls(tool_calls)
|
34
32
|
tool_calls.map do |tool_call|
|
35
33
|
function_name = tool_call.dig("function", "name")
|
@@ -28,11 +28,11 @@ module LiteLLM
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def build_parameters(&
|
31
|
+
def build_parameters(&)
|
32
32
|
return nil unless block_given?
|
33
33
|
|
34
34
|
builder = ParameterBuilder.new
|
35
|
-
schema = builder.build(&
|
35
|
+
schema = builder.build(&)
|
36
36
|
|
37
37
|
{
|
38
38
|
type: "object",
|
@@ -101,8 +101,8 @@ module LiteLLM
|
|
101
101
|
@required = []
|
102
102
|
end
|
103
103
|
|
104
|
-
def build(&
|
105
|
-
instance_eval(&
|
104
|
+
def build(&)
|
105
|
+
instance_eval(&)
|
106
106
|
{ properties: @properties, required: @required }
|
107
107
|
end
|
108
108
|
|
data/lib/litellm.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
12
|
-
require_relative
|
13
|
-
require_relative
|
14
|
-
require_relative
|
3
|
+
require "faraday"
|
4
|
+
require "event_stream_parser"
|
5
|
+
require "json"
|
6
|
+
require "logger"
|
7
|
+
|
8
|
+
require_relative "litellm/version"
|
9
|
+
require_relative "litellm/configuration"
|
10
|
+
require_relative "litellm/streaming"
|
11
|
+
require_relative "litellm/client"
|
12
|
+
require_relative "litellm/errors"
|
13
|
+
require_relative "litellm/tool_handler"
|
14
|
+
require_relative "litellm/utils/tool_definition"
|
15
15
|
|
16
16
|
module LiteLLM
|
17
17
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: litellm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mohamed Nimir
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-06 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: event_stream_parser
|