Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v2.0.36
Browse files Browse the repository at this point in the history
ashpreetbedi committed Nov 10, 2023
1 parent b01a803 commit 6e04990
Showing 10 changed files with 2 additions and 769 deletions.
53 changes: 0 additions & 53 deletions phi/llm/agent/arxiv.py

This file was deleted.

27 changes: 0 additions & 27 deletions phi/llm/agent/base.py

This file was deleted.

339 changes: 0 additions & 339 deletions phi/llm/agent/duckdb.py

This file was deleted.

59 changes: 0 additions & 59 deletions phi/llm/agent/email.py

This file was deleted.

18 changes: 0 additions & 18 deletions phi/llm/agent/google.py

This file was deleted.

116 changes: 0 additions & 116 deletions phi/llm/agent/phi.py

This file was deleted.

19 changes: 0 additions & 19 deletions phi/llm/agent/pubmed.py

This file was deleted.

34 changes: 0 additions & 34 deletions phi/llm/agent/shell.py

This file was deleted.

52 changes: 2 additions & 50 deletions phi/llm/agent/website.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,2 @@
import json
from typing import List, Optional

from phi.document import Document
from phi.knowledge.website import WebsiteKnowledgeBase
from phi.llm.agent.base import BaseAgent
from phi.utils.log import logger


class WebsiteAgent(BaseAgent):
def __init__(self, knowledge_base: Optional[WebsiteKnowledgeBase] = None):
super().__init__(name="website_agent")
self.knowledge_base: Optional[WebsiteKnowledgeBase] = knowledge_base

if self.knowledge_base is not None and isinstance(self.knowledge_base, WebsiteKnowledgeBase):
self.register(self.add_website_to_knowledge_base)
else:
self.register(self.read_website)

def add_website_to_knowledge_base(self, url: str) -> str:
"""This function adds a websites content to the knowledge base.
NOTE: The website must start with https:// and should be a valid website.
USE THIS FUNCTION TO GET INFORMATION ABOUT PRODUCTS FROM THE INTERNET.
:param url: The url of the website to add.
:return: 'Success' if the website was added to the knowledge base.
"""
if self.knowledge_base is None:
return "Knowledge base not provided"

logger.debug(f"Adding to knowledge base: {url}")
self.knowledge_base.urls.append(url)
logger.debug("Loading knowledge base.")
self.knowledge_base.load(recreate=False)
return "Success"

def read_website(self, url: str) -> str:
"""This function reads a website and returns the content.
:param url: The url of the website to read.
:return: Relevant documents from the website.
"""
from phi.document.reader.website import WebsiteReader

website = WebsiteReader()

logger.debug(f"Reading website: {url}")
relevant_docs: List[Document] = website.read(url=url)
return json.dumps([doc.to_dict() for doc in relevant_docs])
# DEPRECATED: Use phi.agent.website instead
from phi.agent.website import WebsiteAgent, WebsiteKnowledgeBase # noqa: F401
54 changes: 0 additions & 54 deletions phi/llm/agent/wikipedia.py

This file was deleted.

0 comments on commit 6e04990

Please sign in to comment.