llm_gateway 0.2.0 → 0.3.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,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "base64"
4
-
5
- module LlmGateway
6
- module Adapters
7
- module OpenAi
8
- class InputMapper < LlmGateway::Adapters::Groq::InputMapper
9
- def self.map(data)
10
- {
11
- messages: map_messages(data[:messages]),
12
- response_format: map_response_format(data[:response_format]),
13
- tools: map_tools(data[:tools]),
14
- system: map_system(data[:system])
15
- }
16
- end
17
-
18
- private
19
-
20
- def self.map_messages(messages)
21
- return messages unless messages
22
-
23
- # First, handle file transformations
24
- messages_with_files = messages.map do |msg|
25
- if msg[:content].is_a?(Array)
26
- content = msg[:content].map do |content|
27
- if content[:type] == "file"
28
- # Map text/plain to application/pdf for OpenAI
29
- media_type = content[:media_type] == "text/plain" ? "application/pdf" : content[:media_type]
30
- {
31
- type: "file",
32
- file: {
33
- filename: content[:name],
34
- file_data: "data:#{media_type};base64,#{Base64.encode64(content[:data])}"
35
- }
36
- }
37
- else
38
- content
39
- end
40
- end
41
- msg.merge(content: content)
42
- else
43
- msg
44
- end
45
- end
46
-
47
- # Then apply parent's tool transformation logic
48
- super(messages_with_files)
49
- end
50
-
51
- def self.map_system(system)
52
- if !system || system.empty?
53
- []
54
- else
55
- system.map do |msg|
56
- msg[:role] == "system" ? msg.merge(role: "developer") : msg
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LlmGateway
4
- module Adapters
5
- module OpenAi
6
- class OutputMapper < LlmGateway::Adapters::Groq::OutputMapper
7
- end
8
- end
9
- end
10
- end