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

[JS] dotprompt .generate and .render methods don't allow custom config options #757

Closed
pavelgj opened this issue Aug 7, 2024 · 1 comment
Assignees
Labels
bug Something isn't working js

Comments

@pavelgj
Copy link
Collaborator

pavelgj commented Aug 7, 2024

Describe the bug

this code does not compile:

    const resp = await dotpromptPrompt.render({
      model: 'vertexai/gemini-1.5-flash',
      input: {
        foo: 'bar',
      },
      config: {
        location: 'us-central1',
      },
    });

Error:

Object literal may only specify known properties, and 'customOption' does not exist in type '{ version?: string | undefined; temperature?: number | undefined; maxOutputTokens?: number | undefined; topK?: number | undefined; topP?: number | undefined; stopSequences?: string[] | undefined; }'.ts(2353)

generate.d.ts(261, 5): The expected type comes from property 'config' which is declared here on type 'PromptGenerateOptions<any>'

Most Vertex AI models have support passing location as a config option.

Known workaround

    const req = await dotpromptPrompt.render({
      model: 'vertexai/gemini-1.5-flash',
      input: {
        foo: 'bar',
      },
    });
    req.config = {
      location:  'us-central1',
    };
    const resp = await generate(req);
@pavelgj pavelgj added bug Something isn't working js labels Aug 7, 2024
@maxl0rd maxl0rd self-assigned this Aug 12, 2024
@maxl0rd
Copy link
Contributor

maxl0rd commented Aug 14, 2024

I looked into this a bit. It's not possible to identify the correct custom options type if we accept string model arguments, so it should be any in that case. But we can make it check the custom options type strictly if a fully qualified model is also passed in to render or generate.

image

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

No branches or pull requests

2 participants