promptbuilder 0.4.21__tar.gz → 0.4.23__tar.gz
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-0.4.21/promptbuilder.egg-info → promptbuilder-0.4.23}/PKG-INFO +2 -2
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/base_client.py +8 -3
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/types.py +17 -5
- {promptbuilder-0.4.21 → promptbuilder-0.4.23/promptbuilder.egg-info}/PKG-INFO +2 -2
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder.egg-info/requires.txt +1 -1
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/setup.py +2 -2
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/LICENSE +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/MANIFEST.in +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/Readme.md +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/__init__.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/agent/__init__.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/agent/agent.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/agent/context.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/agent/tool.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/agent/utils.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/embeddings.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/__init__.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/aisuite_client.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/anthropic_client.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/bedrock_client.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/config.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/exceptions.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/google_client.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/logfire_decorators.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/main.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/openai_client.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/utils.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/prompt_builder.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder.egg-info/SOURCES.txt +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder.egg-info/dependency_links.txt +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder.egg-info/top_level.txt +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/pyproject.toml +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/setup.cfg +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/tests/test_llm_client.py +0 -0
- {promptbuilder-0.4.21 → promptbuilder-0.4.23}/tests/test_llm_client_async.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: promptbuilder
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.23
|
|
4
4
|
Summary: Library for building prompts for LLMs
|
|
5
5
|
Home-page: https://github.com/kapulkin/promptbuilder
|
|
6
6
|
Author: Kapulkin Stanislav
|
|
@@ -14,7 +14,7 @@ License-File: LICENSE
|
|
|
14
14
|
Requires-Dist: pydantic
|
|
15
15
|
Requires-Dist: pytest
|
|
16
16
|
Requires-Dist: aisuite-async
|
|
17
|
-
Requires-Dist: google-genai
|
|
17
|
+
Requires-Dist: google-genai>=1.4.0
|
|
18
18
|
Requires-Dist: anthropic
|
|
19
19
|
Requires-Dist: openai
|
|
20
20
|
Requires-Dist: aioboto3
|
|
@@ -5,6 +5,7 @@ import hashlib
|
|
|
5
5
|
import logging
|
|
6
6
|
from abc import ABC, abstractmethod
|
|
7
7
|
from typing import Iterator, AsyncIterator, Literal, overload
|
|
8
|
+
from pydantic import BaseModel
|
|
8
9
|
|
|
9
10
|
from promptbuilder.llm_client.types import Response, Content, Part, Tool, ToolConfig, FunctionCall, FunctionCallingConfig, Json, ThinkingConfig, ApiKey, PydanticStructure, ResultType, FinishReason
|
|
10
11
|
import promptbuilder.llm_client.utils as utils
|
|
@@ -178,7 +179,7 @@ class BaseLLMClient(ABC, utils.InheritDecoratorsMixin):
|
|
|
178
179
|
tool_config=ToolConfig(function_calling_config=FunctionCallingConfig(mode=tool_choice_mode)),
|
|
179
180
|
)
|
|
180
181
|
|
|
181
|
-
while autocomplete and response.candidates and response.candidates[0].finish_reason
|
|
182
|
+
while autocomplete and response.candidates and response.candidates[0].finish_reason in [FinishReason.STOP, FinishReason.MAX_TOKENS]:
|
|
182
183
|
BaseLLMClient._append_generated_part(messages, response)
|
|
183
184
|
|
|
184
185
|
response = self.create(
|
|
@@ -605,7 +606,12 @@ class CachedLLMClient(BaseLLMClient):
|
|
|
605
606
|
with open(cache_path, "rt") as f:
|
|
606
607
|
cache_data = json.load(f)
|
|
607
608
|
if cache_data["full_model_name"] == llm_client.full_model_name and json.dumps(cache_data["request"]) == json.dumps(messages_dump):
|
|
608
|
-
|
|
609
|
+
response = Response(**cache_data["response"])
|
|
610
|
+
result_type = kwargs.get("result_type", None)
|
|
611
|
+
if result_type is not None and isinstance(result_type, type(BaseModel)):
|
|
612
|
+
response.parsed = result_type.model_validate(response.parsed)
|
|
613
|
+
|
|
614
|
+
return response, messages_dump, cache_path
|
|
609
615
|
else:
|
|
610
616
|
logger.debug(f"Cache mismatch for {key}")
|
|
611
617
|
except (json.JSONDecodeError, KeyError) as e:
|
|
@@ -637,4 +643,3 @@ class CachedLLMClientAsync(BaseLLMClientAsync):
|
|
|
637
643
|
response = await self.llm_client.create(messages, **kwargs)
|
|
638
644
|
CachedLLMClient.save_cache(cache_path, self.llm_client.full_model_name, messages_dump, response)
|
|
639
645
|
return response
|
|
640
|
-
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from abc import ABC, abstractmethod
|
|
3
|
-
from typing import Optional, Any, Callable, Literal, TypeVar, Self
|
|
3
|
+
from typing import Optional, Any, Callable, Literal, TypeVar, Self, Protocol, runtime_checkable
|
|
4
4
|
from enum import Enum
|
|
5
5
|
|
|
6
|
-
from pydantic import BaseModel, model_validator
|
|
6
|
+
from pydantic import BaseModel, model_validator, ConfigDict
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
logger = logging.getLogger(__name__)
|
|
@@ -17,6 +17,16 @@ PydanticStructure = TypeVar("PydanticStructure", bound=BaseModel)
|
|
|
17
17
|
type ResultType = Literal["json"] | type[PydanticStructure] | None
|
|
18
18
|
|
|
19
19
|
|
|
20
|
+
@runtime_checkable
|
|
21
|
+
class PartLike(Protocol):
|
|
22
|
+
"""Protocol for Part-like objects that have the same interface as Part."""
|
|
23
|
+
text: Optional[str]
|
|
24
|
+
function_call: Optional[Any] # Using Any to allow different FunctionCall types
|
|
25
|
+
function_response: Optional[Any] # Using Any to allow different FunctionResponse types
|
|
26
|
+
thought: Optional[bool]
|
|
27
|
+
inline_data: Optional[Any] # Using Any to allow different Blob types
|
|
28
|
+
|
|
29
|
+
|
|
20
30
|
class CustomApiKey(ABC):
|
|
21
31
|
@abstractmethod
|
|
22
32
|
def __hash__(self):
|
|
@@ -80,14 +90,16 @@ class Part(BaseModel):
|
|
|
80
90
|
return cls(inline_data=inline_data)
|
|
81
91
|
|
|
82
92
|
class Content(BaseModel):
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
model_config = ConfigDict(arbitrary_types_allowed=True)
|
|
94
|
+
|
|
95
|
+
parts: list[Part | PartLike] | None = None
|
|
96
|
+
role: Role | None = None
|
|
85
97
|
|
|
86
98
|
def as_str(self) -> str:
|
|
87
99
|
if self.parts is None:
|
|
88
100
|
return ""
|
|
89
101
|
else:
|
|
90
|
-
return "\n".join([part.
|
|
102
|
+
return "\n".join([(part.text or "") for part in self.parts])
|
|
91
103
|
|
|
92
104
|
|
|
93
105
|
class FinishReason(Enum):
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: promptbuilder
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.23
|
|
4
4
|
Summary: Library for building prompts for LLMs
|
|
5
5
|
Home-page: https://github.com/kapulkin/promptbuilder
|
|
6
6
|
Author: Kapulkin Stanislav
|
|
@@ -14,7 +14,7 @@ License-File: LICENSE
|
|
|
14
14
|
Requires-Dist: pydantic
|
|
15
15
|
Requires-Dist: pytest
|
|
16
16
|
Requires-Dist: aisuite-async
|
|
17
|
-
Requires-Dist: google-genai
|
|
17
|
+
Requires-Dist: google-genai>=1.4.0
|
|
18
18
|
Requires-Dist: anthropic
|
|
19
19
|
Requires-Dist: openai
|
|
20
20
|
Requires-Dist: aioboto3
|
|
@@ -2,13 +2,13 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="promptbuilder",
|
|
5
|
-
version="0.4.
|
|
5
|
+
version="0.4.23",
|
|
6
6
|
packages=find_packages(),
|
|
7
7
|
install_requires=[
|
|
8
8
|
"pydantic",
|
|
9
9
|
"pytest",
|
|
10
10
|
"aisuite-async",
|
|
11
|
-
"google-genai>=1.4.0
|
|
11
|
+
"google-genai>=1.4.0",
|
|
12
12
|
"anthropic",
|
|
13
13
|
"openai",
|
|
14
14
|
"aioboto3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{promptbuilder-0.4.21 → promptbuilder-0.4.23}/promptbuilder/llm_client/logfire_decorators.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|