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

TypeError: replicate_1.default is not a constructor #161

Closed
fedikan opened this issue Nov 17, 2023 · 5 comments
Closed

TypeError: replicate_1.default is not a constructor #161

fedikan opened this issue Nov 17, 2023 · 5 comments

Comments

@fedikan
Copy link

fedikan commented Nov 17, 2023

I've just downloaded your client, and wanted to do some cool AI generations, but seems like it's not possible right now :(
My replicate module version is replicate@0.21.1
Some code example:

import Replicate from "replicate";


import { GeneratedImageResponse } from 'src/types/generated.image.response';
import { IImageGenerator } from './interfaces';

export const ReplicateID = {
  'stable_diffusion_infinite_zoom': 'arielreplicate/stable_diffusion_infinite_zoom:a2527c5074fc0cf9fa6015a40d75d080d1ddf7082fabe142f1ccd882c18fce61'
}

export class ReplicateService implements IImageGenerator {

  constructor() {
    const replicate = new Replicate({
      auth: process.env.REPLICATE_API_TOKEN,
    });

    this.replicate = replicate;
  }
  private replicate

  async generateImage(config: any, model): Promise<GeneratedImageResponse> {
    const output = await this.replicate.run(
      ReplicateID[model],
      {
        input: {
          prompt: config.prompt
        }
      }
    );
    return output
  }
}
@mattt
Copy link
Member

mattt commented Nov 17, 2023

Hi @fedikan. It looks like you're running into an issue with ES modules. If you're using from TypeScript, try adding "esModuleInterop": true to your tsconfig.json file. If that's not the case or doesn't resolve your issue, can you share more information about your project structure?

@fedikan
Copy link
Author

fedikan commented Nov 17, 2023

Hi @fedikan. It looks like you're running into an issue with ES modules. If you're using from TypeScript, try adding "esModuleInterop": true to your tsconfig.json file. If that's not the case or doesn't resolve your issue, can you share more information about your project structure?

It worked, thank you for quick reply <3

@mattt
Copy link
Member

mattt commented Nov 17, 2023

So glad to hear it, @fedikan. Happy hacking!

@davidnjagah
Copy link

@mattt i'm also experiencing the same issue and i've added "esModuleInterop": true to my tsconfig.json

@mattt
Copy link
Member

mattt commented Jan 8, 2024

@davidnjagah Sorry to hear that. Please open a new issue with some details about your project, and I'll do my best to help.

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

No branches or pull requests

3 participants