Skip to content

Commit 8d09ba4

Browse files
[Workers AI] Adds Batch Pill and Feature (#21604)
* Adds Batch Pill and Feature * Added filters * docs gen update --------- Co-authored-by: kodster28 <[email protected]>
1 parent 4e148c9 commit 8d09ba4

21 files changed

+729
-142
lines changed

src/components/ModelCatalog.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
8080
return "Function calling";
8181
}
8282

83+
if (property_id === "async_queue" && value === "true") {
84+
return "Batch";
85+
}
86+
8387
return [];
8488
})
8589
.filter((p) => Boolean(p)),
@@ -102,6 +106,10 @@ const ModelCatalog = ({ models }: { models: WorkersAIModelsSchema[] }) => {
102106
return "Function calling";
103107
}
104108

109+
if (property_id === "async_queue" && value === "true") {
110+
return "Batch";
111+
}
112+
105113
return [];
106114
})
107115
.filter((p) => Boolean(p)),

src/components/models/ModelBadges.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ const ModelBadges = ({ model }: { model: WorkersAIModelsSchema }) => {
1616
};
1717
}
1818

19+
if (property_id === "async_queue" && value === "true") {
20+
return {
21+
variant: "note",
22+
text: "Batch",
23+
};
24+
}
25+
1926
if (property_id === "planned_deprecation_date") {
2027
const timestamp = Math.floor(new Date(value as string).getTime() / 1000);
2128

src/components/models/ModelFeatures.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ const ModelFeatures = ({ model }: { model: WorkersAIModelsSchema }) => {
110110
<td>Yes</td>
111111
</tr>
112112
)}
113+
{properties.async_queue && (
114+
<tr>
115+
<td>Batch</td>
116+
<td>Yes</td>
117+
</tr>
118+
)}
113119
{properties.price && properties.price.length > 0 && (
114120
<tr>
115121
<td>Unit Pricing</td>

src/content/workers-ai-models/bart-large-cnn.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
{
1515
"property_id": "beta",
1616
"value": "true"
17+
},
18+
{
19+
"property_id": "price",
20+
"value": [
21+
{
22+
"unit": "per M input tokens",
23+
"price": 0,
24+
"currency": "USD"
25+
}
26+
]
1727
}
1828
],
1929
"schema": {

src/content/workers-ai-models/bge-base-en-v1.5.json

Lines changed: 119 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"created_at": "2023-09-25 19:21:11.898",
1212
"tags": [],
1313
"properties": [
14+
{
15+
"property_id": "async_queue",
16+
"value": "true"
17+
},
1418
{
1519
"property_id": "price",
1620
"value": [
@@ -37,53 +41,135 @@
3741
"schema": {
3842
"input": {
3943
"type": "object",
40-
"properties": {
41-
"text": {
42-
"oneOf": [
43-
{
44-
"type": "string",
45-
"description": "The text to embed",
46-
"minLength": 1
44+
"oneOf": [
45+
{
46+
"properties": {
47+
"text": {
48+
"oneOf": [
49+
{
50+
"type": "string",
51+
"description": "The text to embed",
52+
"minLength": 1
53+
},
54+
{
55+
"type": "array",
56+
"description": "Batch of text values to embed",
57+
"items": {
58+
"type": "string",
59+
"description": "The text to embed",
60+
"minLength": 1
61+
},
62+
"maxItems": 100
63+
}
64+
]
4765
},
48-
{
66+
"pooling": {
67+
"type": "string",
68+
"enum": [
69+
"mean",
70+
"cls"
71+
],
72+
"default": "mean",
73+
"description": "The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy."
74+
}
75+
},
76+
"required": [
77+
"text"
78+
]
79+
},
80+
{
81+
"properties": {
82+
"requests": {
4983
"type": "array",
50-
"description": "Batch of text values to embed",
84+
"description": "Batch of the embeddings requests to run using async-queue",
5185
"items": {
52-
"type": "string",
53-
"description": "The text to embed",
54-
"minLength": 1
55-
},
56-
"maxItems": 100
86+
"properties": {
87+
"text": {
88+
"oneOf": [
89+
{
90+
"type": "string",
91+
"description": "The text to embed",
92+
"minLength": 1
93+
},
94+
{
95+
"type": "array",
96+
"description": "Batch of text values to embed",
97+
"items": {
98+
"type": "string",
99+
"description": "The text to embed",
100+
"minLength": 1
101+
},
102+
"maxItems": 100
103+
}
104+
]
105+
},
106+
"pooling": {
107+
"type": "string",
108+
"enum": [
109+
"mean",
110+
"cls"
111+
],
112+
"default": "mean",
113+
"description": "The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy."
114+
}
115+
},
116+
"required": [
117+
"text"
118+
]
119+
}
57120
}
121+
},
122+
"required": [
123+
"requests"
58124
]
59125
}
60-
},
61-
"required": [
62-
"text"
63126
]
64127
},
65128
"output": {
66-
"type": "object",
67-
"contentType": "application/json",
68-
"properties": {
69-
"shape": {
70-
"type": "array",
71-
"items": {
72-
"type": "number"
129+
"oneOf": [
130+
{
131+
"type": "object",
132+
"contentType": "application/json",
133+
"properties": {
134+
"shape": {
135+
"type": "array",
136+
"items": {
137+
"type": "number"
138+
}
139+
},
140+
"data": {
141+
"type": "array",
142+
"description": "Embeddings of the requested text values",
143+
"items": {
144+
"type": "array",
145+
"description": "Floating point embedding representation shaped by the embedding model",
146+
"items": {
147+
"type": "number"
148+
}
149+
}
150+
},
151+
"pooling": {
152+
"type": "string",
153+
"enum": [
154+
"mean",
155+
"cls"
156+
],
157+
"description": "The pooling method used in the embedding process."
158+
}
73159
}
74160
},
75-
"data": {
76-
"type": "array",
77-
"description": "Embeddings of the requested text values",
78-
"items": {
79-
"type": "array",
80-
"description": "Floating point embedding representation shaped by the embedding model",
81-
"items": {
82-
"type": "number"
161+
{
162+
"type": "object",
163+
"contentType": "application/json",
164+
"title": "Async response",
165+
"properties": {
166+
"request_id": {
167+
"type": "string",
168+
"description": "The async request id that can be used to obtain the results."
83169
}
84170
}
85171
}
86-
}
172+
]
87173
}
88174
}
89175
}

0 commit comments

Comments
 (0)