Spaces:
Sleeping
Sleeping
Update primitives/tools.py
Browse files- primitives/tools.py +4 -4
primitives/tools.py
CHANGED
|
@@ -63,7 +63,7 @@ TYPE_MAPPING = {
|
|
| 63 |
# Available tools
|
| 64 |
# -----------------
|
| 65 |
|
| 66 |
-
async def cricket_source(mode: Literal["live", "upcoming"], want: Literal["
|
| 67 |
"""Fetches whole html from source extracts html container that contains necessary details
|
| 68 |
|
| 69 |
Args:
|
|
@@ -97,7 +97,7 @@ async def cricket_source(mode: Literal["live", "upcoming"], want: Literal["text"
|
|
| 97 |
if mode in ['live', 'upcoming'] and want == "text":
|
| 98 |
text = container.get_text(separator=" ", strip= True)
|
| 99 |
return json.dumps({f"{mode} details": str(text)})
|
| 100 |
-
elif mode == 'live' and want == '
|
| 101 |
hrefs_list = container.find_all("a", class_ = "cb-text-link cb-mtch-lnks")
|
| 102 |
hrefs_string = ",".join(str(tag) for tag in herfs_list)
|
| 103 |
return json.dumps({"hrefs_strings": herfs_string})
|
|
@@ -120,7 +120,7 @@ async def fetch_cricket_details(mode: Literal["live", "upcoming"])-> str:
|
|
| 120 |
|
| 121 |
async def live_cricket_scorecard_href()-> str:
|
| 122 |
"""String of comma separated anchor tags with herf attributes that pointing to live cricket scorecards """
|
| 123 |
-
response = await cricket_source('live', '
|
| 124 |
return response
|
| 125 |
|
| 126 |
|
|
@@ -292,7 +292,7 @@ TOOL_COMPONENTS = {
|
|
| 292 |
},
|
| 293 |
"fetch_cricket_details": {
|
| 294 |
"is_gradio_api": False,
|
| 295 |
-
"inputs": gr.Radio(["live", "
|
| 296 |
"outputs": gr.JSON(label= "Details"),
|
| 297 |
},
|
| 298 |
"live_cricket_scorecard_href": {
|
|
|
|
| 63 |
# Available tools
|
| 64 |
# -----------------
|
| 65 |
|
| 66 |
+
async def cricket_source(mode: Literal["live", "upcoming"], want: Literal["live", "upcoming"]) -> str:
|
| 67 |
"""Fetches whole html from source extracts html container that contains necessary details
|
| 68 |
|
| 69 |
Args:
|
|
|
|
| 97 |
if mode in ['live', 'upcoming'] and want == "text":
|
| 98 |
text = container.get_text(separator=" ", strip= True)
|
| 99 |
return json.dumps({f"{mode} details": str(text)})
|
| 100 |
+
elif mode == 'live' and want == 'href':
|
| 101 |
hrefs_list = container.find_all("a", class_ = "cb-text-link cb-mtch-lnks")
|
| 102 |
hrefs_string = ",".join(str(tag) for tag in herfs_list)
|
| 103 |
return json.dumps({"hrefs_strings": herfs_string})
|
|
|
|
| 120 |
|
| 121 |
async def live_cricket_scorecard_href()-> str:
|
| 122 |
"""String of comma separated anchor tags with herf attributes that pointing to live cricket scorecards """
|
| 123 |
+
response = await cricket_source('live', 'href')
|
| 124 |
return response
|
| 125 |
|
| 126 |
|
|
|
|
| 292 |
},
|
| 293 |
"fetch_cricket_details": {
|
| 294 |
"is_gradio_api": False,
|
| 295 |
+
"inputs": gr.Radio(["live", "upcoming"], label="Mode"),
|
| 296 |
"outputs": gr.JSON(label= "Details"),
|
| 297 |
},
|
| 298 |
"live_cricket_scorecard_href": {
|