Skip to content

Commit

Permalink
fix lint issues (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofermend authored Dec 2, 2024
1 parent 3fde448 commit dfbeba1
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ disable =
too-many-return-statements,
import-outside-toplevel,
eval-used,
too-few-public-methods
too-few-public-methods,
unused-argument

32 changes: 32 additions & 0 deletions vectara_agentic/_callback.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Module to handle agent callbacks
"""

import inspect
from typing import Any, Dict, Optional, List, Callable

Expand Down Expand Up @@ -55,6 +59,18 @@ def on_event_end(
event_id: str = "",
**kwargs: Any,
) -> None:
"""
Handle the end of an event
Args:
event_type: the type of event
payload: the event payload
event_id: the event ID
kwargs: additional keyword arguments
Returns:
None
"""
if self.fn is not None and payload is not None:
if inspect.iscoroutinefunction(self.fn):
raise ValueError("Synchronous callback handler cannot use async callback function")
Expand All @@ -70,6 +86,19 @@ async def aon_event_start(
parent_id: str = "",
**kwargs: Any,
) -> str:
"""
Handle the start of an event
Args:
event_type: the type of event
payload: the event payload
event_id: the event ID
parent_id: the parent event ID
kwargs: additional keyword arguments
Returns:
event_id: the event ID
"""
if self.fn is not None and payload is not None:
await self._ahandle_event(event_type, payload)
return event_id
Expand All @@ -81,6 +110,9 @@ async def aon_event_end(
event_id: str = "",
**kwargs: Any,
) -> None:
"""
Handle the end of an event (async)
"""
if self.fn is not None and payload is not None:
await self._ahandle_event(event_type, payload)

Expand Down
5 changes: 4 additions & 1 deletion vectara_agentic/db_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ def __call__(self, query: str) -> Any:
count_rows = self.load_data_fn(count_query)
num_rows = int(count_rows[0].text)
if num_rows > self.max_rows:
return [f"The query is expected to return more than {self.max_rows} rows. Please refine your query to make it return less rows."]
return [
f"The query is expected to return more than {self.max_rows} rows. "
"Please refine your query to make it return less rows."
]

res = self.load_data_fn(query)
return [d.text for d in res]
Expand Down
4 changes: 2 additions & 2 deletions vectara_agentic/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ def database_tools(
password (str, optional): The database password. Defaults to "Password".
dbname (str, optional): The database name. Defaults to "postgres".
You must specify either the sql_database object or the scheme, host, port, user, password, and dbname.
max_rows (int, optional): if specified, instructs the load_data tool to never return more than max_rows rows.
Defaults to 500.
max_rows (int, optional): if specified, instructs the load_data tool to never return more than max_rows
rows. Defaults to 500.
Returns:
List[VectaraTool]: A list of VectaraTool objects.
Expand Down

0 comments on commit dfbeba1

Please sign in to comment.