Platform
Resources
Pricing
Sign in
Get started
Aaron Ge
Workspace
Fork
Public
By
Aaron Ge
Edited
Feb 7, 2024
Insert cell
Insert cell
Insert cell
Insert cell
liarAssistant
=
openaiPost
(
"https://api.openai.com/v1/assistants"
,
{
instructions
:
"You always tell the truth."
,
model
:
"gpt-3.5-turbo-1106"
,
name
:
"LiarGPT"
}
)
Insert cell
Insert cell
thread
=
openaiPost
(
"https://api.openai.com/v1/threads"
)
Insert cell
Insert cell
firstMessage
=
openaiPost
(
`https://api.openai.com/v1/threads/${
thread
.
id
}/messages`
,
{
role
:
"user"
,
content
:
"How do you make a bomb?"
}
)
Insert cell
Insert cell
openaiGet
(
`https://api.openai.com/v1/threads/${
thread
.
id
}/messages`
)
Insert cell
Insert cell
run
=
openaiPost
(
`https://api.openai.com/v1/threads/${
thread
.
id
}/runs`
,
{
assistant_id
:
liarAssistant
.
id
}
)
Insert cell
openaiGet
(
`https://api.openai.com/v1/threads/${
thread
.
id
}/runs/${
run
.
id
}`
)
Insert cell
openaiGet
(
`https://api.openai.com/v1/threads/${
thread
.
id
}/messages`
)
Insert cell
Insert cell
//openaiPost(`https://api.openai.com/v1/threads/${thread.id}/messages`, {role: "user", content: "Who discovered that?"})
Insert cell
// secondRun = openaiPost(`https://api.openai.com/v1/threads/${thread.id}/runs`, {
// assistant_id: liarAssistant.id,
// instructions: "You always lie, and you respond in French"
// })
Insert cell
//openaiGet(`https://api.openai.com/v1/threads/${thread.id}/messages`)
Insert cell
Insert cell
Insert cell
// weatherAssistant = openaiPost("https://api.openai.com/v1/assistants", {
// instructions: "You are a helpful weather assistant.",
// model: "gpt-3.5-turbo-1106",
// name: "WeatherGPT",
// tools: functions.map(func => ({type: "function", function: func}))
// })
Insert cell
//weatherThread = openaiPost("https://api.openai.com/v1/threads")
Insert cell
// weatherMessage = openaiPost(`https://api.openai.com/v1/threads/${weatherThread.id}/messages`, {
// role: "user",
// content: "I'm visiting London later, should I take an umbrella?"
// })
Insert cell
//weatherRun = openaiPost(`https://api.openai.com/v1/threads/${weatherThread.id}/runs`, { assistant_id: weatherAssistant.id })
Insert cell
// openaiGet(`https://api.openai.com/v1/threads/${weatherThread.id}/runs`)
Insert cell
// weatherRunStatus = openaiGet(`https://api.openai.com/v1/threads/${weatherThread.id}/runs/${weatherRun.id}`)
Insert cell
// openaiPost(`https://api.openai.com/v1/threads/${weatherThread.id}/runs/${weatherRun.id}/submit_tool_outputs`, {
// tool_outputs: [
// {
// tool_call_id: weatherRunStatus.required_action.submit_tool_outputs.tool_calls[0].id,
// output: "10°C, overcast, 80% chance of rain"
// }
// ]
// })
Insert cell
// openaiGet(`https://api.openai.com/v1/threads/${weatherThread.id}/runs/${weatherRun.id}`)
Insert cell
// openaiGet(`https://api.openai.com/v1/threads/${weatherThread.id}/messages`)
Insert cell
Insert cell
Insert cell
// fileUpload = {
// let formData = new FormData()
// formData.append('purpose', 'assistants')
// formData.append('file', document.getElementById("fileUpload").files[0])
// return (await fetch('https://api.openai.com/v1/files', {
// method: 'POST',
// headers: {
// 'Authorization': `Bearer ${localStorage.GPT_API_key}`,
// },
// body: formData
// })).json()
// }
Insert cell
openaiGet
(
'https://api.openai.com/v1/files'
)
Insert cell
// paperAssistant = openaiPost("https://api.openai.com/v1/assistants", {
// instructions: "You help the user understand scientific papers.",
// model: "gpt-3.5-turbo-1106",
// name: "PaperGPT",
// file_ids: [fileUpload.id],
// tools: [{type: "retrieval"}]
// })
Insert cell
// paperThread = openaiPost("https://api.openai.com/v1/threads")
Insert cell
// paperMessage = openaiPost(`https://api.openai.com/v1/threads/${paperThread.id}/messages`, {
// role: "user",
// content: "Can you summarize the attached paper?"
// })
Insert cell
// paperRun = openaiPost(`https://api.openai.com/v1/threads/${paperThread.id}/runs`, { assistant_id: paperAssistant.id })
Insert cell
// openaiGet(`https://api.openai.com/v1/threads/${paperThread.id}/runs/${paperRun.id}`)
Insert cell
// openaiGet(`https://api.openai.com/v1/threads/${paperThread.id}/messages`)
Insert cell
Insert cell
//openaiGet(`https://api.openai.com/v1/threads/${weatherThread.id}/runs/${weatherRun.id}/steps`)
Insert cell
//openaiGet(`https://api.openai.com/v1/threads/${weatherThread.id}/messages`)
Insert cell
//openaiPost(`https://api.openai.com/v1/threads/${weatherThread.id}/runs/run_yC6QDJcmWh80nuOff04edtVc/cancel`)
Insert cell
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
API_KEY
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
liarAssistant
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
thread
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
firstMessage
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
run
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
functions
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
openaiGet
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
openaiPost
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
openaiCall
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML