Skip to content

Commit

Permalink
Added hints to web surfer.
Browse files Browse the repository at this point in the history
  • Loading branch information
afourney committed Feb 14, 2024
1 parent 76d0e78 commit 0d72715
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions autogen/agentchat/contrib/web_surfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def _browser_state() -> Tuple[str, str]:
total_pages = len(self.browser.viewport_pages)

header += f"Viewport position: Showing page {current_page+1} of {total_pages}.\n"
header += "Hint: Looking for something specific on this page? Try calling 'read_page_and_answer'.\n"
return (header, self.browser.viewport)

@self._user_proxy.register_for_execution()
Expand Down Expand Up @@ -187,10 +188,10 @@ def _page_down() -> str:

@self._user_proxy.register_for_execution()
@self._assistant.register_for_llm(
name="answer_from_page",
name="read_page_and_answer",
description="Uses AI to read the page and directly answer a given question based on the content.",
)
def _answer_from_page(
def _read_page_and_answer(
question: Annotated[Optional[str], "The question to directly answer."],
url: Annotated[Optional[str], "[Optional] The url of the page. (Defaults to the current page)"] = None,
) -> str:
Expand Down Expand Up @@ -251,7 +252,7 @@ def _summarize_page(
Optional[str], "[Optional] The url of the page to summarize. (Defaults to current page)"
] = None
) -> str:
return _answer_from_page(url=url, question=None)
return _read_page_and_answer(url=url, question=None)

def generate_surfer_reply(
self,
Expand Down

0 comments on commit 0d72715

Please sign in to comment.