Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌎 Pass source metadata through content refresher agent #1185

Merged
merged 7 commits into from
Aug 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
error handle on content check
  • Loading branch information
shahrishabh7 committed Aug 4, 2023
commit a4a89cb634d2f090876ebcb59e9577758bbf1bb8
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 37,16 @@ async def run(self, workflow_id: str, **kwargs: Any) -> ContentRefresherOutput:

sources = search_results(keywords)
sources = [
(url, title) for url, title in sources if url != target_url
source for source in sources if source["url"] != target_url
] # TODO: check based on content overlap
logger.info(sources)

source_contents = [
(url, title, await get_page_content(url))
for url, title in sources[:3]
# TODO: remove limit of 3 sources
]
for source in sources[:3]: # TODO: remove limit of 3 sources
source["content"] = await get_page_content(source["url"])
logger.info(sources)

source_contents = [
(url, title, page_content)
for url, title, page_content in source_contents
if page_content is not None
source for source in sources if source.get("content", None) is not None
]
logger.info(source_contents)

Expand Down Expand Up @@ -138,7 134,7 @@ async def find_content_kws(content: str) -> str:
)


def search_results(search_query: str) -> list[tuple[str, str]]:
def search_results(search_query: str) -> list[dict[str, str, str]]:
# use SERP API
response = requests.post(
f"https://google.serper.dev/search",
Expand All @@ -152,14 148,19 @@ def search_results(search_query: str) -> list[tuple[str, str]]:
)
response.raise_for_status()
source_information = [
(result["link"], result["title"]) for result in response.json()["organic"]
{
"url": result.get("link", None),
"title": result.get("title", None),
"date": result.get("date", None),
}
for result in response.json().get("organic", [])
]
return source_information


async def find_new_info(target: str, source: tuple[str, str, str]) -> str:
source_metadata = f"{source[0]}, {source[1]}"
source_content = source[2]
async def find_new_info(target: str, source: dict[str, str, str]) -> str:
source_metadata = f"{source['url']}, {source['title']}, {source['date']}"
source_content = source["content"]

# Claude: info mentioned in source that is not mentioned in target
prompt = HumanAssistantPrompt(
Expand Down