pop-python 1.0.3__py3-none-any.whl → 1.0.4__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.
- POP/LLMClient.py +12 -5
- POP/POP.py +17 -9
- {pop_python-1.0.3.dist-info → pop_python-1.0.4.dist-info}/METADATA +1 -1
- {pop_python-1.0.3.dist-info → pop_python-1.0.4.dist-info}/RECORD +7 -7
- {pop_python-1.0.3.dist-info → pop_python-1.0.4.dist-info}/WHEEL +0 -0
- {pop_python-1.0.3.dist-info → pop_python-1.0.4.dist-info}/licenses/LICENSE +0 -0
- {pop_python-1.0.3.dist-info → pop_python-1.0.4.dist-info}/top_level.txt +0 -0
POP/LLMClient.py
CHANGED
|
@@ -84,11 +84,11 @@ class OpenAIClient(LLMClient):
|
|
|
84
84
|
else:
|
|
85
85
|
request_payload["response_format"] = {"type": "json_schema", "json_schema": fmt}
|
|
86
86
|
|
|
87
|
-
# Handle function tools
|
|
87
|
+
# Handle function tools (already OpenAI-style)
|
|
88
88
|
tools = kwargs.get("tools", None)
|
|
89
89
|
if tools:
|
|
90
|
-
request_payload["tools"] =
|
|
91
|
-
request_payload["tool_choice"] = "auto"
|
|
90
|
+
request_payload["tools"] = tools
|
|
91
|
+
request_payload["tool_choice"] = kwargs.get("tool_choice", "auto")
|
|
92
92
|
|
|
93
93
|
# Temporary patch for models not supporting system roles
|
|
94
94
|
if model == "o1-mini" and request_payload["messages"] and request_payload["messages"][0]["role"] == "system":
|
|
@@ -140,6 +140,12 @@ class DeepseekClient(LLMClient):
|
|
|
140
140
|
role = msg.get("role", "user")
|
|
141
141
|
request_payload["messages"].append({"role": role, "content": content})
|
|
142
142
|
|
|
143
|
+
# tools: OpenAI-style list
|
|
144
|
+
tools = kwargs.get("tools", None)
|
|
145
|
+
if tools:
|
|
146
|
+
request_payload["tools"] = tools
|
|
147
|
+
request_payload["tool_choice"] = kwargs.get("tool_choice", "auto")
|
|
148
|
+
|
|
143
149
|
# Execute request
|
|
144
150
|
try:
|
|
145
151
|
response = self.client.chat.completions.create(**request_payload)
|
|
@@ -291,7 +297,8 @@ class DoubaoClient(LLMClient):
|
|
|
291
297
|
# Tools (function calling)
|
|
292
298
|
tools = kwargs.get("tools")
|
|
293
299
|
if tools:
|
|
294
|
-
|
|
300
|
+
payload["tools"] = tools
|
|
301
|
+
payload["tool_choice"] = kwargs.get("tool_choice", "auto")
|
|
295
302
|
try:
|
|
296
303
|
response = self.client.chat.completions.create(**payload)
|
|
297
304
|
except Exception as e:
|
|
@@ -400,4 +407,4 @@ class OllamaClient(LLMClient):
|
|
|
400
407
|
class Response:
|
|
401
408
|
def __init__(self, content): self.choices = [Choice(Message(content))]
|
|
402
409
|
|
|
403
|
-
return Response(content)
|
|
410
|
+
return Response(content)
|
POP/POP.py
CHANGED
|
@@ -70,6 +70,7 @@ class PromptFunction:
|
|
|
70
70
|
- sys: Additional system instructions.
|
|
71
71
|
- fmt: Response format/schema.
|
|
72
72
|
- tools: List of function tools to use (for function calling).
|
|
73
|
+
- tool_choice
|
|
73
74
|
- temp: Temperature.
|
|
74
75
|
- ADD_BEFORE: Text to prepend.
|
|
75
76
|
- ADD_AFTER: Text to append.
|
|
@@ -87,6 +88,9 @@ class PromptFunction:
|
|
|
87
88
|
tools = kwargs.pop("tools", None)
|
|
88
89
|
temp = kwargs.pop("temp", self.temperature)
|
|
89
90
|
images = kwargs.pop("images", None)
|
|
91
|
+
tool_choice = kwargs.pop("tool_choice", None)
|
|
92
|
+
if tools and not tool_choice:
|
|
93
|
+
tool_choice = "auto"
|
|
90
94
|
|
|
91
95
|
# Prepare the prompt with dynamic injections.
|
|
92
96
|
formatted_prompt = self._prepare_prompt(*args, **kwargs)
|
|
@@ -105,15 +109,19 @@ class PromptFunction:
|
|
|
105
109
|
messages = [system_message, user_message]
|
|
106
110
|
|
|
107
111
|
try:
|
|
108
|
-
# Call the LLM client.
|
|
109
|
-
|
|
110
|
-
messages
|
|
111
|
-
model
|
|
112
|
-
temperature
|
|
113
|
-
response_format
|
|
114
|
-
tools
|
|
115
|
-
images
|
|
116
|
-
|
|
112
|
+
# Call the LLM client. Always include tool_choice when tools are provided.
|
|
113
|
+
call_kwargs = {
|
|
114
|
+
"messages": messages,
|
|
115
|
+
"model": model,
|
|
116
|
+
"temperature": temp,
|
|
117
|
+
"response_format": fmt,
|
|
118
|
+
"tools": tools,
|
|
119
|
+
"images": images,
|
|
120
|
+
# Always include tool_choice key so callers can assert on it
|
|
121
|
+
"tool_choice": tool_choice,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
raw_response = self.client.chat_completion(**call_kwargs)
|
|
117
125
|
except Exception as e:
|
|
118
126
|
verbose = True
|
|
119
127
|
if verbose:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
POP/Embedder.py,sha256=KSqneJNdpkE5_b82AHhpXRXAD9DYt9bads6oMcvDIoM,10165
|
|
2
|
-
POP/LLMClient.py,sha256=
|
|
3
|
-
POP/POP.py,sha256=
|
|
2
|
+
POP/LLMClient.py,sha256=ew1Yt9pmt3tK6xfZN3_kJ5det0JsGg7fFXxy1zMahjk,15693
|
|
3
|
+
POP/POP.py,sha256=g9v0qa4G7bZPATRycHZ5owdKaha-YC8CD1U_YtnqH1Y,16319
|
|
4
4
|
POP/__init__.py,sha256=aHsN8USyF18G_8Pr3h49SClWywy0y1h5-63u_OSXBQM,429
|
|
5
5
|
POP/prompts/2024-11-19-content_finder.md,sha256=ncMkvL6xUgYDhSXEPGTw5rnYF3b2Gq1nRyAVdaLaNGA,2238
|
|
6
6
|
POP/prompts/2024-11-19-get_content.md,sha256=vQhkGBX5Doj4vsCIfAmGyLwl0f7wHw0TkEJE3wFBdxY,3530
|
|
@@ -19,8 +19,8 @@ POP/prompts/openai-json_schema_generator.md,sha256=5N8D3qm5UPqjZNqLYmDhwlCc1GeYH
|
|
|
19
19
|
POP/prompts/openai-prompt_generator.md,sha256=drMW9fSZUN8ldwNrvc_YsHDiSbwB58jonVSxdgydDro,3645
|
|
20
20
|
POP/schemas/biomedical_ner_extractor.json,sha256=WbWWWypvDdrHLvoFcEaCXa8Mx_FvmKLqUtYs2GWZujQ,929
|
|
21
21
|
POP/schemas/entity_extraction_per_sentence.json,sha256=S9g4pL_LOc36fNM-PA33kRNGEvKQYPe3GpHBrozwbdc,2149
|
|
22
|
-
pop_python-1.0.
|
|
23
|
-
pop_python-1.0.
|
|
24
|
-
pop_python-1.0.
|
|
25
|
-
pop_python-1.0.
|
|
26
|
-
pop_python-1.0.
|
|
22
|
+
pop_python-1.0.4.dist-info/licenses/LICENSE,sha256=zm0TNFsVPrnSK7IDoO504aeYMnO69QrL9IY9P5jRHHg,1064
|
|
23
|
+
pop_python-1.0.4.dist-info/METADATA,sha256=IsvC9tVfSjSQmzbaKw-HTbGcAYdqMYusGpt4HqWsjAY,7033
|
|
24
|
+
pop_python-1.0.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
25
|
+
pop_python-1.0.4.dist-info/top_level.txt,sha256=n_VDHKZJpAKLhVprDjVofH0AgoRlb1y_uO3aRHNmNyo,4
|
|
26
|
+
pop_python-1.0.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|