Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: OpenAI Assistants API #299

Open
michael-hhai opened this issue Jun 6, 2024 · 6 comments
Open

Feature: OpenAI Assistants API #299

michael-hhai opened this issue Jun 6, 2024 · 6 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@michael-hhai
Copy link

The instrumentation-openai package should be able to capture calls to the OpenAI Assistants API. Specifically, it should be able to trace this program taken from the linked quickstart documentation:

import OpenAI from "openai";
const openai = new OpenAI({ apiKey: OPENAI_KEY });

async function main() {
  const assistant = await openai.beta.assistants.create({
    name: "Math Tutor",
    instructions: "You are a personal math tutor. Write and run code to answer math questions.",
    tools: [{ type: "code_interpreter" }],
    model: "gpt-4o"
  });
  const thread = await openai.beta.threads.create();
  const message = await openai.beta.threads.messages.create(
    thread.id,
    {
      role: "user",
      content: "I need to solve the equation `3x + 11 = 14`. Can you help me?"
    }
  );
  let run = await openai.beta.threads.runs.createAndPoll(
    thread.id,
    {
      assistant_id: assistant.id,
      instructions: "Please address the user as Jane Doe. The user has a premium account."
    }
  );
  if (run.status === 'completed') {
    const messages = await openai.beta.threads.messages.list(
      run.thread_id
    );
    for (const message of messages.data.reverse()) {
      console.log(`${message.role} > ${message.content[0].text.value}`);
    }
  } else {
    console.log(run.status);
  }
}

main();
@nirga
Copy link
Member

nirga commented Jun 6, 2024

Yes @michael-hhai! Do you plan on working on this?

@michael-hhai
Copy link
Author

Not immediately, which is why I made the issue instead of a PR. I should be able to get around to it soon-ish. If I'm not able to get to this within a week, then I'll update this issue.

@nirga nirga added good first issue Good for newcomers help wanted Extra attention is needed labels Jun 6, 2024
@nirga
Copy link
Member

nirga commented Jun 6, 2024

Great @michael-hhai, I'll post it on slack as well maybe someone will want it

@michael-hhai
Copy link
Author

To be clear, if someone else wants to grab this then they can be my guest.

@vr-varad
Copy link

hey @nirga @michael-hhai I would like to work on this.

@nirga
Copy link
Member

nirga commented Aug 16, 2024

Yes please @vr-varad go ahead!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants