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

♻️ refactor: refactor the text to image #4272

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/services/_url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const API_ENDPOINTS = mapWithBasePath({
trace: '/webapi/trace',

// image
images: '/webapi/text-to-image/openai',
images: (provider: string) => `/webapi/text-to-image/${provider}`,

// STT
stt: '/webapi/stt/openai',
Expand Down
6 changes: 4 additions & 2 deletions src/services/textToImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ class ImageGenerationService {
async generateImage(params: Omit<OpenAIImagePayload, 'model' | 'n'>, options?: FetchOptions) {
const payload: OpenAIImagePayload = { ...params, model: 'dall-e-3', n: 1 };

const provider = ModelProvider.OpenAI;

const headers = await createHeaderWithAuth({
headers: { 'Content-Type': 'application/json' },
provider: ModelProvider.OpenAI,
provider,
});

const res = await fetch(API_ENDPOINTS.images, {
const res = await fetch(API_ENDPOINTS.images(provider), {
body: JSON.stringify(payload),
headers: headers,
method: 'POST',
Expand Down
Loading