Spaces:
Sleeping
Sleeping
Geevarghese George
commited on
Commit
·
b7499d1
1
Parent(s):
18fe8e3
async functions need prompt
Browse files
src/upgrade_advisor/agents/package.py
CHANGED
|
@@ -57,7 +57,7 @@ class PackageDiscoveryAgent:
|
|
| 57 |
self.agent = CodeAgent(
|
| 58 |
tools=tool_list,
|
| 59 |
model=model,
|
| 60 |
-
max_steps=
|
| 61 |
add_base_tools=True,
|
| 62 |
additional_authorized_imports=[
|
| 63 |
"json",
|
|
@@ -73,7 +73,8 @@ class PackageDiscoveryAgent:
|
|
| 73 |
"markdownify",
|
| 74 |
"sys",
|
| 75 |
"tomli",
|
| 76 |
-
"requests",
|
|
|
|
| 77 |
],
|
| 78 |
)
|
| 79 |
logger.info(
|
|
|
|
| 57 |
self.agent = CodeAgent(
|
| 58 |
tools=tool_list,
|
| 59 |
model=model,
|
| 60 |
+
max_steps=20,
|
| 61 |
add_base_tools=True,
|
| 62 |
additional_authorized_imports=[
|
| 63 |
"json",
|
|
|
|
| 73 |
"markdownify",
|
| 74 |
"sys",
|
| 75 |
"tomli",
|
| 76 |
+
# "requests",
|
| 77 |
+
"asyncio",
|
| 78 |
],
|
| 79 |
)
|
| 80 |
logger.info(
|
src/upgrade_advisor/agents/tools/pypi_api.py
CHANGED
|
@@ -31,11 +31,11 @@ async def pypi_search(
|
|
| 31 |
dict: Parsed package metadata or an error payload.
|
| 32 |
"""
|
| 33 |
REQUEST_URL = f"https://pypi.python.org/pypi/{package}/json"
|
|
|
|
| 34 |
response = requests.get(REQUEST_URL, timeout=10)
|
| 35 |
if response.ok:
|
| 36 |
result = parse_response_pypi_search(response.json(), cutoff=cutoff)
|
| 37 |
return result.model_dump()
|
| 38 |
-
|
| 39 |
e = HTTPError(str(response.status_code))
|
| 40 |
return ErrorResponseSchema(error=str(e)).model_dump()
|
| 41 |
|
|
|
|
| 31 |
dict: Parsed package metadata or an error payload.
|
| 32 |
"""
|
| 33 |
REQUEST_URL = f"https://pypi.python.org/pypi/{package}/json"
|
| 34 |
+
|
| 35 |
response = requests.get(REQUEST_URL, timeout=10)
|
| 36 |
if response.ok:
|
| 37 |
result = parse_response_pypi_search(response.json(), cutoff=cutoff)
|
| 38 |
return result.model_dump()
|
|
|
|
| 39 |
e = HTTPError(str(response.status_code))
|
| 40 |
return ErrorResponseSchema(error=str(e)).model_dump()
|
| 41 |
|
src/upgrade_advisor/agents/tools/tools.py
CHANGED
|
@@ -186,7 +186,9 @@ class PypiSearchTool(Tool):
|
|
| 186 |
name = "pypi_search"
|
| 187 |
description = """
|
| 188 |
Get metadata about a PyPI package by its name.
|
| 189 |
-
It returns a dictionary with the schema described in `output_schema`
|
|
|
|
|
|
|
| 190 |
"""
|
| 191 |
inputs = {
|
| 192 |
"package": {
|
|
@@ -204,8 +206,8 @@ class PypiSearchTool(Tool):
|
|
| 204 |
def __init__(self):
|
| 205 |
super().__init__()
|
| 206 |
|
| 207 |
-
def forward(self, package: str, cutoff: int) -> dict:
|
| 208 |
-
result = pypi_search(package, cutoff=cutoff)
|
| 209 |
return result
|
| 210 |
|
| 211 |
|
|
@@ -215,7 +217,9 @@ class PypiSearchVersionTool(Tool):
|
|
| 215 |
name = "pypi_search_version"
|
| 216 |
description = """
|
| 217 |
Get metadata about a specific version of a PyPI package.
|
| 218 |
-
It returns a dictionary with the schema described in `output_schema`
|
|
|
|
|
|
|
| 219 |
"""
|
| 220 |
inputs = {
|
| 221 |
"package": {
|
|
@@ -237,8 +241,8 @@ class PypiSearchVersionTool(Tool):
|
|
| 237 |
def __init__(self):
|
| 238 |
super().__init__()
|
| 239 |
|
| 240 |
-
def forward(self, package: str, version: str, cutoff: int) -> dict:
|
| 241 |
-
result = pypi_search_version(package, version, cutoff=cutoff)
|
| 242 |
return result
|
| 243 |
|
| 244 |
|
|
@@ -280,7 +284,9 @@ class RepoFromPyPITool(Tool):
|
|
| 280 |
PyPI.
|
| 281 |
Some projects may not have a GitHub repository listed in their PyPI
|
| 282 |
metadata.
|
| 283 |
-
It returns a dictionary with the schema described in `output_schema`
|
|
|
|
|
|
|
| 284 |
"""
|
| 285 |
inputs = {
|
| 286 |
"package": {
|
|
@@ -298,7 +304,7 @@ class RepoFromPyPITool(Tool):
|
|
| 298 |
def __init__(self):
|
| 299 |
super().__init__()
|
| 300 |
|
| 301 |
-
def forward(self, package: str, cutoff: int) -> dict:
|
| 302 |
-
result = github_repo_and_releases(package, cutoff=cutoff)
|
| 303 |
|
| 304 |
return result
|
|
|
|
| 186 |
name = "pypi_search"
|
| 187 |
description = """
|
| 188 |
Get metadata about a PyPI package by its name.
|
| 189 |
+
It returns a dictionary with the schema described in `output_schema`
|
| 190 |
+
attribute.
|
| 191 |
+
This is an async tool, so make sure to await its execution.
|
| 192 |
"""
|
| 193 |
inputs = {
|
| 194 |
"package": {
|
|
|
|
| 206 |
def __init__(self):
|
| 207 |
super().__init__()
|
| 208 |
|
| 209 |
+
async def forward(self, package: str, cutoff: int) -> dict:
|
| 210 |
+
result = await pypi_search(package, cutoff=cutoff)
|
| 211 |
return result
|
| 212 |
|
| 213 |
|
|
|
|
| 217 |
name = "pypi_search_version"
|
| 218 |
description = """
|
| 219 |
Get metadata about a specific version of a PyPI package.
|
| 220 |
+
It returns a dictionary with the schema described in `output_schema`
|
| 221 |
+
attribute.
|
| 222 |
+
This is an async tool, so make sure to await its execution.
|
| 223 |
"""
|
| 224 |
inputs = {
|
| 225 |
"package": {
|
|
|
|
| 241 |
def __init__(self):
|
| 242 |
super().__init__()
|
| 243 |
|
| 244 |
+
async def forward(self, package: str, version: str, cutoff: int) -> dict:
|
| 245 |
+
result = await pypi_search_version(package, version, cutoff=cutoff)
|
| 246 |
return result
|
| 247 |
|
| 248 |
|
|
|
|
| 284 |
PyPI.
|
| 285 |
Some projects may not have a GitHub repository listed in their PyPI
|
| 286 |
metadata.
|
| 287 |
+
It returns a dictionary with the schema described in `output_schema`
|
| 288 |
+
attribute.
|
| 289 |
+
This is an async tool, so make sure to await its execution.
|
| 290 |
"""
|
| 291 |
inputs = {
|
| 292 |
"package": {
|
|
|
|
| 304 |
def __init__(self):
|
| 305 |
super().__init__()
|
| 306 |
|
| 307 |
+
async def forward(self, package: str, cutoff: int) -> dict:
|
| 308 |
+
result = await github_repo_and_releases(package, cutoff=cutoff)
|
| 309 |
|
| 310 |
return result
|
src/upgrade_advisor/theme.py
CHANGED
|
@@ -40,14 +40,14 @@ class Christmas(Base):
|
|
| 40 |
)
|
| 41 |
super().set(
|
| 42 |
body_background_fill=(
|
| 43 |
-
"radial-gradient(
|
| 44 |
-
"radial-gradient(
|
| 45 |
-
"
|
| 46 |
),
|
| 47 |
body_background_fill_dark=(
|
| 48 |
-
"radial-gradient(
|
| 49 |
-
"radial-gradient(
|
| 50 |
-
"
|
| 51 |
),
|
| 52 |
background_fill_primary="rgba(255, 255, 255, 0.92)",
|
| 53 |
background_fill_primary_dark="rgba(12, 22, 17, 0.9)",
|
|
@@ -71,9 +71,9 @@ class Christmas(Base):
|
|
| 71 |
block_title_text_color_dark="*primary_100",
|
| 72 |
block_title_text_weight="700",
|
| 73 |
button_primary_background_fill="linear-gradient(120deg, *primary_500, #f59e0b 80%)",
|
| 74 |
-
button_primary_background_fill_hover="linear-gradient(120deg,
|
| 75 |
button_primary_background_fill_dark="linear-gradient(120deg, *primary_600, #d97706 80%)",
|
| 76 |
-
button_primary_background_fill_hover_dark="linear-gradient(120deg,
|
| 77 |
button_primary_text_color="white",
|
| 78 |
button_primary_text_color_dark="white",
|
| 79 |
button_primary_shadow="0 10px 40px rgba(0, 0, 0, 0.25)",
|
|
|
|
| 40 |
)
|
| 41 |
super().set(
|
| 42 |
body_background_fill=(
|
| 43 |
+
"radial-gradient(rgba(255, 255, 255, 0.6) 2px, transparent 2px) 0 0/26px 26px, "
|
| 44 |
+
"radial-gradient(rgba(239, 68, 68, 0.55) 2px, transparent 2px) 13px 13px/26px 26px, "
|
| 45 |
+
"rgba(15, 42, 29, 0.92)"
|
| 46 |
),
|
| 47 |
body_background_fill_dark=(
|
| 48 |
+
"radial-gradient(rgba(243, 244, 246, 0.52) 2px, transparent 2px) 0 0/26px 26px, "
|
| 49 |
+
"radial-gradient(rgba(248, 113, 113, 0.48) 2px, transparent 2px) 13px 13px/26px 26px, "
|
| 50 |
+
"rgba(5, 20, 13, 0.94)"
|
| 51 |
),
|
| 52 |
background_fill_primary="rgba(255, 255, 255, 0.92)",
|
| 53 |
background_fill_primary_dark="rgba(12, 22, 17, 0.9)",
|
|
|
|
| 71 |
block_title_text_color_dark="*primary_100",
|
| 72 |
block_title_text_weight="700",
|
| 73 |
button_primary_background_fill="linear-gradient(120deg, *primary_500, #f59e0b 80%)",
|
| 74 |
+
button_primary_background_fill_hover="linear-gradient(120deg, #34d399, #bbf7d0 80%)",
|
| 75 |
button_primary_background_fill_dark="linear-gradient(120deg, *primary_600, #d97706 80%)",
|
| 76 |
+
button_primary_background_fill_hover_dark="linear-gradient(120deg, #10b981, #34d399 80%)",
|
| 77 |
button_primary_text_color="white",
|
| 78 |
button_primary_text_color_dark="white",
|
| 79 |
button_primary_shadow="0 10px 40px rgba(0, 0, 0, 0.25)",
|