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

No way to import types with Deno #477

Closed
1 task done
ChuckJonas opened this issue Nov 9, 2023 · 6 comments
Closed
1 task done

No way to import types with Deno #477

ChuckJonas opened this issue Nov 9, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@ChuckJonas
Copy link

Confirm this is a Node library issue and not an underlying OpenAI API issue

  • This is an issue with the Node library

Describe the bug

Based on the docs, this library exposes the Request/Response types via the "default" namespace.

However, if I try to use the imports in my code, I get an error: Identifier expected.

chatCompletion_ts_—_ccc-private-gpt

I'm not 100% but it seems like maybe this is a reserved keyword that Deno doesn't support having as a namespace?

To Reproduce

  1. create deno project
  2. install v4.16.1
  3. add this code:
import { type default } from "https://deno.land/x/openai@v4.16.1/mod.ts";
const { ChatCompletion } = default;

Code Sandbox Link (you might have to start typing to see error)

Code snippets

No response

OS

osx

Node version

deno 1.38.0

Library version

v4.16.1

@ChuckJonas ChuckJonas added the bug Something isn't working label Nov 9, 2023
@ChuckJonas
Copy link
Author

Looks like the deno docs were just throwing me off.

You can import types like so:

import OpenAI from "openai";
export type ChatCompletion = OpenAI.Chat.Completions.ChatCompletion;
export type ChatCompletionOptions =
  OpenAI.Chat.Completions.ChatCompletionCreateParams;

@rattrayalex
Copy link
Collaborator

Glad you figured this out!

Looks like the deno docs were just throwing me off.

OOC, which deno docs are you referring to?

@ChuckJonas
Copy link
Author

ChuckJonas commented Nov 10, 2023

@rattrayalex these docs that I assume are autogenerated via static analysis by deno?

default_ChatCompletion____mod_ts___openai_v4_16_1___Deno

Trying to assign the type to a const should have been enough to realize there's something wrong, but I somehow missed that...

@rattrayalex
Copy link
Collaborator

rattrayalex commented Nov 10, 2023

Ah, I see, thank you for sharing that – I wasn't aware Deno generated docs like that. I'll see if there's something to be done about that.

EDIT: I've filed denoland/website_feedback#53

@ChuckJonas
Copy link
Author

oh, I also opened a ticket but on the deno_doc repo: denoland/deno_doc#395

I'm actually not sure this is actually the related repo though...

@rattrayalex
Copy link
Collaborator

Ah, yours is more likely to be the correct location, well done. Added a pointer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants