-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
966491c
commit b59a0b1
Showing
5 changed files
with
169 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import OpenAI from 'openai'; | ||
|
||
const openai = new OpenAI(); | ||
|
||
export async function generateImage(prompt: string) { | ||
try { | ||
const imageResponse = await openai.images.generate({ | ||
model: 'dall-e-3', | ||
prompt: prompt, | ||
n: 1, | ||
size: '1024x1024', | ||
}); | ||
const imageUrl = imageResponse.data[0]?.url || ''; | ||
return imageUrl; | ||
} catch (error) { | ||
console.error('Error generating image:', error); | ||
throw error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { generateImage } from '../repository/stampRepository'; | ||
|
||
export async function generateImageUrl(input: string): Promise<string> { | ||
const template = | ||
'スタイルはキティちゃんのようにシンプルで愛らしいキャラクターのLINEスタンプを生成してください。ポーズはセリフに合わせて適切に変化させてください。セリフ:'; | ||
|
||
const prompt = template + input; | ||
|
||
const imageUrl = await generateImage(prompt); | ||
|
||
return imageUrl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters