Public
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.
Learn more