ailoy-py 0.0.1__cp313-cp313-manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ailoy/__init__.py +3 -0
- ailoy/agent.py +729 -0
- ailoy/ailoy_py.cpython-313-x86_64-linux-gnu.so +0 -0
- ailoy/ailoy_py.pyi +29 -0
- ailoy/cli/__main__.py +11 -0
- ailoy/cli/model.py +112 -0
- ailoy/presets/tools/calculator.json +24 -0
- ailoy/presets/tools/frankfurter.json +33 -0
- ailoy/presets/tools/nytimes.json +26 -0
- ailoy/presets/tools/tmdb.json +185 -0
- ailoy/runtime.py +273 -0
- ailoy/vector_store.py +207 -0
- ailoy_py-0.0.1.dist-info/METADATA +88 -0
- ailoy_py-0.0.1.dist-info/RECORD +19 -0
- ailoy_py-0.0.1.dist-info/WHEEL +5 -0
- ailoy_py-0.0.1.dist-info/entry_points.txt +3 -0
- ailoy_py.libs/libgomp-870cb1d0.so.1.0.0 +0 -0
- ailoy_py.libs/libmvec-2-8eb5c230.28.so +0 -0
- ailoy_py.libs/libtvm_runtime-7067e461.so +0 -0
Binary file
|
ailoy/ailoy_py.pyi
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
from typing import Any, Literal, Optional, TypedDict
|
2
|
+
|
3
|
+
class Packet(TypedDict):
|
4
|
+
packet_type: Literal["respond", "respond_execute"]
|
5
|
+
instruction_type: Optional[Literal["call_function", "define_component", "delete_component", "call_method"]]
|
6
|
+
headers: list[bool | int | str]
|
7
|
+
body: dict[str, Any]
|
8
|
+
|
9
|
+
def start_threads(address: str) -> None: ...
|
10
|
+
def stop_threads(address: str) -> None: ...
|
11
|
+
def generate_uuid() -> str: ...
|
12
|
+
|
13
|
+
class BrokerClient:
|
14
|
+
def send_type1(self, txid: str, ptype: Literal["connect", "disconnect"]) -> bool: ...
|
15
|
+
def send_type2(
|
16
|
+
self,
|
17
|
+
txid: str,
|
18
|
+
ptype: Literal["subscribe", "unsubscribe", "execute"],
|
19
|
+
itype: Literal["call_function", "define_component", "delete_component", "call_method"],
|
20
|
+
*args,
|
21
|
+
) -> bool: ...
|
22
|
+
def send_type3(
|
23
|
+
self,
|
24
|
+
txid: str,
|
25
|
+
ptype: Literal["respond", "respond_execute"],
|
26
|
+
status: bool,
|
27
|
+
*args,
|
28
|
+
) -> bool: ...
|
29
|
+
def listen() -> Optional[Packet]: ...
|
ailoy/cli/__main__.py
ADDED
ailoy/cli/model.py
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
from enum import Enum
|
2
|
+
from typing import Annotated
|
3
|
+
|
4
|
+
import typer
|
5
|
+
from pydantic import BaseModel
|
6
|
+
from rich.console import Console
|
7
|
+
from rich.table import Table
|
8
|
+
|
9
|
+
from ailoy.runtime import Runtime
|
10
|
+
|
11
|
+
app = typer.Typer(no_args_is_help=True)
|
12
|
+
|
13
|
+
|
14
|
+
def _create_runtime(ctx: typer.Context) -> Runtime:
|
15
|
+
runtime = Runtime()
|
16
|
+
ctx.call_on_close(runtime.stop)
|
17
|
+
return runtime
|
18
|
+
|
19
|
+
|
20
|
+
def _humanize_bytes(num: float, suffix="B"):
|
21
|
+
for unit in ("", "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi"):
|
22
|
+
if abs(num) < 1024.0:
|
23
|
+
return f"{num:3.1f}{unit}{suffix}"
|
24
|
+
num /= 1024.0
|
25
|
+
return f"{num:.1f}Yi{suffix}"
|
26
|
+
|
27
|
+
|
28
|
+
class ListModelsResponse(BaseModel):
|
29
|
+
class Item(BaseModel):
|
30
|
+
type: str
|
31
|
+
model_id: str
|
32
|
+
attributes: dict[str, str]
|
33
|
+
model_path: str
|
34
|
+
total_bytes: int
|
35
|
+
|
36
|
+
results: list[Item]
|
37
|
+
|
38
|
+
|
39
|
+
@app.command("list")
|
40
|
+
def list_local_models(ctx: typer.Context):
|
41
|
+
rt = _create_runtime(ctx)
|
42
|
+
resp = rt.call("list_local_models", {})
|
43
|
+
|
44
|
+
table = Table(title="List models in local cache", title_justify="center")
|
45
|
+
table.add_column("Type", justify="center")
|
46
|
+
table.add_column("Model ID")
|
47
|
+
table.add_column("Attributes")
|
48
|
+
table.add_column("Path", overflow="fold")
|
49
|
+
table.add_column("Size", justify="center")
|
50
|
+
|
51
|
+
resp = ListModelsResponse.model_validate(resp)
|
52
|
+
models = sorted(resp.results, key=lambda x: x.model_id)
|
53
|
+
|
54
|
+
for model in models:
|
55
|
+
attributes = [f"{key}: {val}" for key, val in model.attributes.items()]
|
56
|
+
attributes_str = "\n".join(attributes)
|
57
|
+
|
58
|
+
model_size = _humanize_bytes(model.total_bytes)
|
59
|
+
|
60
|
+
table.add_row(model.type, model.model_id, attributes_str, model.model_path, model_size)
|
61
|
+
|
62
|
+
console = Console()
|
63
|
+
console.print(table)
|
64
|
+
|
65
|
+
|
66
|
+
class Quantization(str, Enum):
|
67
|
+
q4f16_1 = "q4f16_1"
|
68
|
+
|
69
|
+
|
70
|
+
class Device(str, Enum):
|
71
|
+
metal = "metal"
|
72
|
+
vulkan = "vulkan"
|
73
|
+
|
74
|
+
|
75
|
+
class DownloadModelResponse(BaseModel):
|
76
|
+
model_path: str
|
77
|
+
|
78
|
+
|
79
|
+
@app.command("download")
|
80
|
+
def download_models(
|
81
|
+
ctx: typer.Context,
|
82
|
+
model_id: Annotated[str, typer.Argument(help="model id")],
|
83
|
+
quantization: Annotated[Quantization, typer.Option("-q", "--quantization", help="quantization method")],
|
84
|
+
device: Annotated[Device, typer.Option("-d", "--device", help="target device")],
|
85
|
+
):
|
86
|
+
rt = _create_runtime(ctx)
|
87
|
+
resp = DownloadModelResponse.model_validate(
|
88
|
+
rt.call(
|
89
|
+
"download_model",
|
90
|
+
{
|
91
|
+
"model_id": model_id,
|
92
|
+
"quantization": quantization,
|
93
|
+
"device": device,
|
94
|
+
},
|
95
|
+
)
|
96
|
+
)
|
97
|
+
|
98
|
+
print(f"Successfully downloaded {model_id} in {resp.model_path}")
|
99
|
+
|
100
|
+
|
101
|
+
@app.command("remove")
|
102
|
+
def remove_model(
|
103
|
+
ctx: typer.Context,
|
104
|
+
model_id: Annotated[str, typer.Argument(help="model id")],
|
105
|
+
):
|
106
|
+
rt = _create_runtime(ctx)
|
107
|
+
resp = rt.call("remove_model", {"model_id": model_id})
|
108
|
+
|
109
|
+
if resp["skipped"]:
|
110
|
+
print(f"Skipped removing {model_id}")
|
111
|
+
else:
|
112
|
+
print(f"Successfully removed {model_id} in {resp['model_path']}")
|
@@ -0,0 +1,24 @@
|
|
1
|
+
{
|
2
|
+
"calculator": {
|
3
|
+
"type": "builtin",
|
4
|
+
"description": {
|
5
|
+
"name": "calculator",
|
6
|
+
"description": "Evaluate the given mathematical expression. It is recommended to be used when there is something to calculate.",
|
7
|
+
"parameters": {
|
8
|
+
"type": "object",
|
9
|
+
"properties": {
|
10
|
+
"expression": {
|
11
|
+
"type": "string",
|
12
|
+
"description": "The mathematical expression to evaluate, which is consist of float numbers, arithmetics(+, -, *, /, %, ^), parentheses, and functions.\nThe following mathematical constants and functions can be utilzed in the expression.\n[e, pi, sqrt, abs, round, trunc, floor, ceil, ln, log, log10, sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, fac, ncr, npr]"
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"required": [
|
16
|
+
"expression"
|
17
|
+
]
|
18
|
+
}
|
19
|
+
},
|
20
|
+
"behavior": {
|
21
|
+
"outputPath": "value"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"frankfurter": {
|
3
|
+
"type": "restapi",
|
4
|
+
"description": {
|
5
|
+
"name": "frankfurter",
|
6
|
+
"description": "Get the latest currency exchange rates of target currencies based on the 'base' currency",
|
7
|
+
"parameters": {
|
8
|
+
"type": "object",
|
9
|
+
"properties": {
|
10
|
+
"base": {
|
11
|
+
"type": "string",
|
12
|
+
"description": "The ISO 4217 currency code to be the divider of the currency rate to be got."
|
13
|
+
},
|
14
|
+
"symbols": {
|
15
|
+
"type": "string",
|
16
|
+
"description": "The target ISO 4217 currency codes separated by comma; if not given, targets will be every existing codes."
|
17
|
+
}
|
18
|
+
},
|
19
|
+
"required": [
|
20
|
+
"base"
|
21
|
+
]
|
22
|
+
}
|
23
|
+
},
|
24
|
+
"behavior": {
|
25
|
+
"baseURL": "https://api.frankfurter.dev/v1/latest",
|
26
|
+
"method": "GET",
|
27
|
+
"headers": {
|
28
|
+
"accept": "application/json"
|
29
|
+
},
|
30
|
+
"outputPath": "rates"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"nytimes_article_search": {
|
3
|
+
"type": "restapi",
|
4
|
+
"description": {
|
5
|
+
"name": "nytimes_article_search",
|
6
|
+
"description": "search new york times articles by keyword.",
|
7
|
+
"parameters": {
|
8
|
+
"type": "object",
|
9
|
+
"properties": {
|
10
|
+
"q": {
|
11
|
+
"type": "string",
|
12
|
+
"description": "Query keyword"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
},
|
17
|
+
"behavior": {
|
18
|
+
"baseURL": "https://api.nytimes.com/svc/search/v2/articlesearch.json",
|
19
|
+
"method": "GET",
|
20
|
+
"headers": {
|
21
|
+
"accept": "application/json"
|
22
|
+
},
|
23
|
+
"outputPath": "response.docs[:10].{headline:headline.main, abstract:abstract, type_of_material:type_of_material, section:section_name, subsection:subsection_name, web_url:web_url}"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,185 @@
|
|
1
|
+
{
|
2
|
+
"tmdb_trending_movies": {
|
3
|
+
"type": "restapi",
|
4
|
+
"description": {
|
5
|
+
"name": "tmdb_trending_movies",
|
6
|
+
"description": "Get the trending movies on TMDB.",
|
7
|
+
"parameters": {
|
8
|
+
"type": "object",
|
9
|
+
"properties": {
|
10
|
+
"time_window": {
|
11
|
+
"type": "string",
|
12
|
+
"choices": [
|
13
|
+
"day",
|
14
|
+
"week"
|
15
|
+
],
|
16
|
+
"default": "day"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
},
|
21
|
+
"behavior": {
|
22
|
+
"baseURL": "https://api.themoviedb.org/3/trending/movie/${time_window}",
|
23
|
+
"method": "GET",
|
24
|
+
"authentication": "bearer",
|
25
|
+
"headers": {
|
26
|
+
"accept": "application/json"
|
27
|
+
},
|
28
|
+
"outputPath": "results[:10].{id: id, title: title, overview: overview, original_language: original_language, genre_ids: genre_ids, release_date: release_date, vote_average: vote_average, adult:adult}"
|
29
|
+
}
|
30
|
+
},
|
31
|
+
"tmdb_movie_search": {
|
32
|
+
"type": "restapi",
|
33
|
+
"description": {
|
34
|
+
"name": "tmdb_movie_search",
|
35
|
+
"description": "Search for movies by their original, translated and alternative titles.",
|
36
|
+
"parameters": {
|
37
|
+
"type": "object",
|
38
|
+
"properties": {
|
39
|
+
"query": {
|
40
|
+
"type": "string"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"return": {
|
45
|
+
"type": "object",
|
46
|
+
"properties": {
|
47
|
+
"id": {
|
48
|
+
"type": "number",
|
49
|
+
"description": "Unique ID of the movie"
|
50
|
+
},
|
51
|
+
"genre_ids": {
|
52
|
+
"type": "array",
|
53
|
+
"items": {
|
54
|
+
"type": "number",
|
55
|
+
"description": "Unique ID of the genre"
|
56
|
+
}
|
57
|
+
},
|
58
|
+
"overview": {
|
59
|
+
"type": "string",
|
60
|
+
"description": "Overview of the movie"
|
61
|
+
},
|
62
|
+
"popularity": {
|
63
|
+
"type": "number",
|
64
|
+
"description": "Popularity of the movie(starts from 0)"
|
65
|
+
},
|
66
|
+
"vote_count": {
|
67
|
+
"type": "number"
|
68
|
+
},
|
69
|
+
"vote_average": {
|
70
|
+
"type": "number"
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
},
|
75
|
+
"behavior": {
|
76
|
+
"baseURL": "https://api.themoviedb.org/3/search/movie",
|
77
|
+
"method": "GET",
|
78
|
+
"authentication": "bearer",
|
79
|
+
"headers": {
|
80
|
+
"accept": "application/json"
|
81
|
+
},
|
82
|
+
"outputPath": "results[:5].{id: id, title: title, overview: overview, original_language: original_language, genre_ids: genre_ids, release_date: release_date, vote_average: vote_average, adult:adult}"
|
83
|
+
}
|
84
|
+
},
|
85
|
+
"tmdb_movie_reviews": {
|
86
|
+
"type": "restapi",
|
87
|
+
"description": {
|
88
|
+
"name": "tmdb_movie_reviews",
|
89
|
+
"description": "Get the user reviews for a movie.",
|
90
|
+
"parameters": {
|
91
|
+
"type": "object",
|
92
|
+
"properties": {
|
93
|
+
"movie_id": {
|
94
|
+
"type": "number",
|
95
|
+
"description": "Unique ID of the movie (Can be acquired by movie search API)"
|
96
|
+
}
|
97
|
+
}
|
98
|
+
}
|
99
|
+
},
|
100
|
+
"behavior": {
|
101
|
+
"baseURL": "https://api.themoviedb.org/3/movie/${movie_id}/reviews",
|
102
|
+
"method": "GET",
|
103
|
+
"authentication": "bearer",
|
104
|
+
"headers": {
|
105
|
+
"accept": "application/json"
|
106
|
+
},
|
107
|
+
"outputPath": "results[:3].{content:content, author:author, url:url, created_at:created_at, updated_at:updated_at}"
|
108
|
+
}
|
109
|
+
},
|
110
|
+
"tmdb_movie_recommendations": {
|
111
|
+
"type": "restapi",
|
112
|
+
"description": {
|
113
|
+
"name": "tmdb_movie_recommendations",
|
114
|
+
"description": "Recommend movies based on the movie ID.",
|
115
|
+
"parameters": {
|
116
|
+
"type": "object",
|
117
|
+
"properties": {
|
118
|
+
"movie_id": {
|
119
|
+
"type": "number",
|
120
|
+
"description": "Unique ID of the movie (Can be acquired by movie search API)"
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
},
|
125
|
+
"behavior": {
|
126
|
+
"baseURL": "https://api.themoviedb.org/3/movie/${movie_id}/recommendations",
|
127
|
+
"method": "GET",
|
128
|
+
"authentication": "bearer",
|
129
|
+
"headers": {
|
130
|
+
"accept": "application/json"
|
131
|
+
},
|
132
|
+
"outputPath": "results[:5].{id: id, title: title, overview: overview, original_language: original_language, genre_ids: genre_ids, release_date: release_date, vote_average: vote_average, adult:adult}"
|
133
|
+
}
|
134
|
+
},
|
135
|
+
"tmdb_movie_watch_providers": {
|
136
|
+
"type": "restapi",
|
137
|
+
"description": {
|
138
|
+
"name": "tmdb_movie_watch_providers",
|
139
|
+
"description": "Get the list of streaming providers we have for a movie in some coutries.",
|
140
|
+
"parameters": {
|
141
|
+
"type": "object",
|
142
|
+
"properties": {
|
143
|
+
"movie_id": {
|
144
|
+
"type": "number",
|
145
|
+
"description": "Unique ID of the movie (Can be acquired by movie search API)"
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
},
|
150
|
+
"behavior": {
|
151
|
+
"baseURL": "https://api.themoviedb.org/3/movie/${movie_id}/watch/providers",
|
152
|
+
"method": "GET",
|
153
|
+
"authentication": "bearer",
|
154
|
+
"headers": {
|
155
|
+
"accept": "application/json"
|
156
|
+
},
|
157
|
+
"outputPath": "results.{US:US.{buy:buy[*].provider_name, rent:rent[*].provider_name,stream:flatrate[*].provider_name},KR:KR.{buy:buy[*].provider_name, rent:rent[*].provider_name,stream:flatrate[*].provider_name}}"
|
158
|
+
}
|
159
|
+
},
|
160
|
+
"tmdb_movie_genre_names": {
|
161
|
+
"type": "restapi",
|
162
|
+
"description": {
|
163
|
+
"name": "tmdb_movie_genre_names",
|
164
|
+
"description": "Get the list of genre names with their ids.",
|
165
|
+
"parameters": {
|
166
|
+
"type": "object",
|
167
|
+
"properties": {
|
168
|
+
"language": {
|
169
|
+
"type": "string",
|
170
|
+
"description": "ISO 639-1 language code itself or with ISO 3166-1 country code\ne.g.)en, en-US, default is en."
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}
|
174
|
+
},
|
175
|
+
"behavior": {
|
176
|
+
"baseURL": "https://api.themoviedb.org/3/genre/movie/list",
|
177
|
+
"method": "GET",
|
178
|
+
"authentication": "bearer",
|
179
|
+
"headers": {
|
180
|
+
"accept": "application/json"
|
181
|
+
},
|
182
|
+
"outputPath": "genres"
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|