Skip to content

Commit

Permalink
♻️ refactor: refactor the text to image
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Oct 5, 2024
1 parent 0c32283 commit f0d0f6b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
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

0 comments on commit f0d0f6b

Please sign in to comment.