pyconverters-openai_vision 0.5.32__py3-none-any.whl → 0.5.36__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.
- pyconverters_openai_vision/__init__.py +1 -1
- pyconverters_openai_vision/openai_vision.py +18 -7
- {pyconverters_openai_vision-0.5.32.dist-info → pyconverters_openai_vision-0.5.36.dist-info}/METADATA +1 -1
- pyconverters_openai_vision-0.5.36.dist-info/RECORD +7 -0
- pyconverters_openai_vision-0.5.32.dist-info/RECORD +0 -7
- {pyconverters_openai_vision-0.5.32.dist-info → pyconverters_openai_vision-0.5.36.dist-info}/WHEEL +0 -0
- {pyconverters_openai_vision-0.5.32.dist-info → pyconverters_openai_vision-0.5.36.dist-info}/entry_points.txt +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""OpenAIVision converter"""
|
|
2
|
-
__version__ = "0.5.
|
|
2
|
+
__version__ = "0.5.36"
|
|
@@ -147,6 +147,10 @@ class OpenAIVisionConverterBase(ConverterBase):
|
|
|
147
147
|
PREFIX: str = ""
|
|
148
148
|
oauth_token: OAuthToken = OAuthToken()
|
|
149
149
|
|
|
150
|
+
@classmethod
|
|
151
|
+
def is_model_gpt_5_model(cls, model: str) -> bool:
|
|
152
|
+
return "gpt-5" in model
|
|
153
|
+
|
|
150
154
|
def compute_args(self, params: OpenAIVisionBaseParameters, source: UploadFile, kind
|
|
151
155
|
) -> Dict[str, Any]:
|
|
152
156
|
data = source.file.read()
|
|
@@ -155,7 +159,7 @@ class OpenAIVisionConverterBase(ConverterBase):
|
|
|
155
159
|
binary_block = {
|
|
156
160
|
"type": "image_url",
|
|
157
161
|
"image_url": {
|
|
158
|
-
"url": f"data:
|
|
162
|
+
"url": f"data:{kind.mime};base64,{rv.decode('utf-8')}"
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
messages = [{"role": "system", "content": params.system_prompt}] if params.system_prompt is not None else []
|
|
@@ -167,10 +171,11 @@ class OpenAIVisionConverterBase(ConverterBase):
|
|
|
167
171
|
},
|
|
168
172
|
binary_block
|
|
169
173
|
]})
|
|
174
|
+
max_tokens_param = 'max_completion_tokens' if self.is_model_gpt_5_model(params.model_str) else 'max_tokens'
|
|
170
175
|
kwargs = {
|
|
171
176
|
'model': params.model_str,
|
|
172
177
|
'messages': messages,
|
|
173
|
-
|
|
178
|
+
max_tokens_param: params.max_tokens,
|
|
174
179
|
'temperature': params.temperature,
|
|
175
180
|
'top_p': params.top_p,
|
|
176
181
|
'n': params.n,
|
|
@@ -299,12 +304,12 @@ class OpenAIVisionProcessorBaseParameters(ProcessorParameters):
|
|
|
299
304
|
extra="advanced"
|
|
300
305
|
)
|
|
301
306
|
system_prompt: str = Field(
|
|
302
|
-
|
|
307
|
+
None,
|
|
303
308
|
description="""Contains the system prompt""",
|
|
304
309
|
extra="multiline,advanced",
|
|
305
310
|
)
|
|
306
311
|
prompt: str = Field(
|
|
307
|
-
|
|
312
|
+
"Generate a textual description of the image",
|
|
308
313
|
description="""Contains the prompt""",
|
|
309
314
|
extra="multiline",
|
|
310
315
|
)
|
|
@@ -357,6 +362,10 @@ class OpenAIVisionProcessorBase(ProcessorBase):
|
|
|
357
362
|
PREFIX: str = ""
|
|
358
363
|
oauth_token: OAuthToken = OAuthToken()
|
|
359
364
|
|
|
365
|
+
@classmethod
|
|
366
|
+
def is_model_gpt_5_model(cls, model: str) -> bool:
|
|
367
|
+
return "gpt-5" in model
|
|
368
|
+
|
|
360
369
|
def compute_args(self, params: OpenAIVisionProcessorBaseParameters, source: str, kind
|
|
361
370
|
) -> Dict[str, Any]:
|
|
362
371
|
if kind.mime.startswith("image"):
|
|
@@ -375,10 +384,11 @@ class OpenAIVisionProcessorBase(ProcessorBase):
|
|
|
375
384
|
},
|
|
376
385
|
binary_block
|
|
377
386
|
]})
|
|
387
|
+
max_tokens_param = 'max_completion_tokens' if self.is_model_gpt_5_model(params.model_str) else 'max_tokens'
|
|
378
388
|
kwargs = {
|
|
379
389
|
'model': params.model_str,
|
|
380
390
|
'messages': messages,
|
|
381
|
-
|
|
391
|
+
max_tokens_param: params.max_tokens,
|
|
382
392
|
'temperature': params.temperature,
|
|
383
393
|
'top_p': params.top_p,
|
|
384
394
|
'n': params.n,
|
|
@@ -446,8 +456,9 @@ class OpenAIVisionProcessorBase(ProcessorBase):
|
|
|
446
456
|
m = matchobj.group(0)
|
|
447
457
|
m_id = matchobj.group(1)
|
|
448
458
|
if m_id in alts:
|
|
449
|
-
|
|
450
|
-
|
|
459
|
+
# markdown blockquote
|
|
460
|
+
m_desc = "\n".join(["> " + li for li in alts[m_id].splitlines()])
|
|
461
|
+
return f"{m}\n{m_desc}\n"
|
|
451
462
|
return m
|
|
452
463
|
|
|
453
464
|
ptext = re.sub(link_regex, convert_links, text, 0,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
pyconverters_openai_vision/__init__.py,sha256=-BX6FHKC8AX-7vCq_-SC81FmeXDVkY1SIy4vU9f9-gU,52
|
|
2
|
+
pyconverters_openai_vision/openai_utils.py,sha256=XI4WYZ-EAVG0Vxd5yUDuZNDgEzqHJeriScxTUusi1oo,7740
|
|
3
|
+
pyconverters_openai_vision/openai_vision.py,sha256=Lp8g8KbTvRznOrC7dPRM-C9qmZcgzs-Kq6QidHtZwA4,23780
|
|
4
|
+
pyconverters_openai_vision-0.5.36.dist-info/entry_points.txt,sha256=NR0re-yebKKyhApky1I6nDQzjJQfEyfOkJlJju0Ngzo,404
|
|
5
|
+
pyconverters_openai_vision-0.5.36.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
6
|
+
pyconverters_openai_vision-0.5.36.dist-info/METADATA,sha256=govETANuIkSFp_1AAH1t2AxwryMgupNpZ2VERpWhbyI,2662
|
|
7
|
+
pyconverters_openai_vision-0.5.36.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
pyconverters_openai_vision/__init__.py,sha256=u1qzNNU3oXNQEdCLbHC2tSiBYPkFG6jkkixct0t9Zwo,52
|
|
2
|
-
pyconverters_openai_vision/openai_utils.py,sha256=XI4WYZ-EAVG0Vxd5yUDuZNDgEzqHJeriScxTUusi1oo,7740
|
|
3
|
-
pyconverters_openai_vision/openai_vision.py,sha256=OGr1veVTxgWxxClMNXeNCiuVrBhGA5ZpjbsoThRMXn8,23231
|
|
4
|
-
pyconverters_openai_vision-0.5.32.dist-info/entry_points.txt,sha256=NR0re-yebKKyhApky1I6nDQzjJQfEyfOkJlJju0Ngzo,404
|
|
5
|
-
pyconverters_openai_vision-0.5.32.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
|
|
6
|
-
pyconverters_openai_vision-0.5.32.dist-info/METADATA,sha256=spGRRfpd6RtKo3OJWmsXRv90ENoJpraJ9UtYS8NbYqg,2662
|
|
7
|
-
pyconverters_openai_vision-0.5.32.dist-info/RECORD,,
|
{pyconverters_openai_vision-0.5.32.dist-info → pyconverters_openai_vision-0.5.36.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|