yihong0618 / bilingual_book_maker

Make bilingual epub books Using AI translate
MIT License
6.91k stars 1k forks source link

Add a model named "openai" and "--model_list" option #392

Closed TimelyToga closed 3 months ago

TimelyToga commented 3 months ago

This is in response to https://github.com/yihong0618/bilingual_book_maker/issues/390.

Solution

# Specific model 
--model openai --model_list gpt-4-1106-preview
# Multiple models 
--model openai --model_list gpt-4-1106-preview,gpt-3.5-turbo-0125

Currently this openai model alias is only for this behavior, but I think it should be expanded to be the defacto way to use the OpenAI API. The current approach is a bit messy because chatgptapi and gpt-4 are two separate top-level models.

I opted to add a new model to preserve backwards compatibility, but also paves a path for future CLI improvements.

Edge cases

No --model_list with openai:

image

First model is not valid

image

We should probably include some automatic checking to make sure all the models you specify are valid, but since we're using cycle(), this failure should be found within the first N paragraphs.

yihong0618 commented 3 months ago

nice and clean code, thanks very much. will check tonight (utc+8)

TimelyToga commented 3 months ago

I just noticed there are some issues with unnecessary whitespace changes in README. Let me fix that.

yihong0618 commented 3 months ago

very nice solution and did not make any break change, I think with your solution we had support openai like api like grog or others.

image

TimelyToga commented 3 months ago

@yihong0618 wow that's cool! Didn't even realize you had that feature. Thanks for the merge.

rafaelobo commented 2 months ago

Can someone upload an example of using with Groq and Llama3? I would be thankful.

yihong0618 commented 2 months ago

Can someone upload an example of using with Groq and Llama3? I would be thankful.

OK