Skip to content

Commit a939ff5

Browse files
authored
v0 Release (#62)
1 parent 025f553 commit a939ff5

File tree

17 files changed

+73
-46
lines changed

17 files changed

+73
-46
lines changed

.changeset/config.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
3-
"changelog": ["@changesets/changelog-github", { "repo": "jxnl/instructor-js" }],
3+
"changelog": ["@changesets/changelog-github", { "repo": "instructor-ai/instructor-js" }],
44
"commit": false,
55
"fixed": [],
66
"linked": [],
7-
"access": "restricted",
7+
"access": "public",
88
"baseBranch": "main",
99
"ignore": [],
1010
"privatePackages": {
11-
"version": true,
11+
"version": false,
1212
"tag": false
1313
}
1414
}

.changeset/red-birds-march.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@instructor-ai/instructor": patch
3+
---
4+
5+
V0 release

.github/workflows/publish.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish changesets
1+
name: Publish
22

33
on:
44
pull_request:
@@ -9,13 +9,17 @@ concurrency: ${{ github.workflow }}-${{ github.ref }}
99
permissions: {} #reset
1010
jobs:
1111
publish:
12-
if: github.repository == 'jxnl/instructor-js' && github.event.pull_request.merged == true && (startsWith(github.head_ref, 'changeset-release/main') || startsWith(github.head_ref, '_publish-trigger'))
12+
if: github.repository == 'instructor-ai/instructor-js' && github.event.pull_request.merged == true && (startsWith(github.head_ref, 'changeset-release/main') || startsWith(github.head_ref, '_publish-trigger'))
1313
permissions:
1414
contents: write
1515
pull-requests: write
1616

1717
name: Publish packages
1818
runs-on: ubuntu-latest
19+
environment: Publish
20+
env:
21+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22+
1923

2024
steps:
2125
- name: Checkout Repo

.github/workflows/release-pr.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Create changeset release PR
1+
name: RC PR
22

33
on:
44
push:
@@ -12,13 +12,16 @@ env:
1212

1313
jobs:
1414
release:
15-
if: github.repository == 'jxnl/instructor-js'
15+
if: github.repository == 'instructor-ai/instructor-js'
1616
permissions:
1717
contents: write
1818
pull-requests: write
1919

2020
name: Changeset Release
2121
runs-on: ubuntu-latest
22+
environment: Publish
23+
env:
24+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
2225

2326
steps:
2427
- name: Checkout code

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test-wf
1+
name: Test
22
on:
33
push:
44
branches:

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _Structured extraction in Typescript, powered by llms, designed for simplicity,
66

