Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/reworkd/AgentGPT
Browse files Browse the repository at this point in the history
  • Loading branch information
asim-shrestha committed Nov 1, 2023
2 parents 9deadf9 + 64cb796 commit b8b8994
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
4 changes: 2 additions & 2 deletions next/src/components/dialog/ToolsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const SidTool = ({ tool, onChange }: ToolProps) => {
<div className="flex flex-grow flex-col gap-1">
<p className="font-bold capitalize">{tool.name}</p>
<p className="text-xs sm:text-sm">{tool.description}</p>
</div>
{sid.connected && (
<>
<Button onClick={sid.manage}>Manage</Button>
Expand All @@ -98,8 +97,9 @@ const SidTool = ({ tool, onChange }: ToolProps) => {
>
Disconnect
</Button>
</>
</>
)}
</div>
<Switch
value={!sid?.connected ?? false ? false : tool.active}
onChange={() => onChange(tool.name, !tool.active)}
Expand Down
36 changes: 26 additions & 10 deletions platform/reworkd_platform/web/api/agent/tools/sidsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from reworkd_platform.web.api.agent.tools.tool import Tool
from reworkd_platform.web.api.agent.tools.utils import Snippet, summarize_sid

from reworkd_platform.web.api.agent.tools.search import Search


async def _sid_search_results(
search_term: str, limit: int, token: str
Expand Down Expand Up @@ -90,27 +92,25 @@ async def dynamic_available(user: UserBase, oauth_crud: OAuthCrud) -> bool:

return bool(installation and installation.access_token_enc)

async def call(
async def _run_sid(
self,
goal: str,
task: str,
input_str: str,
user: UserBase,
oauth_crud: OAuthCrud,
*args: Any,
**kwargs: Any,
) -> FastAPIStreamingResponse:
) -> Optional[FastAPIStreamingResponse]:
installation = await oauth_crud.get_installation_by_user_id(
user_id=user.id, provider="sid"
)
# if the tool is called, the installation should be available. However, it is possible that it is
# disconnected in the meantime. In that case, we pretend as if no information is found.
if not installation:
return stream_string("Unable to fetch SID results", True)
logger.warning("No sid installation found for user {user.id}")
return None

token = await get_access_token(oauth_crud, installation)
if not token:
return stream_string("Unable to fetch SID results", True)
logger.warning("Unable to fetch sid access token for {user.id}")
return None

try:
res = await _sid_search_results(input_str, limit=10, token=token)
Expand All @@ -119,9 +119,25 @@ async def call(
]
except Exception as e:
logger.exception(e)
return stream_string("Unable to fetch SID results", True)
return None

if not snippets:
return stream_string("No good results found by SID", True)
return None

return summarize_sid(self.model, self.language, goal, task, snippets)


async def call(
self,
goal: str,
task: str,
input_str: str,
user: UserBase,
oauth_crud: OAuthCrud,
*args: Any,
**kwargs: Any,
) -> FastAPIStreamingResponse:
# fall back to search if no results are found
return await self._run_sid(goal, task, input_str, user, oauth_crud) or await Search(self.model, self.language).call(
goal, task, input_str, user, oauth_crud
)

0 comments on commit b8b8994

Please sign in to comment.