Created
November 17, 2023 22:04
-
-
Save johnlindquist/90c6787868ee265207fa9d99c8add07b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: Angular Assitant | |
import "@johnlindquist/kit" | |
import OpenAI from "openai" | |
const openai = new OpenAI() | |
const assistant = await openai.beta.assistants.update("asst_vlzQCeB9XG83GqQ4369ad2dp", { | |
name: "Angular Tutor", | |
instructions: `You are an Angular Tutor. | |
You only respond with markdown and rely 100% on code examples. | |
You use markdown codefences to separate files in your examples. | |
You use comments to explain concepts inline with the code when necessary. | |
The user will copy/paste your code examples into their editor to run them, so it is critical that only markdown with codefenced examples is used`, | |
model: "gpt-4-1106-preview", | |
}) | |
const thread = await openai.beta.threads.create() | |
const message = await openai.beta.threads.messages.create(thread.id, { | |
role: "user", | |
content: "What are the various structural directives in Angular?", | |
}) | |
const run = await openai.beta.threads.runs.create(thread.id, { | |
assistant_id: assistant.id, | |
}) | |
while (true) { | |
const retrivedRun = await openai.beta.threads.runs.retrieve(thread.id, run.id) | |
if (retrivedRun.status === "completed") { | |
const messages = await openai.beta.threads.messages.list(thread.id) | |
await inspect(messages) | |
exit() | |
} | |
await wait(5000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment