mdwiltfong / doc-inspector

1 stars 0 forks source link

Creating Runs - use `.create` or `.createAndRun`? #12

Open Jamesllllllllll opened 9 months ago

Jamesllllllllll commented 9 months ago

Hey, getting ready to work on setting up polling for runs and I came across this method - createThreadAndRun

It creates a thread and runs it in one request. Would this be easy to implement? I like it because the AI response would appear, showing the user another visual cue that they can start chatting.

mdwiltfong commented 9 months ago

Yeah I saw this after implementing the routes. Looking at the response though, I think the frontend still has to poll for the run status. So although this removes the need for an API route, does it do anything else?

{
  "id": "run_abc123",
  "object": "thread.run",
  "created_at": 1699076792,
  "assistant_id": "asst_abc123",
  "thread_id": "thread_abc123",
  "status": "queued",
  "started_at": null,
  "expires_at": 1699077392,
  "cancelled_at": null,
  "failed_at": null,
  "completed_at": null,
  "last_error": null,
  "model": "gpt-4",
  "instructions": "You are a helpful assistant.",
  "tools": [],
  "file_ids": [],
  "metadata": {}
}
Jamesllllllllll commented 9 months ago

I do like the idea of having the AI start the conversation once everything is ready (assistant crated, documents added, thread started). It's nice for UX to show that the user can start chatting.

mdwiltfong commented 9 months ago

Ah I see what you're saying. By using this route the AI can start the convo.

That's a nice-to-have. I think we can add that later if we finish early.

Jamesllllllllll commented 9 months ago

Sounds good!