FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DeepResearchAgent/src/utils/string_utils.py at main · SkyworkAI/DeepResearchAgent · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
SkyworkAI
/
DeepResearchAgent
Public
Notifications
You must be signed in to change notification settings
Fork
456
Star
3.5k
Code
Issues
3
Pull requests
7
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
DeepResearchAgent
/
src
/
utils
/
string_utils.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (37 loc) · 1.15 KB
Breadcrumbs
DeepResearchAgent
/
src
/
utils
/
string_utils.py
Copy path
File metadata and controls
44 lines (37 loc) · 1.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import
hashlib
import
uuid
from
datetime
import
datetime
def
hash_text_sha256
(
text
:
str
)
->
str
:
hash_object
=
hashlib
.
sha256
(
text
.
encode
())
return
hash_object
.
hexdigest
()
def
extract_boxed_content
(
text
:
str
)
->
str
:
"""
Extracts answers in
\\
boxed{}.
"""
depth
=
0
start_pos
=
text
.
rfind
(
r"\boxed{"
)
end_pos
=
-
1
if
start_pos
!=
-
1
:
content
=
text
[
start_pos
+
len
(
r"\boxed{"
) :]
for
i
,
char
in
enumerate
(
content
):
if
char
==
"{"
:
depth
+=
1
elif
char
==
"}"
:
depth
-=
1
if
depth
==
-
1
:
# exit
end_pos
=
i
break
if
end_pos
!=
-
1
:
return
content
[:
end_pos
].
strip
()
return
"None"
def
dedent
(
text
:
str
)
->
str
:
"""
Dedent the text and expand the tabs.
"""
clean
=
"
\n
"
.
join
(
line
.
strip
()
for
line
in
text
.
splitlines
())
return
clean
def
generate_unique_id
(
prefix
:
str
=
"session"
)
->
str
:
"""Generate a unique id using timestamp and UUID."""
timestamp
=
datetime
.
now
().
strftime
(
"%Y%m%d-%H%M%S"
)
unique_id
=
str
(
uuid
.
uuid4
())[:
8
]
return
f"
{
prefix
}
_
{
timestamp
}
_
{
unique_id
}
"
Back
|
FazBrowse Home
|
New Git URL