llm_meta_client 1.6.0 → 1.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/llm_meta_client/server_query.rb +22 -6
- data/lib/llm_meta_client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f5b2078839265ff4e964a4437b2d4865c4fcb9d520d3adee38160b04716dceed
|
|
4
|
+
data.tar.gz: f70e94937945bfc7bb2d51e65d3c229055e434ea130e3181760c4c12c9281e41
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ccd30289df04520d3c8be1343bdba1e183204b898b0c763d8a7bc5a70b8b49627bf4c57487786faa32be90c0cd2d38617aee0567214d93fa21f850ddd08ec61
|
|
7
|
+
data.tar.gz: d16fbce1d748fe0cbe516c0af6b6d8dab825eaec3b362d901591f578cba460a9ed59c07805e054282557d81045a235387c072123e1a17691a1b450ea8c2e00fb
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.0] - 2026-07-06
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `ServerQuery#stream` and `#call` accept a new `messages:` kwarg — an array of role-tagged prior turns (`[{role: "user"|"assistant"|"system", content: "..."}]`) forwarded to `llm_meta_server` as `messages` in the JSON body. When present, the current-turn text stays in `prompt:` (so image/document attachments still bind to it) and the server pre-seeds `LLM::Session`'s message buffer with the history. Fixes a class of "sticky context" bugs where models re-executed the prior turn's task instead of the new instruction because the whole conversation was being packed into a single user message.
|
|
13
|
+
|
|
8
14
|
## [1.6.0] - 2026-07-02
|
|
9
15
|
|
|
10
16
|
### Added
|
|
@@ -12,11 +12,20 @@ module LlmMetaClient
|
|
|
12
12
|
# Returns the final assistant content. If tool calls fired, the returned
|
|
13
13
|
# string mirrors the synchronous #call format (response + markdown
|
|
14
14
|
# "Tool calls" section appended) so persistence stays consistent.
|
|
15
|
-
def stream(id_token, api_key_uuid, model_id, context, user_content, tool_ids: [], generation_settings: {}, image_context: nil, image: nil, images: nil, document: nil)
|
|
15
|
+
def stream(id_token, api_key_uuid, model_id, context, user_content, tool_ids: [], generation_settings: {}, image_context: nil, image: nil, images: nil, document: nil, messages: nil)
|
|
16
16
|
if image_context.present?
|
|
17
17
|
prompt_text = user_content.is_a?(Hash) ? (user_content[:prompt] || user_content["prompt"]).to_s : user_content.to_s
|
|
18
18
|
debug_log "Streaming image request to LLM: \n===>\n#{prompt_text}\n(with #{image_context.size} prior turn(s))\n===>"
|
|
19
19
|
body = { prompt: prompt_text, image_context: image_context }
|
|
20
|
+
elsif messages.present?
|
|
21
|
+
# New (v1.7+) role-tagged wire format. Prior turns travel as a
|
|
22
|
+
# proper `messages:` array; the current user turn's text is sent as
|
|
23
|
+
# `prompt`. Callers who use this form should NOT include the
|
|
24
|
+
# current turn in `messages` — it stays in `prompt` so attachments
|
|
25
|
+
# (image/document) can attach to it via the existing pipeline.
|
|
26
|
+
prompt_text = user_content.is_a?(Hash) ? (user_content[:prompt] || user_content["prompt"]).to_s : user_content.to_s
|
|
27
|
+
debug_log "Streaming role-tagged request to LLM: \n===>\n#{prompt_text}\n(with #{messages.size} prior message(s))\n===>"
|
|
28
|
+
body = { prompt: prompt_text, messages: messages }
|
|
20
29
|
else
|
|
21
30
|
context_and_user_content = "Context:#{context}, User Prompt: #{user_content}"
|
|
22
31
|
debug_log "Streaming request to LLM: \n===>\n#{context_and_user_content}\n===>"
|
|
@@ -62,12 +71,18 @@ module LlmMetaClient
|
|
|
62
71
|
collected_tool_calls.any? ? combine_with_tool_calls(assembled, collected_tool_calls) : assembled
|
|
63
72
|
end
|
|
64
73
|
|
|
65
|
-
def call(id_token, api_key_uuid, model_id, context, user_content, tool_ids: [], generation_settings: {}, document: nil)
|
|
74
|
+
def call(id_token, api_key_uuid, model_id, context, user_content, tool_ids: [], generation_settings: {}, document: nil, messages: nil)
|
|
66
75
|
debug_log "Context: #{context}"
|
|
67
|
-
|
|
68
|
-
|
|
76
|
+
if messages.present?
|
|
77
|
+
prompt_text = user_content.is_a?(Hash) ? (user_content[:prompt] || user_content["prompt"]).to_s : user_content.to_s
|
|
78
|
+
debug_log "Role-tagged request to LLM: \n===>\n#{prompt_text}\n(with #{messages.size} prior message(s))\n===>"
|
|
79
|
+
payload = prompt_text
|
|
80
|
+
else
|
|
81
|
+
payload = "Context:#{context}, User Prompt: #{user_content}"
|
|
82
|
+
debug_log "Request to LLM: \n===>\n#{payload}\n===>"
|
|
83
|
+
end
|
|
69
84
|
|
|
70
|
-
response = request(api_key_uuid, id_token, model_id,
|
|
85
|
+
response = request(api_key_uuid, id_token, model_id, payload, tool_ids, generation_settings, document: document, messages: messages)
|
|
71
86
|
|
|
72
87
|
unless response.success?
|
|
73
88
|
raise Exceptions::ServerError, build_error_message(response.code.to_i, response.parsed_response)
|
|
@@ -116,7 +131,7 @@ module LlmMetaClient
|
|
|
116
131
|
lines.join("\n")
|
|
117
132
|
end
|
|
118
133
|
|
|
119
|
-
def request(api_key_uuid, id_token, model_id, user_content, tool_ids, generation_settings, document: nil)
|
|
134
|
+
def request(api_key_uuid, id_token, model_id, user_content, tool_ids, generation_settings, document: nil, messages: nil)
|
|
120
135
|
headers = { "Content-Type" => "application/json" }
|
|
121
136
|
headers["Authorization"] = "Bearer #{id_token}" if id_token.present?
|
|
122
137
|
|
|
@@ -124,6 +139,7 @@ module LlmMetaClient
|
|
|
124
139
|
body[:tool_ids] = tool_ids if tool_ids.present?
|
|
125
140
|
body[:generation_settings] = generation_settings if generation_settings.present?
|
|
126
141
|
body[:document] = document if document.present?
|
|
142
|
+
body[:messages] = messages if messages.present?
|
|
127
143
|
|
|
128
144
|
HTTParty.post(
|
|
129
145
|
url(api_key_uuid, model_id),
|