dotpromptz 0.1.2__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.
dotpromptz/__init__.py ADDED
@@ -0,0 +1,29 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # SPDX-License-Identifier: Apache-2.0
16
+
17
+ """Dotpromptz implements the .prompt templates for Python."""
18
+
19
+ from .dotprompt import Dotprompt
20
+
21
+
22
+ def package_name() -> str:
23
+ """Stub function to test imports."""
24
+ return 'dotpromptz'
25
+
26
+
27
+ __all__ = [
28
+ Dotprompt.__name__,
29
+ ]
@@ -0,0 +1,4 @@
1
+ # Copyright 2025 Google LLC
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ """Adapters for dotpromptz."""
@@ -0,0 +1,150 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # SPDX-License-Identifier: Apache-2.0
16
+
17
+ """Data models and interfaces type definitions using Pydantic v2."""
18
+
19
+ import sys # noqa
20
+
21
+ from typing import Any, Literal
22
+
23
+ from pydantic import BaseModel
24
+
25
+ from dotpromptz.typing import Role
26
+
27
+ if sys.version_info < (3, 11): # noqa
28
+ from strenum import StrEnum # noqa
29
+ else: # noqa
30
+ from enum import StrEnum # noqa
31
+
32
+
33
+ class DetailKind(StrEnum):
34
+ """The kind of Image URL detail."""
35
+
36
+ AUTO = 'auto'
37
+ LOW = 'low'
38
+ HIGH = 'high'
39
+
40
+
41
+ # Define TypedDicts to represent the interfaces
42
+ class ImageURLDetail(BaseModel):
43
+ """Image URL Detail."""
44
+
45
+ url: str
46
+ detail: DetailKind | None = None
47
+
48
+
49
+ class ContentItemType(StrEnum):
50
+ """Enumveration variants for content item type."""
51
+
52
+ TEXT = 'text'
53
+ IMAGE_URL = 'image_url'
54
+
55
+
56
+ class ContentItem(BaseModel):
57
+ """Content Item: can be text or image."""
58
+
59
+ type: ContentItemType
60
+ text: str | None = None
61
+ image_url: ImageURLDetail | None = None
62
+
63
+
64
+ class ToolFunction(BaseModel):
65
+ name: str
66
+ arguments: str
67
+
68
+
69
+ class ToolCallType(StrEnum):
70
+ """Enumeration variants for tool call type."""
71
+
72
+ FUNCTION = 'function'
73
+
74
+
75
+ class ToolCall(BaseModel):
76
+ id: str
77
+ type: ToolCallType
78
+ function: ToolFunction
79
+
80
+
81
+ class OpenAIMessage(BaseModel):
82
+ """Open AI Message"""
83
+
84
+ role: Role
85
+ content: str | list[ContentItem] | None = None
86
+ name: str | None = None
87
+ tool_calls: list[ToolCall] | None = None
88
+ tool_call_id: str | None = None
89
+
90
+
91
+ class OpenAIToolFunction(BaseModel):
92
+ name: str
93
+ description: str | None = None
94
+ parameters: dict[str, Any] | None = None
95
+
96
+
97
+ class OpenAIToolDefinition(BaseModel):
98
+ type: ToolCallType
99
+ function: OpenAIToolFunction
100
+
101
+
102
+ class ToolChoiceFunction(BaseModel):
103
+ name: str
104
+
105
+
106
+ class ToolChoice(BaseModel):
107
+ """Tool Choice"""
108
+
109
+ type: ToolCallType
110
+ function: ToolChoiceFunction
111
+
112
+
113
+ class ResponseFormatType(StrEnum):
114
+ """Enum variants for response format type."""
115
+
116
+ TEXT = 'text'
117
+ JSON_OBJECT = 'json_object'
118
+
119
+
120
+ class ResponseFormat(BaseModel):
121
+ """Expected Response Format"""
122
+
123
+ type: ResponseFormatType
124
+
125
+
126
+ ToolChoiceOptions = Literal['none', 'auto']
127
+
128
+
129
+ class OpenAIRequest(BaseModel):
130
+ """Open AI Request"""
131
+
132
+ messages: list[OpenAIMessage]
133
+ model: str
134
+ frequency_penalty: float | None = None
135
+ logit_bias: dict[str, int] | None = None
136
+ max_tokens: int | None = None
137
+ n: int | None = None
138
+ presence_penalty: float | None = None
139
+ response_format: ResponseFormat | None = None
140
+ seed: int | None = None
141
+ stop: str | list[str] | None = None
142
+ stream: bool | None = None
143
+ temperature: float | None = None
144
+ tool_choice: ToolChoiceOptions | ToolChoice | None = None
145
+ tools: list[OpenAIToolDefinition] | None = None
146
+ top_p: float | None = None
147
+ user: str | None = None
148
+
149
+
150
+ # Functions