Skip to content

Commit 4f0890e

Browse files
committed
thomasgauvin: add html characters because escaping double quotes doesnt seem to work
1 parent ceb28bd commit 4f0890e

File tree

1 file changed

+60
-67
lines changed

1 file changed

+60
-67
lines changed

src/content/docs/workers-ai/configuration/bindings.mdx

Lines changed: 60 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pcx_content_type: configuration
33
title: Workers Bindings
44
sidebar:
55
order: 1
6-
76
---
87

98
import { Type, MetaInfo } from "~/components";
@@ -40,81 +39,75 @@ To configure a Workers AI binding in your Pages Function, you must use the Cloud
4039
`async env.AI.run()` runs a model. Takes a model as the first parameter, and an object as the second parameter.
4140

4241
```javascript
43-
const answer = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
44-
prompt: "What is the origin of the phrase 'Hello, World'"
42+
const answer = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
43+
prompt: "What is the origin of the phrase 'Hello, World'",
4544
});
4645
```
4746

48-
**Parameters**
47+
```javascript
48+
const answer = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
49+
prompt: "What is the origin of the phrase 'Hello, World'",
50+
stream: true,
51+
});
4952

53+
return new Response(answer, {
54+
headers: { "content-type": "text/event-stream" },
55+
});
56+
```
5057

58+
**Parameters**
5159

52-
* `model` <Type text="string" /> <MetaInfo text="required" />
60+
- `model` <Type text="string" /> <MetaInfo text="required" />
5361

54-
* The model to run.
62+
- The model to run.
5563

5664
**Supported options**
5765

58-
* `prompt` <Type text="string" /> <MetaInfo text="optional" />
59-
* Text prompt for the text-generation (maxLength: 131072, minLength: 1).
60-
* `raw` <Type text="boolean" /> <MetaInfo text="optional" />
61-
* If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
62-
* `stream` <Type text="boolean" /> <MetaInfo text="optional" />
63-
* If true, the response will be streamed back incrementally using SSE, Server Sent Events.
64-
* `max_tokens` <Type text="number" /> <MetaInfo text="optional" />
65-
* The maximum number of tokens to generate in the response.
66-
* `temperature` <Type text="number" /> <MetaInfo text="optional" />
67-
* Controls the randomness of the output; higher values produce more random results (maximum: 5, minimum: 0).
68-
* `top_p` <Type text="number" /> <MetaInfo text="optional" />
69-
* Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses (maximum: 2, minimum: 0).
70-
* `top_k` <Type text="number" /> <MetaInfo text="optional" />
71-
* Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises (maximum: 50, minimum: 1).
72-
* `seed` <Type text="number" /> <MetaInfo text="optional" />
73-
* Random seed for reproducibility of the generation (maximum: 9999999999, minimum: 1).
74-
* `repetition_penalty` <Type text="number" /> <MetaInfo text="optional" />
75-
* Penalty for repeated tokens; higher values discourage repetition (maximum: 2, minimum: 0).
76-
* `frequency_penalty` <Type text="number" /> <MetaInfo text="optional" />
77-
* Decreases the likelihood of the model repeating the same lines verbatim (maximum: 2, minimum: 0).
78-
* `presence_penalty` <Type text="number" /> <MetaInfo text="optional" />
79-
* Increases the likelihood of the model introducing new topics (maximum: 2, minimum: 0).
80-
* `messages` <Type text="{
81-
role: \"user\" | \"assistant\" | \"system\" | \"tool\" | (string & NonNullable<unknown>);
82-
content: string;
83-
name?: string;
84-
}[]" /> <MetaInfo text="optional" />
85-
* An array of message objects representing the conversation history.
86-
* `tools` <Type text="{
87-
type: \"function\" | (string & NonNullable<unknown>);
88-
function: {
89-
name: string;
90-
description: string;
91-
parameters?: {
92-
type: \"object\" | (string & NonNullable<unknown>);
93-
properties: {
94-
[key: string]: {
95-
type: string;
96-
description?: string;
66+
- `prompt` <Type text="string" /> <MetaInfo text="optional" />
67+
- Text prompt for the text-generation (maxLength: 131072, minLength: 1).
68+
- `raw` <Type text="boolean" /> <MetaInfo text="optional" />
69+
- If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
70+
- `stream` <Type text="boolean" /> <MetaInfo text="optional" />
71+
- If true, the response will be streamed back incrementally using SSE, Server Sent Events.
72+
- `max_tokens` <Type text="number" /> <MetaInfo text="optional" />
73+
- The maximum number of tokens to generate in the response.
74+
- `temperature` <Type text="number" /> <MetaInfo text="optional" />
75+
- Controls the randomness of the output; higher values produce more random results (maximum: 5, minimum: 0).
76+
- `top_p` <Type text="number" /> <MetaInfo text="optional" />
77+
- Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses (maximum: 2, minimum: 0).
78+
- `top_k` <Type text="number" /> <MetaInfo text="optional" />
79+
- Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises (maximum: 50, minimum: 1).
80+
- `seed` <Type text="number" /> <MetaInfo text="optional" />
81+
- Random seed for reproducibility of the generation (maximum: 9999999999, minimum: 1).
82+
- `repetition_penalty` <Type text="number" /> <MetaInfo text="optional" />
83+
- Penalty for repeated tokens; higher values discourage repetition (maximum: 2, minimum: 0).
84+
- `frequency_penalty` <Type text="number" /> <MetaInfo text="optional" />
85+
- Decreases the likelihood of the model repeating the same lines verbatim (maximum: 2, minimum: 0).
86+
- `presence_penalty` <Type text="number" /> <MetaInfo text="optional" />
87+
- Increases the likelihood of the model introducing new topics (maximum: 2, minimum: 0).
88+
- `messages` <Type text="{
89+
role: &quot;user&quot; | &quot;assistant&quot; | &quot;system&quot; | &quot;tool&quot; | (string & NonNullable<unknown>);
90+
content: string;
91+
name?: string;
92+
}[]" /> <MetaInfo text="optional" /> \* An array of message objects representing the conversation history.
93+
- `tools` <Type text="{
94+
type: &quot;function&quot; | (string & NonNullable<unknown>);
95+
function: {
96+
name: string;
97+
description: string;
98+
parameters?: {
99+
type: &quot;object&quot; | (string & NonNullable<unknown>);
100+
properties: {
101+
[key: string]: {
102+
type: string;
103+
description?: string;
104+
};
105+
};
106+
required: string[];
97107
};
98108
};
99-
required: string[];
100-
};
101-
};
102-
}[]" /> <MetaInfo text="optional" />
103-
* A list of tools available for the assistant to use.
104-
* `functions` <Type text="{
105-
name: string;
106-
code: string;
107-
}[]" /> <MetaInfo text="optional" />
108-
* A list of functions available for the assistant to use.
109-
110-
111-
```javascript
112-
const answer = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
113-
prompt: "What is the origin of the phrase 'Hello, World'",
114-
stream: true
115-
});
116-
117-
return new Response(answer, {
118-
headers: { "content-type": "text/event-stream" }
119-
});
120-
```
109+
}[]" /> <MetaInfo text="optional" /> \* A list of tools available for the assistant to use.
110+
- `functions` <Type text="{
111+
name: string;
112+
code: string;
113+
}[]" /> <MetaInfo text="optional" /> \* A list of functions available for the assistant to use.

0 commit comments

Comments
 (0)