mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
support system meesage in environment variable (#144)
* support config tags to translate * support system meesage in envirment
This commit is contained in:
parent
aaa1ab4d7b
commit
c0b3e0c2d5
@ -1,6 +1,7 @@
|
||||
import time
|
||||
|
||||
import openai
|
||||
from os import environ
|
||||
|
||||
from .base_translator import Base
|
||||
|
||||
@ -20,10 +21,14 @@ class ChatGPTAPI(Base):
|
||||
completion = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": environ.get("OPENAI_API_SYS_MSG"),
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"Please help me to translate,`{text}` to {self.language}, please return only translated content not include the origin text",
|
||||
}
|
||||
},
|
||||
],
|
||||
)
|
||||
t_text = (
|
||||
|
Loading…
x
Reference in New Issue
Block a user