Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
v2.3.19
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Feb 5, 2024
1 parent 113d43c commit 5980faf
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 57 deletions.
10 changes: 5 additions & 5 deletions ai/knowledge_base.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from phi.knowledge.combined import CombinedKnowledgeBase
from phi.knowledge.pdf import PDFUrlKnowledgeBase, PDFKnowledgeBase
from phi.knowledge.website import WebsiteKnowledgeBase
from phi.vectordb.pgvector import PgVector
from phi.vectordb.pgvector import PgVector2

from db.session import db_url

url_pdf_knowledge_base = PDFUrlKnowledgeBase(
urls=["https://www.family-action.org.uk/content/uploads/2019/07/meals-more-recipes.pdf"],
# Store this knowledge base in ai.url_pdf_documents
vector_db=PgVector(
vector_db=PgVector2(
schema="ai",
db_url=db_url,
collection="url_pdf_documents",
Expand All @@ -20,7 +20,7 @@
local_pdf_knowledge_base = PDFKnowledgeBase(
path="data/pdfs",
# Store this knowledge base in ai.local_pdf_documents
vector_db=PgVector(
vector_db=PgVector2(
schema="ai",
db_url=db_url,
collection="local_pdf_documents",
Expand All @@ -35,7 +35,7 @@
local_pdf_knowledge_base,
],
# Store this knowledge base in ai.pdf_documents
vector_db=PgVector(
vector_db=PgVector2(
schema="ai",
db_url=db_url,
collection="pdf_documents",
Expand All @@ -49,7 +49,7 @@
# Number of links to follow from the seed URLs
max_links=15,
# Store this knowledge base in ai.website_documents
vector_db=PgVector(
vector_db=PgVector2(
schema="ai",
db_url=db_url,
collection="website_documents",
Expand Down
14 changes: 11 additions & 3 deletions app/pages/1_PDF_Assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
from ai.assistants.pdf_rag import get_rag_pdf_assistant
from utils.log import logger


st.title(":snowman: PDF Assistant")
st.markdown('<a href="https://github.com/phidatahq/phidata"><h4>by phidata</h4></a>', unsafe_allow_html=True)
st.set_page_config(
page_title="PDF AI",
page_icon=":orange_heart:",
)
st.title("PDF Assistant")
st.markdown("##### :orange_heart: built using [phidata](https://github.com/phidatahq/phidata)")
with st.expander(":rainbow[:point_down: Example Questions]"):
st.markdown("- How do I make chicken tikka salad?")
st.markdown("- How do I make chicken curry?")
Expand Down Expand Up @@ -135,6 +138,11 @@ def main() -> None:
st.session_state["pdf_knowledge_base_loaded"] = True
st.sidebar.success("Knowledge base recreated")

if st.sidebar.button("Clear Knowledge Base", disabled=True):
pdf_assistant.knowledge_base.vector_db.clear()
st.session_state["pdf_knowledge_base_loaded"] = False
st.sidebar.success("Knowledge base cleared")

if st.sidebar.button("Auto Rename"):
pdf_assistant.auto_rename_run()

Expand Down
9 changes: 6 additions & 3 deletions app/pages/2_Image_Assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@
from ai.assistants.image import get_image_assistant
from utils.log import logger


st.title(":snowman: Image Assistant")
st.markdown('<a href="https://github.com/phidatahq/phidata"><h4>by phidata</h4></a>', unsafe_allow_html=True)
st.set_page_config(
page_title="Image AI",
page_icon=":orange_heart:",
)
st.title("Image Assistant")
st.markdown("##### :orange_heart: built using [phidata](https://github.com/phidatahq/phidata)")


def encode_image(image_file):
Expand Down
18 changes: 13 additions & 5 deletions app/pages/3_Website_Assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
from ai.assistants.website_rag import get_rag_website_assistant
from utils.log import logger


st.title(":snowman: Website Assistant")
st.markdown('<a href="https://github.com/phidatahq/phidata"><h4>by phidata</h4></a>', unsafe_allow_html=True)
st.set_page_config(
page_title="Website AI",
page_icon=":orange_heart:",
)
st.title("Website Assistant")
st.markdown("##### :orange_heart: built using [phidata](https://github.com/phidatahq/phidata)")
with st.expander(":rainbow[:point_down: Example Questions]"):
st.markdown("- What is phidata?")
st.markdown("- How do I build an AI App?")
Expand Down Expand Up @@ -121,16 +124,21 @@ def main() -> None:
restart_assistant()

if website_assistant.knowledge_base:
if st.sidebar.button("Update Knowledge Base"):
if st.sidebar.button("Update Knowledge Base", disabled=True):
website_assistant.knowledge_base.load(recreate=False)
st.session_state["knowledge_base_exists"] = True
st.sidebar.success("Knowledge base updated")

if st.sidebar.button("Recreate Knowledge Base"):
if st.sidebar.button("Recreate Knowledge Base", disabled=True):
website_assistant.knowledge_base.load(recreate=True)
st.session_state["knowledge_base_exists"] = True
st.sidebar.success("Knowledge base recreated")

if st.sidebar.button("Clear Knowledge Base", disabled=True):
website_assistant.knowledge_base.vector_db.clear()
st.session_state["pdf_knowledge_base_loaded"] = False
st.sidebar.success("Knowledge base cleared")

if st.sidebar.button("Auto Rename"):
website_assistant.auto_rename_run()

Expand Down
14 changes: 11 additions & 3 deletions arxiv_ai/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@
st.markdown("- Search the web for gaia")
st.markdown("Notes:")
st.markdown("- To Ask questions from a specific paper: Select a paper from the sidebar")
st.markdown("- By default it searches its knowledge base first.\nToggle force search to search arXiv for a specific topic")
st.markdown("- Message us on [discord](https://discord.com/invite/4MtYHHrgA8) for any issues or feature requests")
st.markdown(
"- By default it searches its knowledge base first.\nToggle force search to search arXiv for a specific topic"
)
st.markdown(
"- Message us on [discord](https://discord.com/invite/4MtYHHrgA8) for any issues or feature requests"
)


def restart_assistant():
Expand All @@ -53,7 +57,11 @@ def main() -> None:
st.markdown("#### :technologist: Enter a username and ask me about arXiv")
return

force_search_arxiv = st.sidebar.toggle(label='Force search arXiv', value=False, help="Turn on to search arXiv for a specific topic instead of the knowledge base")
force_search_arxiv = st.sidebar.toggle(
label="Force search arXiv",
value=False,
help="Turn on to search arXiv for a specific topic instead of the knowledge base",
)

# Get the assistant
arxiv_assistant: Assistant
Expand Down
2 changes: 1 addition & 1 deletion arxiv_ai/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
arxiv_assistant_storage = PgAssistantStorage(
schema="ai",
db_url=db_url,
table_name="pdf_assistant",
table_name="arxiv_assistant",
)
4 changes: 2 additions & 2 deletions demos/sales_analysis/sales_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from phi.knowledge.json import JSONKnowledgeBase
from phi.knowledge.text import TextKnowledgeBase
from phi.knowledge.combined import CombinedKnowledgeBase
from phi.vectordb.pgvector import PgVector
from phi.vectordb.pgvector import PgVector2
from phi.storage.assistant.postgres import PgAssistantStorage

from db.session import db_url
Expand All @@ -17,7 +17,7 @@
JSONKnowledgeBase(path=sales_knowledge_dir),
],
# Store the knowledge in `ai.sales_knowledge`
vector_db=PgVector(collection="sales_knowledge", db_url=db_url),
vector_db=PgVector2(collection="sales_knowledge", db_url=db_url),
)
sales_ai_knowledge_base.load(recreate=False)

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
# Linting and Formatting
"ruff",
# phidata
"phidata==2.3.12",
"phidata==2.3.19",
]

[build-system]
Expand All @@ -63,7 +63,7 @@ build-backend = "setuptools.build_meta"
line-length = 110
extend-include = ["*.ipynb"]
exclude = ["aienv*", ".venv*"]
[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
# Ignore `F401` (import violations) in all `__init__.py` files
"__init__.py" = ["F401"]
"*.ipynb" = ["E402"]
Expand Down
4 changes: 2 additions & 2 deletions recipe/assistant_with_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from phi.assistant import Assistant
from phi.storage.assistant.postgres import PgAssistantStorage
from phi.knowledge.pdf import PDFUrlKnowledgeBase
from phi.vectordb.pgvector import PgVector
from phi.vectordb.pgvector import PgVector2

from db.session import db_url

knowledge_base = PDFUrlKnowledgeBase(
urls=["https://www.family-action.org.uk/content/uploads/2019/07/meals-more-recipes.pdf"],
vector_db=PgVector(collection="recipes", db_url=db_url),
vector_db=PgVector2(collection="recipes", db_url=db_url),
)

storage = PgAssistantStorage(table_name="recipe_assistant", db_url=db_url)
Expand Down
4 changes: 2 additions & 2 deletions recipe/auto_assistant.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from phi.assistant import Assistant
from phi.knowledge.pdf import PDFUrlKnowledgeBase
from phi.vectordb.pgvector import PgVector
from phi.vectordb.pgvector import PgVector2

from db.session import db_url

knowledge_base = PDFUrlKnowledgeBase(
urls=["https://www.family-action.org.uk/content/uploads/2019/07/meals-more-recipes.pdf"],
vector_db=PgVector(collection="recipes", db_url=db_url),
vector_db=PgVector2(collection="recipes", db_url=db_url),
)
knowledge_base.load(recreate=False)

Expand Down
4 changes: 2 additions & 2 deletions recipe/rag_assistant.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from phi.assistant import Assistant
from phi.knowledge.pdf import PDFUrlKnowledgeBase
from phi.vectordb.pgvector import PgVector
from phi.vectordb.pgvector import PgVector2

from db.session import db_url

knowledge_base = PDFUrlKnowledgeBase(
urls=["https://www.family-action.org.uk/content/uploads/2019/07/meals-more-recipes.pdf"],
vector_db=PgVector(collection="recipes", db_url=db_url),
vector_db=PgVector2(collection="recipes", db_url=db_url),
)
knowledge_base.load(recreate=False)

Expand Down
40 changes: 20 additions & 20 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# ./scripts/upgrade.sh all
#
aiohttp==3.9.2
aiohttp==3.9.3
aiosignal==1.3.1
alembic==1.13.1
altair==5.2.0
Expand All @@ -14,18 +14,18 @@ arxiv==2.1.0
attrs==23.2.0
beautifulsoup4==4.12.3
blinker==1.7.0
boto3==1.34.29
botocore==1.34.29
boto3==1.34.34
botocore==1.34.34
cachetools==5.3.2
certifi==2023.11.17
certifi==2024.2.2
charset-normalizer==3.3.2
click==8.1.7
contourpy==1.2.0
cycler==0.12.1
distro==1.9.0
docker==7.0.0
duckdb==0.9.2
fastapi==0.109.0
fastapi==0.109.2
feedparser==6.0.10
fonttools==4.47.2
frozenlist==1.4.1
Expand All @@ -42,31 +42,31 @@ jmespath==1.0.1
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
kiwisolver==1.4.5
mako==1.3.0
mako==1.3.2
markdown-it-py==3.0.0
markupsafe==2.1.4
markupsafe==2.1.5
matplotlib==3.8.2
mdurl==0.1.2
multidict==6.0.4
multidict==6.0.5
mypy==1.8.0
mypy-extensions==1.0.0
numpy==1.26.3
openai==1.10.0
openai==1.11.1
packaging==23.2
pandas==2.2.0
pandas-stubs==2.1.4.231227
pgvector==0.2.4
phidata==2.3.12
phidata==2.3.19
pillow==10.2.0
plotly==5.18.0
pluggy==1.4.0
polars==0.20.6
polars==0.20.7
protobuf==4.25.2
psycopg[binary]==3.1.17
psycopg-binary==3.1.17
psycopg[binary]==3.1.18
psycopg-binary==3.1.18
pyarrow==15.0.0
pydantic==2.3.0
pydantic-core==2.6.3
pydantic==2.6.0
pydantic-core==2.16.1
pydantic-settings==2.1.0
pydeck==0.8.1b0
pygments==2.17.2
Expand All @@ -75,14 +75,14 @@ pypdf==4.0.1
pytest==8.0.0
python-dateutil==2.8.2
python-dotenv==1.0.1
pytz==2023.4
pytz==2024.1
pyyaml==6.0.1
referencing==0.33.0
regex==2023.12.25
requests==2.31.0
rich==13.7.0
rpds-py==0.17.1
ruff==0.1.14
ruff==0.2.0
s3transfer==0.10.0
scipy==1.12.0
seaborn==0.13.2
Expand All @@ -92,8 +92,8 @@ smmap==5.0.1
sniffio==1.3.0
soupsieve==2.5
sqlalchemy==2.0.25
starlette==0.35.1
streamlit==1.30.0
starlette==0.36.3
streamlit==1.31.0
tavily-python==0.3.1
tenacity==8.2.3
tiktoken==0.5.2
Expand All @@ -106,7 +106,7 @@ typer==0.9.0
types-beautifulsoup4==4.12.0.20240106
types-html5lib==1.1.11.20240106
types-pillow==10.2.0.20240125
types-pytz==2023.3.1.1
types-pytz==2024.1.0.20240203
types-requests==2.31.0.20240125
typing-extensions==4.9.0
tzdata==2023.4
Expand Down
14 changes: 7 additions & 7 deletions workspace/prd_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,11 @@
group="pdf",
image=prd_image,
command="streamlit run pdf_ai/app.py",
# streamlit_server_max_upload_size=10,
streamlit_server_max_upload_size=10,
port_number=8501,
ecs_task_cpu="2048",
ecs_task_memory="4096",
ecs_service_count=2,
ecs_task_cpu="4096",
ecs_task_memory="8192",
ecs_service_count=3,
ecs_cluster=prd_ecs_cluster,
aws_secrets=[prd_secret],
subnets=ws_settings.subnet_ids,
Expand Down Expand Up @@ -287,9 +287,9 @@
image=prd_image,
command="streamlit run arxiv_ai/app.py",
port_number=8501,
ecs_task_cpu="4096",
ecs_task_memory="8192",
ecs_service_count=5,
ecs_task_cpu="2048",
ecs_task_memory="4096",
ecs_service_count=3,
ecs_cluster=prd_ecs_cluster,
aws_secrets=[prd_secret],
subnets=ws_settings.subnet_ids,
Expand Down

0 comments on commit 5980faf

Please sign in to comment.