77
[![Twitter Follow](https://img.shields.io/twitter/follow/jxnlco?style=social)](https://twitter.com/jxnlco)
88
[![Documentation](https://img.shields.io/badge/docs-available-brightgreen)](https://jxnl.github.io/instructor-js)
9-
[![GitHub issues](https://img.shields.io/github/issues/jxnl/instructor-js.svg)](https://github.com/jxnl/instructor-js/issues)
9+
[![GitHub issues](https://img.shields.io/github/issues/instructor-ai/instructor-js.svg)](https://github.com/instructor-ai/instructor-js/issues)
1010
[![Discord](https://img.shields.io/discord/1192334452110659664?label=discord)](https://discord.gg/CV8sPM5k5Y)
1111

1212
Dive into the world of Python-based structured extraction, by OpenAI's function calling API and Pydantic, the most widely used data validation library for Python. Instructor stands out for its simplicity, transparency, and user-centric design. Whether you're a seasoned developer or just starting out, you'll find Instructor's approach intuitive and steerable.
@@ -74,7 +74,7 @@ If you'd like to see more check out our [cookbook](examples/index.md).
7474

7575
## Contributing
7676

77-
If you want to help out, checkout some of the issues marked as `good-first-issue` or `help-wanted`. Found [here](https://github.com/jxnl/instructor-js/labels/good%20first%20issue). They could be anything from code improvements, a guest blog post, or a new cook book.
77+
If you want to help out, checkout some of the issues marked as `good-first-issue` or `help-wanted`. Found [here](https://github.com/instructor-ai/instructor-js/labels/good%20first%20issue). They could be anything from code improvements, a guest blog post, or a new cook book.
7878

7979
## License
8080

docs/contributing.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ We would love for you to contribute to `Instructor-js`.
44

55
Theres a bunch of examples in the python version, including documentation here [python docs](https://jxnl.github.io/instructor/examples/)
66

7-
If you want to contribute, please check out [issues](https://github.com/jxnl/instructor-js/issues/8)
7+
If you want to contribute, please check out [issues](https://github.com/instructor-ai/instructor-js/issues/8)
88

99
## Issues
1010

11-
If you find a bug, please file an issue on [our issue tracker on GitHub](https://github.com/jxnl/instructor-js/issues).
11+
If you find a bug, please file an issue on [our issue tracker on GitHub](https://github.com/instructor-ai/instructor-js/issues).
1212

1313
To help us reproduce the bug, please provide a minimal reproducible example, including a code snippet and the full error message.
1414

@@ -20,9 +20,9 @@ To help us reproduce the bug, please provide a minimal reproducible example, inc
2020

2121
We welcome pull requests! There is plenty to do, and we are happy to discuss any contributions you would like to make.
2222

23-
If it is not a small change, please start by [filing an issue](https://github.com/jxnl/instructor-js/issues) first.
23+
If it is not a small change, please start by [filing an issue](https://github.com/instructor-ai/instructor-js/issues) first.
2424

25-
If you need ideas, you can check out the [help wanted](https://github.com/jxnl/instructor-js/labels/help%20wanted) or [good first issue](https://github.com/jxnl/instructor-js/labels/good%20first%20issue) labels.
25+
If you need ideas, you can check out the [help wanted](https://github.com/instructor-ai/instructor-js/labels/help%20wanted) or [good first issue](https://github.com/instructor-ai/instructor-js/labels/good%20first%20issue) labels.
2626

2727
# Contributors
2828

@@ -36,7 +36,7 @@ If you need ideas, you can check out the [help wanted](https://github.com/jxnl/i
3636
<!-- ALL-CONTRIBUTORS-LIST:END -->
3737

3838
<a href="https://github.com/jxnl/instructor/graphs/contributors">
39-
<img src="https://contrib.rocks/image?repo=jxnl/instructor-js" />
39+
<img src="https://contrib.rocks/image?repo=instructor-ai/instructor-js" />
4040
</a>
4141

4242

docs/examples/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
This page is under construction. Please check back later. Consider contributing to this page by opening a PR! Theres a bunch of examples in the python version, including documentation here [python docs](https://jxnl.github.io/instructor/examples/)
66

7-
If you want to contribute, please check out [issues](https://github.com/jxnl/instructor-js/issues/8)
7+
If you want to contribute, please check out [issues](https://github.com/instructor-ai/instructor-js/issues/8)
88

99

1010

docs/help.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ The [cookbooks](examples/index.md) are a great place to start. They contain a va
2121

2222
## :material-github: GitHub Discussions
2323

24-
[GitHub discussions](https://github.com/jxnl/instructor-js/discussions) are useful for asking questions, your question and the answer will help everyone.
24+
[GitHub discussions](https://github.com/instructor-ai/instructor-js/discussions) are useful for asking questions, your question and the answer will help everyone.
2525

2626
## :material-github: GitHub Issues
2727

28-
[GitHub issues](https://github.com/jxnl/instructor-js/issues) are useful for reporting bugs or requesting new features.
28+
[GitHub issues](https://github.com/instructor-ai/instructor-js/issues) are useful for reporting bugs or requesting new features.
2929

3030
## :material-twitter: Twitter
3131

docs/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ _Structured extraction in Typescript, powered by llms, designed for simplicity,
66

77
[![Twitter Follow](https://img.shields.io/twitter/follow/jxnlco?style=social)](https://twitter.com/jxnlco)
88
[![Documentation](https://img.shields.io/badge/docs-available-brightgreen)](https://jxnl.github.io/instructor-js)
9-
[![GitHub issues](https://img.shields.io/github/issues/jxnl/instructor-js.svg)](https://github.com/jxnl/instructor-js/issues)
9+
[![GitHub issues](https://img.shields.io/github/issues/instructor-ai/instructor-js.svg)](https://github.com/instructor-ai/instructor-js/issues)
1010

1111
Dive into the world of Typescript-based structured extraction, by OpenAI's function calling API and Zod, typeScript-first schema validation with static type inference. Instructor stands out for its simplicity, transparency, and user-centric design. Whether you're a seasoned developer or just starting out, you'll find Instructor's approach intuitive and steerable.
1212

@@ -73,7 +73,7 @@ If you'd like to see more check out our [cookbook](examples/index.md).
7373

7474
## Contributing
7575

76-
If you want to help out, checkout some of the issues marked as `good-first-issue` or `help-wanted`. Found [here](https://github.com/jxnl/instructor-js/labels/good%20first%20issue). They could be anything from code improvements, a guest blog post, or a new cook book.
76+
If you want to help out, checkout some of the issues marked as `good-first-issue` or `help-wanted`. Found [here](https://github.com/instructor-ai/instructor-js/labels/good%20first%20issue). They could be anything from code improvements, a guest blog post, or a new cook book.
7777

7878
## License
7979

docs/overrides/main.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
{% include ".icons/fontawesome/solid/star.svg" %}
1212
</span>
1313
us on
14-
<a href="https://www.github.com/jxnl/instructor-js">
14+
<a href="https://www.github.com/instructor-ai/instructor-js">
1515
<span class="twemoji github">
1616
{% include ".icons/fontawesome/brands/github.svg" %}
1717
</span>

examples/extract_user_stream/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ const extractionStream = await client.chat.completions.create({
5555
messages: [{ role: "user", content: textBlock }],
5656
model: "gpt-4-1106-preview",
5757
response_model: {
58-
schema: ExtractionValuesSchema
58+
schema: ExtractionValuesSchema,
59+
name: "value extraction"
5960
},
6061
max_retries: 3,
6162
stream: true,

mkdocs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ site_name: Instructor (JS)
22
site_author: Jason Liu
33
site_description: Enhancing OpenAI function calling with Zod
44
repo_name: instructor
5-
repo_url: https://github.com/jxnl/instructor-js
5+
repo_url: https://github.com/instructor-ai/instructor-js
66
site_url: https://jxnl.github.io/instructor-js/
77
edit_uri: edit/main/docs/
88
copyright: Copyright &copy; 2024 Jason Liu

package.json

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
{
2-
"name": "instructor-js",
3-
"version": "0.0.1",
2+
"name": "@instructor-ai/instructor",
3+
"version": "0.0.0",
44
"description": "structured outputs for llms",
5-
"main": "./dist/index.js",
6-
"module": "./dist/index.mjs",
7-
"types": "./dist/index.d.ts",
8-
"exports": {
9-
".": {
10-
"import": "./dist/index.mjs",
11-
"require": "./dist/index.js"
12-
}
13-
},
145
"publishConfig": {
156
"access": "public"
167
},
8+
"main": "./dist/instructor.js",
9+
"module": "./dist/instructor.mjs",
10+
"types": "./dist/instructor.d.ts",
11+
"exports": {
12+
".": {
13+
"import": "./dist/instructor.mjs",
14+
"require": "./dist/instructor.js"
15+
},
16+
"./*": "./dist/*.mjs"
17+
},
18+
"files": [
19+
"dist/**"
20+
],
21+
"sideEffects": false,
1722
"scripts": {
1823
"test": "echo \"Error: no test specified\" && exit 1",
1924
"build": "tsup",
@@ -28,7 +33,7 @@
2833
},
2934
"repository": {
3035
"type": "git",
31-
"url": "git+https://github.com/jxnl/instructor-js.git"
36+
"url": "git+https://github.com/instructor-ai/instructor-js.git"
3237
},
3338
"keywords": [
3439
"llm",
@@ -39,9 +44,9 @@
3944
"author": "Jason Liu",
4045
"license": "MIT",
4146
"bugs": {
42-
"url": "https://github.com/jxnl/instructor-js/issues"
47+
"url": "https://github.com/instructor-ai/instructor-js/issues"
4348
},
44-
"homepage": "https://github.com/jxnl/instructor-js#readme",
49+
"homepage": "https://github.com/instructor-ai/instructor-js#readme",
4550
"dependencies": {
4651
"schema-stream": "1.6.0",
4752
"zod-to-json-schema": "^3.22.3",

src/instructor.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,25 @@ class Instructor {
246246
response_model,
247247
...params
248248
}: ChatCompletionCreateParamsWithModel<T>): ChatCompletionCreateParams => {
249-
const jsonSchema = zodToJsonSchema(response_model.schema, {
250-
name: "response_model",
249+
const { schema, name = "response_model", description } = response_model
250+
const safeName = name.replace(/[^a-zA-Z0-9]/g, "_").replace(/\s/g, "_")
251+
252+
const { definitions } = zodToJsonSchema(schema, {
253+
name: safeName,
251254
errorMessages: true
252255
})
253256

254-
this.log("JSON Schema from zod: ", jsonSchema)
257+
if (!definitions || !definitions?.[safeName]) {
258+
console.warn("Could not extract json schema definitions from your schema", schema)
259+
throw new Error("Could not extract json schema definitions from your schema")
260+
}
261+
262+
this.log("JSON Schema from zod: ", definitions)
255263

256264
const definition = {
257-
name: "response_model",
258-
...jsonSchema.definitions?.response_model
265+
name: safeName,
266+
description,
267+
...definitions[safeName]
259268
}
260269

261270
const paramsForMode = MODE_TO_PARAMS[this.mode](definition, params, this.mode)

src/oai/params.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function OAIBuildFunctionParams(definition, params) {
1515
{
1616
name: name,
1717
description: description ?? undefined,
18-
paramaters: definitionParams
18+
parameters: definitionParams
1919
}
2020
]
2121
}
@@ -52,7 +52,7 @@ export function OAIBuildMessageBasedParams(definition, params, mode) {
5252
[MODE.JSON_SCHEMA]: {
5353
response_format: {
5454
type: "json_object",
55-
schema: omit(["name"], definition)
55+
schema: omit(["name", "description"], definition)
5656
}
5757
}
5858
}
@@ -68,7 +68,7 @@ export function OAIBuildMessageBasedParams(definition, params, mode) {
6868
role: "system",
6969
content: `
7070
Given a user prompt, you will return fully valid JSON based on the following description and schema.
71-
You will return no other prose. You will take into account any descriptions or required paramaters within the schema
71+
You will return no other prose. You will take into account any descriptions or required parameters within the schema
7272
and return a valid and fully escaped JSON object that matches the schema and those instructions.
7373
7474
description: ${definition?.description}

tests/mode.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { MODE } from "@/constants/modes"
77

88
const models_latest = ["gpt-3.5-turbo-1106", "gpt-4-1106-preview"]
99
const models_old = ["gpt-3.5-turbo", "gpt-4"]
10-
const models_anyscale = ["mistralai/Mixtral-8x7B-Instruct-v0.1"]
10+
const models_anyscale = ["Open-Orca/Mistral-7B-OpenOrca"]
1111

1212
const createTestCases = (): { model: string; mode: MODE }[] => {
1313
const { FUNCTIONS, JSON_SCHEMA, ...rest } = MODE

0 commit comments

Comments
 (0)