Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
MinerU
Commits
373900a4
Commit
373900a4
authored
Jun 06, 2025
by
myhloli
Browse files
refactor: enhance content processing and improve JSON loading logic
parent
b0fd7566
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
mineru/utils/llm_aided.py
mineru/utils/llm_aided.py
+9
-3
No files found.
mineru/utils/llm_aided.py
View file @
373900a4
...
@@ -81,10 +81,16 @@ Corrected title list:
...
@@ -81,10 +81,16 @@ Corrected title list:
{
'role'
:
'user'
,
'content'
:
title_optimize_prompt
}],
{
'role'
:
'user'
,
'content'
:
title_optimize_prompt
}],
temperature
=
0.7
,
temperature
=
0.7
,
)
)
# logger.info(f"Title completion: {completion.choices[0].message.content}")
content
=
completion
.
choices
[
0
].
message
.
content
.
strip
()
dict_completion
=
ast
.
literal_eval
(
completion
.
choices
[
0
].
message
.
content
)
# logger.info(f"Title completion: {content}")
# logger.info(f"len(dict_completion): {len(dict_completion)}, len(title_dict): {len(title_dict)}")
if
"</think>"
in
content
:
idx
=
content
.
index
(
"</think>"
)
+
len
(
"</think>"
)
content
=
content
[
idx
:].
strip
()
import
json_repair
dict_completion
=
json_repair
.
loads
(
content
)
dict_completion
=
{
int
(
k
):
int
(
v
)
for
k
,
v
in
dict_completion
.
items
()}
# logger.info(f"len(dict_completion): {len(dict_completion)}, len(title_dict): {len(title_dict)}")
if
len
(
dict_completion
)
==
len
(
title_dict
):
if
len
(
dict_completion
)
==
len
(
title_dict
):
for
i
,
origin_title_block
in
enumerate
(
origin_title_list
):
for
i
,
origin_title_block
in
enumerate
(
origin_title_list
):
origin_title_block
[
"level"
]
=
int
(
dict_completion
[
i
])
origin_title_block
[
"level"
]
=
int
(
dict_completion
[
i
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment