groq / groq-typescript

The official Node.js / Typescript library for the Groq API
Apache License 2.0
145 stars 17 forks source link

Unable to access `CompletionCreateParams` from `Groq.Chat.CompletionCreateParams` #6

Closed bracesproul closed 6 months ago

bracesproul commented 6 months ago

When trying to access Groq.Chat.CompletionCreateParams or Groq.Chat.Completions.CompletionCreateParams (which my VSCode auto complete suggests as valid imports) I get the following error:

Namespace '"/Users/bracesproul/code/lang-chain-ai/langchainjs/node_modules/groq-sdk/resources/chat/chat".Chat' has no exported member 'CompletionCreateParams'.ts(2694)

TSConfig

groq-sdk version: 0.2.1 (latest)

Is there a different recommended way to access this interface?

hozen-groq commented 6 months ago

Hi, Brace! Thanks for reaching out. Could you please try again with groq-sdk version 0.3.0?

bracesproul commented 6 months ago

Hi, Brace! Thanks for reaching out. Could you please try again with groq-sdk version 0.3.0?

still getting the same error :(

dackerman commented 6 months ago

Hi @bracesproul - if you're looking to implement an interface, then Groq.Chat.CompletionCreateParams is a namespace, not an interface. Maybe you mean Groq.Chat.CompletionCreateParams.Message (which is an interface)?

something like:

class MyParams implements Groq.Chat.CompletionCreateParams.Message {
  get role() {
    return 'somerole';
  }
  get content() {
    return 'somecontent';
  }
}

If you want just the type of the whole params object, that would be ChatCompletionCreateParams which you can import like so:

import { ChatCompletionCreateParams } from 'groq-sdk/resources/chat/completions';

function makeParams(): ChatCompletionCreateParams {...}

It might help to look at completions.ts to see how these things are defined more clearly. Does that help?

bracesproul commented 6 months ago

Hi @bracesproul - if you're looking to implement an interface, then Groq.Chat.CompletionCreateParams is a namespace, not an interface. Maybe you mean Groq.Chat.CompletionCreateParams.Message (which is an interface)?

something like:

class MyParams implements Groq.Chat.CompletionCreateParams.Message {
  get role() {
    return 'somerole';
  }
  get content() {
    return 'somecontent';
  }
}

If you want just the type of the whole params object, that would be ChatCompletionCreateParams which you can import like so:

import { ChatCompletionCreateParams } from 'groq-sdk/resources/chat/completions';

function makeParams(): ChatCompletionCreateParams {...}

It might help to look at completions.ts to see how these things are defined more clearly. Does that help?

Importing from the path you listed fixed it, I appreciate it!

oeyoews commented 5 months ago

I'm troubled by the same problem. I think this can be temporarily updated to the readme.