Skip to content

Commit

Permalink
Merge branch 'main' into feat/llm-agent-limit-tool-call-depth
Browse files Browse the repository at this point in the history
  • Loading branch information
elisalimli committed May 1, 2024
2 parents acf1ce3 + 3ae1001 commit da9ed78
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 116 deletions.
226 changes: 140 additions & 86 deletions libs/superagent/app/agents/llm.py

Large diffs are not rendered by default.

11 changes: 0 additions & 11 deletions libs/superagent/app/agents/test.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def add_datasource(self, assistant: dict, data: dict):
data["index_name"] = await self._get_unique_index_name(data, assistant)

await self._add_superrag_tool(assistant, data)
self.superrag_service.ingest(data=data)
await self.superrag_service.aingest(data=data)

async def delete_datasource(self, assistant: dict, datasource: dict):
tool = await self.agent_manager.get_tool(
Expand All @@ -156,7 +156,7 @@ async def delete_datasource(self, assistant: dict, datasource: dict):
tool_metadata = json.loads(tool.metadata)

await self._delete_tool(assistant, datasource)
self.superrag_service.delete(
await self.superrag_service.adelete(
{
**datasource,
"index_name": tool_metadata.get("index_name"),
Expand Down
2 changes: 1 addition & 1 deletion libs/superagent/app/tools/superrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ async def _arun(

credentials = get_superrag_compatible_credentials(provider.options)

res = self.superrag_service.query(
res = await self.superrag_service.aquery(
{
"vector_database": {"type": database_provider, "config": credentials},
"index_name": index_name,
Expand Down
3 changes: 3 additions & 0 deletions libs/superagent/lint-and-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
# getting changed files (only staged)
changes=$(git diff --name-only --cached | grep '^libs/superagent.*\.py$' | sed 's|^libs/superagent/||')

# Filter deleted files
changes=$(echo "$changes" | while read -r file; do [ -e "$file" ] && echo "$file"; done)
lint() {
poetry run black $changes
# sort imports
Expand Down
8 changes: 4 additions & 4 deletions libs/superagent/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion libs/superagent/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ openai = "^1.1.1"
langchain-experimental = "^0.0.37"
pydub = "^0.25.1"
algoliasearch = "^3.0.0"
litellm = "1.35.21"
litellm = "1.35.33"
weaviate-client = "^3.25.3"
qdrant-client = "^1.6.9"
vecs = "^0.4.2"
Expand Down
26 changes: 15 additions & 11 deletions libs/superagent/services/superrag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Optional
from urllib.parse import unquote, urlparse

import requests
from aiohttp import ClientSession
from decouple import config
from pydantic import BaseModel

Expand Down Expand Up @@ -42,10 +42,10 @@ def suffix(self) -> str:

class File(BaseModel):
url: str
name: str | None = None
name: Optional[str] = None

@property
def type(self) -> FileType | None:
def type(self) -> Optional[FileType]:
url = self.url
if url:
parsed_url = urlparse(url)
Expand Down Expand Up @@ -79,25 +79,29 @@ def __init__(self, url: Optional[str] = None):
if not self.url:
raise ValueError("SUPERRAG_API_URL is not set")

def _request(self, method, endpoint, data):
return requests.request(method, f"{self.url}/{endpoint}", json=data).json()
async def _arequest(self, method, endpoint, data):
async with ClientSession() as session:
async with session.request(
method, f"{self.url}/{endpoint}", json=data
) as response:
return await response.json()

def ingest(self, data):
return self._request(
async def aingest(self, data):
return await self._arequest(
"POST",
"ingest",
data,
)

def delete(self, data):
return self._request(
async def adelete(self, data):
return await self._arequest(
"DELETE",
"delete",
data,
)

def query(self, data):
return self._request(
async def aquery(self, data):
return await self._arequest(
"POST",
"query",
data,
Expand Down

0 comments on commit da9ed78

Please sign in to comment.