Skip to content

Commit c810a5c

Browse files
dwcarrroodboi
andauthored
Update together.md to fix example code errors (#185)
Co-authored-by: Dimitri Kennedy <[email protected]>
1 parent 1ff06f6 commit c810a5c

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

docs/blog/posts/together.md

+14-12
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,43 @@ The good news is that Anyscale employs the same OpenAI client, and its models su
3535
Let's explore one of the models available in Together's extensive collection!
3636

3737
```ts
38-
import Instructor from "@/instructor"
38+
import Instructor from "@instructor-ai/instructor"
3939
import OpenAI from "openai"
4040
import { z } from "zod"
4141

42-
const property = z.object({
43-
name: z.string(),
44-
value: z.string()
45-
}).describe("A property defined by a name and value")
42+
const property = z
43+
.object({
44+
name: z.string(),
45+
value: z.string(),
46+
})
47+
.describe("A property defined by a name and value");
4648

4749
const UserSchema = z.object({
4850
age: z.number(),
4951
name: z.string(),
50-
properties: z.array(property)
52+
properties: z.array(property),
5153
})
5254

5355
const oai = new OpenAI({
54-
baseUrl='https://api.together.xyz',
56+
baseURL: "https://api.together.xyz",
5557
apiKey: process.env.TOGETHER_API_KEY ?? undefined,
5658
})
5759

5860
const client = Instructor({
5961
client: oai,
60-
mode: "JSON_SCHEMA"
62+
mode: "JSON_SCHEMA",
6163
})
6264

6365
const user = await client.chat.completions.create({
6466
messages: [{ role: "user", content: "Harry Potter" }],
6567
model: "mistralai/Mixtral-8x7B-Instruct-v0.1",
6668
response_model: { schema: UserSchema, name: "UserSchema" },
67-
max_retries: 3
69+
max_retries: 3,
6870
})
6971

70-
console.log(user)
72+
console.log(user);
7173
/**
72-
* {
74+
{
7375
age: 17,
7476
name: "Harry Potter",
7577
properties: [
@@ -82,7 +84,7 @@ console.log(user)
8284
}
8385
],
8486
}
85-
*/
87+
**/
8688
```
8789

8890
You can find more information about Togethers's output mode support [here](https://docs.together.ai/docs/json-mode/).

0 commit comments

Comments
 (0)