@google/genai 0.9.0 → 0.11.0
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.
- package/README.md +30 -5
- package/dist/genai.d.ts +803 -41
- package/dist/index.js +1664 -1039
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1662 -1040
- package/dist/index.mjs.map +1 -1
- package/dist/node/index.js +1792 -1128
- package/dist/node/index.js.map +1 -1
- package/dist/node/node.d.ts +803 -41
- package/dist/web/index.mjs +1786 -1123
- package/dist/web/index.mjs.map +1 -1
- package/dist/web/web.d.ts +803 -41
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,19 +107,19 @@ const ai = new GoogleGenAI({
|
|
|
107
107
|
All API features are accessed through an instance of the `GoogleGenAI` classes.
|
|
108
108
|
The submodules bundle together related API methods:
|
|
109
109
|
|
|
110
|
-
- [`ai.models`](https://googleapis.github.io/js-genai/classes/models.Models.html):
|
|
110
|
+
- [`ai.models`](https://googleapis.github.io/js-genai/main/classes/models.Models.html):
|
|
111
111
|
Use `models` to query models (`generateContent`, `generateImages`, ...), or
|
|
112
112
|
examine their metadata.
|
|
113
|
-
- [`ai.caches`](https://googleapis.github.io/js-genai/classes/caches.Caches.html):
|
|
113
|
+
- [`ai.caches`](https://googleapis.github.io/js-genai/main/classes/caches.Caches.html):
|
|
114
114
|
Create and manage `caches` to reduce costs when repeatedly using the same
|
|
115
115
|
large prompt prefix.
|
|
116
|
-
- [`ai.chats`](https://googleapis.github.io/js-genai/classes/chats.Chats.html):
|
|
116
|
+
- [`ai.chats`](https://googleapis.github.io/js-genai/main/classes/chats.Chats.html):
|
|
117
117
|
Create local stateful `chat` objects to simplify multi turn interactions.
|
|
118
|
-
- [`ai.files`](https://googleapis.github.io/js-genai/classes/files.Files.html):
|
|
118
|
+
- [`ai.files`](https://googleapis.github.io/js-genai/main/classes/files.Files.html):
|
|
119
119
|
Upload `files` to the API and reference them in your prompts.
|
|
120
120
|
This reduces bandwidth if you use a file many times, and handles files too
|
|
121
121
|
large to fit inline with your prompt.
|
|
122
|
-
- [`ai.live`](https://googleapis.github.io/js-genai/classes/live.Live.html):
|
|
122
|
+
- [`ai.live`](https://googleapis.github.io/js-genai/main/classes/live.Live.html):
|
|
123
123
|
Start a `live` session for real time interaction, allows text + audio + video
|
|
124
124
|
input, and text or audio output.
|
|
125
125
|
|
|
@@ -212,6 +212,31 @@ async function main() {
|
|
|
212
212
|
main();
|
|
213
213
|
```
|
|
214
214
|
|
|
215
|
+
### Generate Content
|
|
216
|
+
|
|
217
|
+
#### How to structure `contents` argument for `generateContent`
|
|
218
|
+
|
|
219
|
+
The SDK allows you to specify the following types in the `contents` parameter:
|
|
220
|
+
|
|
221
|
+
#### Content
|
|
222
|
+
|
|
223
|
+
- `Content`: The SDK will wrap the singular `Content` instance in an array which
|
|
224
|
+
contains only the given content instance
|
|
225
|
+
- `Content[]`: No transformation happens
|
|
226
|
+
|
|
227
|
+
#### Part
|
|
228
|
+
|
|
229
|
+
Parts will be aggregated on a singular Content, with role 'user'.
|
|
230
|
+
|
|
231
|
+
- `Part | string`: The SDK will wrap the `string` or `Part` in a `Content`
|
|
232
|
+
instance with role 'user'.
|
|
233
|
+
- `Part[] | string[]`: The SDK will wrap the full provided list into a single
|
|
234
|
+
`Content` with role 'user'.
|
|
235
|
+
|
|
236
|
+
**_NOTE:_** This doesn't apply to `FunctionCall` and `FunctionResponse` parts,
|
|
237
|
+
if you are specifying those, you need to explicitly provide the full
|
|
238
|
+
`Content[]` structure making it explicit which Parts are 'spoken' by the model,
|
|
239
|
+
or the user. The SDK will throw an exception if you try this.
|
|
215
240
|
|
|
216
241
|
## Preview Launch
|
|
217
242
|
|