Skip to content

Commit b80c550

Browse files
enhance url2note
1 parent 42490b2 commit b80c550

File tree

2 files changed

+68
-344
lines changed

2 files changed

+68
-344
lines changed

dialoghelper/core.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,16 @@ def run_msg(
272272
def url2note(
273273
url:str, # URL to read
274274
extract_section:bool=True, # If url has an anchor, return only that section
275-
selector:str=None # Select section(s) using BeautifulSoup.select (overrides extract_section)
275+
selector:str=None, # Select section(s) using BeautifulSoup.select (overrides extract_section)
276+
ai_img:bool=True, # Make images visible to the AI
277+
split_re:str=r'(?=^#{1,6} .+)' # Regex to split content into multiple notes, set to False for single note
276278
):
277-
"Read URL as markdown, and add a note below current message with the result"
278-
res = read_url(url, as_md=True, extract_section=extract_section, selector=selector)
279+
"Read URL as markdown, and add note(s) below current message with the result"
280+
res = read_url(url, as_md=True, extract_section=extract_section, selector=selector, ai_img=ai_img)
281+
if split_re: return [add_msg(s) for s in re.split(split_re, res, flags=re.MULTILINE) if s.strip()]
279282
return add_msg(res)
280283

284+
281285
# %% ../nbs/00_core.ipynb
282286
def ast_py(code:str):
283287
"Get an SgRoot root node for python `code`"

0 commit comments

Comments
 (0)