Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
zcpua committed Jul 16, 2023
1 parent 258ef88 commit b9d81f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export class AppController {
res.raw.setHeader('Pragma', 'no-cache');
res.raw.setHeader('Expires', '0');

const msg = await this.MjService.Avatar(data.img, (uri: string) => {
res.raw.write(JSON.stringify({ uri }));
const msg = await this.MjService.Avatar(data.img, (uri, progress) => {
res.raw.write(JSON.stringify({ uri, progress }));
});
res.raw.write(JSON.stringify(msg));
res.raw.end();
Expand Down
6 changes: 3 additions & 3 deletions src/midjourney.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export class MidjourneyService implements OnModuleInit {
});
return msg;
}
async Avatar(img: string, loading?: (uri: string) => void) {
async Avatar(img: string, loading?: (uri: string, progress: string) => void) {
const blob = await base64ToBlob(img);
const desc = await this.Midjourney.DescribeByBlob(blob);
// const DcImage = await this.Midjourney.MJApi.UploadImageByBole(blob);
// const nonce = nextNonce();
// const httpStatus = await this.Midjourney.MJApi.DescribeApi(DcImage, nonce);
// desc.descriptions[0];
const prompt = `${desc.uri} half body, illustration for a children’s book, simple, cute, full-color, profile picture`;
const msg = await this.Midjourney.Imagine(prompt, (uri: string) => {
loading && loading(uri);
const msg = await this.Midjourney.Imagine(prompt, (uri, progress) => {
loading && loading(uri, progress);
});
return msg;
}
Expand Down

0 comments on commit b9d81f5

Please sign in to comment.