Skip to content

Instantly share code, notes, and snippets.

@elijahbenizzy
Created December 31, 2024 23:19
Show Gist options
  • Save elijahbenizzy/63b0446cd9ef3d934f69a974e9c88eb9 to your computer and use it in GitHub Desktop.
Save elijahbenizzy/63b0446cd9ef3d934f69a974e9c88eb9 to your computer and use it in GitHub Desktop.
action(reads=[], writes=["markdown_content"])
def fetch_webpage(state: State, webpage_url: str) -> State:
"""Fetch a webpage and convert it to Markdown."""
try:
response = sgai_client.markdownify(website_url=webpage_url)
markdown_content = response["result"]
print(f"Request ID: {response['request_id']}")
print(f"Markdown Content: {markdown_content[:200]}... (truncated)")
return state.update(markdown_content=markdown_content)
except Exception as e:
sgai_logger.error(f"Failed to fetch webpage: {e}")
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment