pyconverters-openai_vision 0.5.38__tar.gz → 0.5.40__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.
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/PKG-INFO +1 -1
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/pyconverters_openai_vision/__init__.py +1 -1
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/pyconverters_openai_vision/openai_vision.py +7 -1
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/setup.py +1 -1
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/test_openai_vision.py +18 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/.dockerignore +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/.gitignore +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/Dockerfile +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/Jenkinsfile +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/README.md +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/bumpversion.py +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/pyconverters_openai_vision/openai_utils.py +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/pyproject.toml +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/__init__.py +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/ENG product fact files_general offer_2025_30pages.json +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/ENG product fact files_general offer_2025_30pages_alts.json +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/ENG product fact files_general offer_2025_30pages_descs.json +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/PC_Kairntech_LLM_v1.md.json +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/colducoq.jpg +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/webinar.png +0 -0
- {pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tox.ini +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"""OpenAIVision converter"""
|
|
2
|
-
__version__ = "0.5.
|
|
2
|
+
__version__ = "0.5.40"
|
|
@@ -180,7 +180,7 @@ class OpenAIVisionConverterBase(ConverterBase):
|
|
|
180
180
|
return kwargs
|
|
181
181
|
|
|
182
182
|
def compute_result(self, base_url, **kwargs):
|
|
183
|
-
pattern: Pattern = re.compile(r"```(?:markdown
|
|
183
|
+
pattern: Pattern = re.compile(r"```(?:markdown|json|python|html)?(\W.*?)```", re.DOTALL)
|
|
184
184
|
"""Regex pattern to parse the output."""
|
|
185
185
|
response = openai_chat_completion(self.PREFIX, self.oauth_token, base_url, **kwargs)
|
|
186
186
|
contents = []
|
|
@@ -191,6 +191,12 @@ class OpenAIVisionConverterBase(ConverterBase):
|
|
|
191
191
|
action_match = pattern.search(choice.message.content)
|
|
192
192
|
if action_match is not None:
|
|
193
193
|
contents.append(action_match.group(1).strip())
|
|
194
|
+
else:
|
|
195
|
+
action_match = re.search(r"```(.*?)```", choice.message.content, re.DOTALL)
|
|
196
|
+
if action_match is not None:
|
|
197
|
+
contents.append(action_match.group(1).strip())
|
|
198
|
+
else:
|
|
199
|
+
contents.append(choice.message.content)
|
|
194
200
|
else:
|
|
195
201
|
contents.append(choice.message.content)
|
|
196
202
|
if contents:
|
|
@@ -48,7 +48,7 @@ entry_points = \
|
|
|
48
48
|
'pyconverters_openai_vision.openai_vision:OpenAIVisionProcessor']}
|
|
49
49
|
|
|
50
50
|
setup(name='pyconverters-openai_vision',
|
|
51
|
-
version='0.5.
|
|
51
|
+
version='0.5.40',
|
|
52
52
|
description='OpenAIVision converter',
|
|
53
53
|
author='Olivier Terrier',
|
|
54
54
|
author_email='olivier.terrier@kairntech.com',
|
{pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/test_openai_vision.py
RENAMED
|
@@ -107,3 +107,21 @@ def test_runpod():
|
|
|
107
107
|
assert len(docs) == 1
|
|
108
108
|
doc0 = docs[0]
|
|
109
109
|
assert 'generative ai' in doc0.text.lower()
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@pytest.mark.skip(reason="Not a test")
|
|
113
|
+
def test_openai_error():
|
|
114
|
+
converter = OpenAIVisionConverter()
|
|
115
|
+
parameters = OpenAIVisionParameters(prompt='''You are an assistant capable of transforming an image into text in markdown.
|
|
116
|
+
For the image provided, return a text containing:
|
|
117
|
+
objects: [“list of detected objects”],
|
|
118
|
+
visible_text: [“text detected in the image”],
|
|
119
|
+
main_colors: [“list of dominant colors”],
|
|
120
|
+
description: “narrative description of the image”''')
|
|
121
|
+
testdir = Path(__file__).parent
|
|
122
|
+
source = Path(testdir, 'data/ChatGPT Image 12 déc. 2025, 08_57_52.png')
|
|
123
|
+
with source.open("rb") as fin:
|
|
124
|
+
docs: List[Document] = converter.convert(UploadFile(source.name, fin, 'image/png'), parameters)
|
|
125
|
+
assert len(docs) == 1
|
|
126
|
+
doc0 = docs[0]
|
|
127
|
+
assert 'dent de crolles' in doc0.text.lower()
|
|
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
|
{pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/colducoq.jpg
RENAMED
|
File without changes
|
{pyconverters_openai_vision-0.5.38 → pyconverters_openai_vision-0.5.40}/tests/data/webinar.png
RENAMED
|
File without changes
|
|
File without changes
|