promptbuilder 0.4.29__py3-none-any.whl → 0.4.30__py3-none-any.whl
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.
- promptbuilder/llm_client/base_client.py +11 -8
- {promptbuilder-0.4.29.dist-info → promptbuilder-0.4.30.dist-info}/METADATA +1 -1
- {promptbuilder-0.4.29.dist-info → promptbuilder-0.4.30.dist-info}/RECORD +6 -6
- {promptbuilder-0.4.29.dist-info → promptbuilder-0.4.30.dist-info}/WHEEL +0 -0
- {promptbuilder-0.4.29.dist-info → promptbuilder-0.4.30.dist-info}/licenses/LICENSE +0 -0
- {promptbuilder-0.4.29.dist-info → promptbuilder-0.4.30.dist-info}/top_level.txt +0 -0
|
@@ -121,9 +121,10 @@ class BaseLLMClient(ABC, utils.InheritDecoratorsMixin):
|
|
|
121
121
|
total_count += BaseLLMClient._response_out_tokens(response)
|
|
122
122
|
if max_tokens is not None and total_count >= max_tokens:
|
|
123
123
|
break
|
|
124
|
-
if response.candidates:
|
|
125
|
-
BaseLLMClient._append_generated_part(messages, response)
|
|
126
|
-
|
|
124
|
+
if response.candidates and response.candidates[0].content:
|
|
125
|
+
appended_message = BaseLLMClient._append_generated_part(messages, response)
|
|
126
|
+
if appended_message is not None:
|
|
127
|
+
response.candidates[0].content = appended_message
|
|
127
128
|
return response
|
|
128
129
|
|
|
129
130
|
@logfire_decorators.create
|
|
@@ -245,7 +246,7 @@ class BaseLLMClient(ABC, utils.InheritDecoratorsMixin):
|
|
|
245
246
|
|
|
246
247
|
|
|
247
248
|
@staticmethod
|
|
248
|
-
def _append_generated_part(messages: list[Content], response: Response):
|
|
249
|
+
def _append_generated_part(messages: list[Content], response: Response) -> Content | None:
|
|
249
250
|
assert(response.candidates and response.candidates[0].content), "Response must contain at least one candidate with content."
|
|
250
251
|
|
|
251
252
|
text_parts = [
|
|
@@ -262,7 +263,7 @@ class BaseLLMClient(ABC, utils.InheritDecoratorsMixin):
|
|
|
262
263
|
response_text = "".join(part.text for part in thought_parts)
|
|
263
264
|
is_thought = True
|
|
264
265
|
else:
|
|
265
|
-
|
|
266
|
+
return None
|
|
266
267
|
|
|
267
268
|
if len(messages) > 0 and messages[-1].role == "model":
|
|
268
269
|
message_to_append = messages[-1]
|
|
@@ -274,6 +275,7 @@ class BaseLLMClient(ABC, utils.InheritDecoratorsMixin):
|
|
|
274
275
|
message_to_append.parts.append(Part(text=response_text, thought=is_thought))
|
|
275
276
|
else:
|
|
276
277
|
messages.append(Content(parts=[Part(text=response_text, thought=is_thought)], role="model"))
|
|
278
|
+
return messages[-1]
|
|
277
279
|
|
|
278
280
|
@staticmethod
|
|
279
281
|
def _response_out_tokens(response: Response):
|
|
@@ -458,9 +460,10 @@ class BaseLLMClientAsync(ABC, utils.InheritDecoratorsMixin):
|
|
|
458
460
|
total_count += BaseLLMClient._response_out_tokens(response)
|
|
459
461
|
if max_tokens is not None and total_count >= max_tokens:
|
|
460
462
|
break
|
|
461
|
-
if response.candidates:
|
|
462
|
-
BaseLLMClient._append_generated_part(messages, response)
|
|
463
|
-
|
|
463
|
+
if response.candidates and response.candidates[0].content:
|
|
464
|
+
appended_message = BaseLLMClient._append_generated_part(messages, response)
|
|
465
|
+
if appended_message is not None:
|
|
466
|
+
response.candidates[0].content = appended_message
|
|
464
467
|
return response
|
|
465
468
|
|
|
466
469
|
@logfire_decorators.create_async
|
|
@@ -9,7 +9,7 @@ promptbuilder/agent/utils.py,sha256=vTkphKw04v_QDIJtoB2JKK0RGY6iI1t_0LbmuStunzI,
|
|
|
9
9
|
promptbuilder/llm_client/__init__.py,sha256=wJ33cnRtZX_YPsbcGxEu3SEZMOhPX7-fHI59MEPUe7I,517
|
|
10
10
|
promptbuilder/llm_client/aisuite_client.py,sha256=_TfB1xv73kIn4n8ulV3bj8bHOVm4DOD5uIdX-pbYoXY,15563
|
|
11
11
|
promptbuilder/llm_client/anthropic_client.py,sha256=HSIAZVOQoi3hinjhBVGqpt91k0x38xj6EUsPSUrlAA0,28076
|
|
12
|
-
promptbuilder/llm_client/base_client.py,sha256=
|
|
12
|
+
promptbuilder/llm_client/base_client.py,sha256=2VXc3Jw1ugu8VTTeK72Ntvh2Zobg23uxw1a6qY6W6HI,28908
|
|
13
13
|
promptbuilder/llm_client/bedrock_client.py,sha256=rJMzVV7x_sNJ1nVVqWU1sU-Pq7xlxFxIa_hTD2wtM1Y,27943
|
|
14
14
|
promptbuilder/llm_client/config.py,sha256=exQEm35wp7lK5SfXNpN5H9VZEb2LVa4pyZ-cxGt1U-U,1124
|
|
15
15
|
promptbuilder/llm_client/exceptions.py,sha256=t-X7r_a8B1jNu8eEavde1jXu5dz97yV3IG4YHOtgh0Y,4836
|
|
@@ -20,8 +20,8 @@ promptbuilder/llm_client/main.py,sha256=m-9jM2IYMFy6aZBUmPb52wpFlIK0H1aRj293oFmx
|
|
|
20
20
|
promptbuilder/llm_client/openai_client.py,sha256=lT0RCiixJBoCtzUbL_0J5NQ5G8KGONzK3dQ73_NgL78,24789
|
|
21
21
|
promptbuilder/llm_client/types.py,sha256=kgbg5FRzvZwu98y1OhAZJDneXBNPnsFZueQCr9HXIY4,8063
|
|
22
22
|
promptbuilder/llm_client/utils.py,sha256=79lvSppjrrItHB5MIozbp_5Oq7TsOK4Qzt9Ae3XMLFw,7624
|
|
23
|
-
promptbuilder-0.4.
|
|
24
|
-
promptbuilder-0.4.
|
|
25
|
-
promptbuilder-0.4.
|
|
26
|
-
promptbuilder-0.4.
|
|
27
|
-
promptbuilder-0.4.
|
|
23
|
+
promptbuilder-0.4.30.dist-info/licenses/LICENSE,sha256=fqXmInzgsvEOIaKSBgcrwKyYCGYF0MKErJ0YivtODcc,1096
|
|
24
|
+
promptbuilder-0.4.30.dist-info/METADATA,sha256=wKv1yEjLK2Zm8jOyXaY0_7mNcug1ZorhfHlPDFw3sA4,3729
|
|
25
|
+
promptbuilder-0.4.30.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
+
promptbuilder-0.4.30.dist-info/top_level.txt,sha256=UBVcYn4UgrPy3O3fmmnPEU_kieuplBMgheetIMei4EI,14
|
|
27
|
+
promptbuilder-0.4.30.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|