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

Create export for WebSocket on Deno/JSR #1269

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kwhinnery-openai
Copy link

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

  • Need to export WebSocket client for JSR / Deno!

Additional context & links

https://jsr.io/docs/package-configuration#exports

@kwhinnery-openai kwhinnery-openai requested a review from a team as a code owner January 17, 2025 21:12
@kwhinnery-openai
Copy link
Author

This should work but currently does not - this PR should fix.

// import { OpenAIRealtimeWebSocket } from "openai/beta/realtime/websocket";
import { OpenAIRealtimeWebSocket } from "jsr:@openai/openai/beta/realtime/websocket";

const rt = new OpenAIRealtimeWebSocket({
  model: "gpt-4o-realtime-preview-2024-12-17",
});

rt.socket.addEventListener("open", () => {
  rt.send({ type: "session.update", session: { modalities: ["text"] } });

  rt.send({
    type: "conversation.item.create",
    item: {
      type: "message",
      role: "user",
      content: [{
        type: "input_text",
        text: "Tell me a three sentence bedtime story about a unicorn.",
      }],
    },
  });

  rt.send({ type: "response.create" });
});

rt.on("response.text.delta", (event) => process.stdout.write(event.delta));
rt.on("response.done", () => rt.close());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants