Skip to content

Commit

Permalink
v2.4.18
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Jun 1, 2024
1 parent e1dd00a commit 79f1f85
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 18 deletions.
6 changes: 4 additions & 2 deletions cookbook/tools/exa_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from phi.assistant import Assistant
from phi.tools.exa import ExaTools

os.environ['EXA_API_KEY'] = 'your api key'
os.environ["EXA_API_KEY"] = "your api key"

assistant = Assistant(tools=[ExaTools(include_domains=['cnbc.com', 'reuters.com', 'bloomberg.com'])], show_tool_calls=True)
assistant = Assistant(
tools=[ExaTools(include_domains=["cnbc.com", "reuters.com", "bloomberg.com"])], show_tool_calls=True
)
assistant.print_response("Search for AAPL news", debug_mode=True, markdown=True)
7 changes: 4 additions & 3 deletions phi/storage/assistant/sqllite.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,19 @@ def upsert(self, row: AssistantRun) -> Optional[AssistantRun]:
sess.commit() # Make sure to commit the changes to the database
return self.read(run_id=row.run_id)
except OperationalError as oe:
logger.error(f"OperationalError occurred: {oe}")
logger.debug(f"OperationalError occurred: {oe}")
self.create() # This will only create the table if it doesn't exist
try:
sess.execute(stmt)
sess.commit()
return self.read(run_id=row.run_id)
except Exception as e:
logger.error(f"Error during upsert: {e}")
logger.warning(f"Error during upsert: {e}")
sess.rollback() # Rollback the session in case of any error
except Exception as e:
logger.error(f"Error during upsert: {e}")
logger.warning(f"Error during upsert: {e}")
sess.rollback()
return None

def delete(self) -> None:
if self.table_exists():
Expand Down
12 changes: 2 additions & 10 deletions phi/tools/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@


class PostgresTools(Toolkit):
"""A basic tool to connect to a PostgreSQL database and perform read-only operations on it.
"""
"""A basic tool to connect to a PostgreSQL database and perform read-only operations on it."""

def __init__(
self,
connection: Optional[psycopg2.extensions.connection] = None,
Expand All @@ -33,7 +33,6 @@ def __init__(
self.host: Optional[str] = host
self.port: Optional[int] = port


self.register(self.show_tables)
self.register(self.describe_table)
if inspect_queries:
Expand All @@ -45,7 +44,6 @@ def __init__(
if export_tables:
self.register(self.export_table_to_path)


@property
def connection(self) -> psycopg2.extensions.connection:
"""
Expand All @@ -71,7 +69,6 @@ def connection(self) -> psycopg2.extensions.connection:

return self._connection


def show_tables(self) -> str:
"""Function to show tables in the database
Expand All @@ -82,7 +79,6 @@ def show_tables(self) -> str:
logger.debug(f"Tables: {tables}")
return tables


def describe_table(self, table: str) -> str:
"""Function to describe a table
Expand All @@ -95,7 +91,6 @@ def describe_table(self, table: str) -> str:
logger.debug(f"Table description: {table_description}")
return f"{table}\n{table_description}"


def summarize_table(self, table: str, table_schema: Optional[str] = "public") -> str:
"""Function to compute a number of aggregates over a table.
The function launches a query that computes a number of aggregates over all columns,
Expand Down Expand Up @@ -165,7 +160,6 @@ def summarize_table(self, table: str, table_schema: Optional[str] = "public") ->
logger.debug(f"Table summary: {table_summary}")
return table_summary


def inspect_query(self, query: str) -> str:
"""Function to inspect a query and return the query plan. Always inspect your query before running them.
Expand All @@ -178,7 +172,6 @@ def inspect_query(self, query: str) -> str:
logger.debug(f"Explain plan: {explain_plan}")
return explain_plan


def export_table_to_path(self, table: str, path: Optional[str] = None) -> str:
"""Save a table in CSV format.
If the path is provided, the table will be saved under that path.
Expand All @@ -202,7 +195,6 @@ def export_table_to_path(self, table: str, path: Optional[str] = None) -> str:

return result


def run_query(self, query: str) -> str:
"""Function that runs a query and returns the result.
Expand Down
3 changes: 1 addition & 2 deletions phi/vectordb/qdrant/qdrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
from qdrant_client.http import models
except ImportError:
raise ImportError(
"The `qdrant-client` package is not installed. "
"Please install it via `pip install qdrant-client`."
"The `qdrant-client` package is not installed. " "Please install it via `pip install qdrant-client`."
)

from phi.document import Document
Expand Down
1 change: 1 addition & 0 deletions phi/workspace/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ class WorkspaceStarterTemplate(str, Enum):
ai_api = "ai-api"
django_app = "django-app"
streamlit_app = "streamlit-app"
llm_os = "llm-os"
agentic_rag = "personalized-agentic-rag"
2 changes: 2 additions & 0 deletions phi/workspace/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
WorkspaceStarterTemplate.ai_api: "ai-api",
WorkspaceStarterTemplate.django_app: "django-app",
WorkspaceStarterTemplate.streamlit_app: "streamlit-app",
WorkspaceStarterTemplate.llm_os: "llm-os",
WorkspaceStarterTemplate.agentic_rag: "agentic-rag",
}
TEMPLATE_TO_REPO_MAP: Dict[WorkspaceStarterTemplate, str] = {
WorkspaceStarterTemplate.ai_app: "https://github.com/phidatahq/ai-app.git",
WorkspaceStarterTemplate.ai_api: "https://github.com/phidatahq/ai-api.git",
WorkspaceStarterTemplate.django_app: "https://github.com/phidatahq/django-app.git",
WorkspaceStarterTemplate.streamlit_app: "https://github.com/phidatahq/streamlit-app.git",
WorkspaceStarterTemplate.llm_os: "https://github.com/phidatahq/llm-os.git",
WorkspaceStarterTemplate.agentic_rag: "https://github.com/phidatahq/personalized-agentic-rag.git",
}

Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "phidata"
version = "2.4.17"
version = "2.4.18"
description = "Memory, knowledge and tools for LLMs."
requires-python = ">=3.7"
readme = "README.md"
Expand Down Expand Up @@ -108,6 +108,7 @@ module = [
"pyarrow.*",
"pgvector.*",
"psycopg.*",
"psycopg2.*",
"pypdf.*",
"qdrant_client.*",
"rapidocr_onnxruntime.*",
Expand Down

0 comments on commit 79f1f85

Please sign in to comment.