promptbuilder 0.4.33__py3-none-any.whl → 0.4.34__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.
@@ -7,7 +7,7 @@ import logfire
7
7
 
8
8
  from promptbuilder.llm_client.utils import inherited_decorator
9
9
  from promptbuilder.llm_client.config import GLOBAL_CONFIG
10
- from promptbuilder.llm_client.types import Response, UsageMetadata
10
+ from promptbuilder.llm_client.types import Response, UsageMetadata, content_to_str
11
11
 
12
12
 
13
13
  P = ParamSpec("P")
@@ -24,9 +24,9 @@ def extract_span_data(self, *args, **kwargs) -> dict[str, Any]:
24
24
  logfire_messages.append({"role": "system", "content": system_message})
25
25
  for content in messages:
26
26
  if content.role == "user":
27
- logfire_messages.append({"role": "user", "content": content.as_str()})
27
+ logfire_messages.append({"role": "user", "content": content_to_str(content)})
28
28
  elif content.role == "model":
29
- logfire_messages.append({"role": "assistant", "content": content.as_str()})
29
+ logfire_messages.append({"role": "assistant", "content": content_to_str(content)})
30
30
  span_data["request_data"] = {"messages": logfire_messages}
31
31
  span_data["messages"] = messages
32
32
 
@@ -96,11 +96,13 @@ class Content(BaseModel):
96
96
  role: Role | None = None
97
97
 
98
98
  def as_str(self) -> str:
99
- if self.parts is None:
100
- return ""
101
- else:
102
- return "\n".join([(part.text or "") for part in self.parts])
99
+ return content_to_str(self)
103
100
 
101
+ def content_to_str(content: Content) -> str:
102
+ if content.parts is None:
103
+ return ""
104
+ else:
105
+ return "".join([part.text for part in content.parts if part.text])
104
106
 
105
107
  class FinishReason(Enum):
106
108
  """Output only. The reason why the model stopped generating tokens.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: promptbuilder
3
- Version: 0.4.33
3
+ Version: 0.4.34
4
4
  Summary: Library for building prompts for LLMs
5
5
  Home-page: https://github.com/kapulkin/promptbuilder
6
6
  Author: Kapulkin Stanislav
@@ -15,14 +15,14 @@ promptbuilder/llm_client/config.py,sha256=exQEm35wp7lK5SfXNpN5H9VZEb2LVa4pyZ-cxG
15
15
  promptbuilder/llm_client/exceptions.py,sha256=t-X7r_a8B1jNu8eEavde1jXu5dz97yV3IG4YHOtgh0Y,4836
16
16
  promptbuilder/llm_client/google_client.py,sha256=ZjJjDUQZH6zAIRoi4xUx3IDEm8jRkVWGyehy5P_Ba_M,12170
17
17
  promptbuilder/llm_client/litellm_client.py,sha256=NxVJORvQy5fSoqzPOagBliAhg2fjnFNnV5ZF7qckbVI,25561
18
- promptbuilder/llm_client/logfire_decorators.py,sha256=un_QnIekypOEcqTZ5v1y9pwijGnF95xwnwKO5rFSHVY,9667
18
+ promptbuilder/llm_client/logfire_decorators.py,sha256=pEPm3nTfqkg9kZr3s5ORs3fMex_z4Ce8CAt301m3OIk,9697
19
19
  promptbuilder/llm_client/main.py,sha256=2Q7J5FwivX2YwvptzoSEtCfvfcI9p5HC55D3mMb2se4,8243
20
20
  promptbuilder/llm_client/openai_client.py,sha256=QMXX7VPYWFo1VvX8bWF6jpi95ZIOk_MMBpz-14GrT-k,25274
21
- promptbuilder/llm_client/types.py,sha256=kgbg5FRzvZwu98y1OhAZJDneXBNPnsFZueQCr9HXIY4,8063
21
+ promptbuilder/llm_client/types.py,sha256=fnkSMFjK9ViaRQsD6LILpLz8R2_E1TI9efjy8VNO0RQ,8139
22
22
  promptbuilder/llm_client/utils.py,sha256=79lvSppjrrItHB5MIozbp_5Oq7TsOK4Qzt9Ae3XMLFw,7624
23
23
  promptbuilder/llm_client/vertex_client.py,sha256=OgbmRIYQXeK2kAh27ijhXuTzeg8APP38IyJ9WJqvDkY,15405
24
- promptbuilder-0.4.33.dist-info/licenses/LICENSE,sha256=fqXmInzgsvEOIaKSBgcrwKyYCGYF0MKErJ0YivtODcc,1096
25
- promptbuilder-0.4.33.dist-info/METADATA,sha256=LzmyQ7EyHXCNSmW_M_cXFdKimdlQvizbK85I5qf-uPs,3799
26
- promptbuilder-0.4.33.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
- promptbuilder-0.4.33.dist-info/top_level.txt,sha256=UBVcYn4UgrPy3O3fmmnPEU_kieuplBMgheetIMei4EI,14
28
- promptbuilder-0.4.33.dist-info/RECORD,,
24
+ promptbuilder-0.4.34.dist-info/licenses/LICENSE,sha256=fqXmInzgsvEOIaKSBgcrwKyYCGYF0MKErJ0YivtODcc,1096
25
+ promptbuilder-0.4.34.dist-info/METADATA,sha256=vGhJa-lzL9vGZm-4GTwWmYtqzpjPGEkVt7SL5Lvkskg,3799
26
+ promptbuilder-0.4.34.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
27
+ promptbuilder-0.4.34.dist-info/top_level.txt,sha256=UBVcYn4UgrPy3O3fmmnPEU_kieuplBMgheetIMei4EI,14
28
+ promptbuilder-0.4.34.dist-info/RECORD,,