mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
feat: add support for --temperature option to gemini
This commit is contained in:
parent
b07e8f2e10
commit
696ea341b5
@ -290,7 +290,7 @@ So you are close to reaching the limit. You have to choose your own value, there
|
|||||||
"--temperature",
|
"--temperature",
|
||||||
type=float,
|
type=float,
|
||||||
default=1.0,
|
default=1.0,
|
||||||
help="temperature parameter for `chatgptapi`/`gpt4`/`claude`",
|
help="temperature parameter for `chatgptapi`/`gpt4`/`claude`/`gemini`",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--block_size",
|
"--block_size",
|
||||||
|
@ -11,7 +11,7 @@ from rich import print
|
|||||||
from .base_translator import Base
|
from .base_translator import Base
|
||||||
|
|
||||||
generation_config = {
|
generation_config = {
|
||||||
"temperature": 0.7,
|
"temperature": 1.0,
|
||||||
"top_p": 1,
|
"top_p": 1,
|
||||||
"top_k": 1,
|
"top_k": 1,
|
||||||
"max_output_tokens": 2048,
|
"max_output_tokens": 2048,
|
||||||
@ -38,9 +38,15 @@ class Gemini(Base):
|
|||||||
|
|
||||||
DEFAULT_PROMPT = "Please help me to translate,`{text}` to {language}, please return only translated content not include the origin text"
|
DEFAULT_PROMPT = "Please help me to translate,`{text}` to {language}, please return only translated content not include the origin text"
|
||||||
|
|
||||||
def __init__(self, key, language, **kwargs) -> None:
|
def __init__(
|
||||||
genai.configure(api_key=key)
|
self,
|
||||||
|
key,
|
||||||
|
language,
|
||||||
|
temperature=1.0,
|
||||||
|
**kwargs,
|
||||||
|
) -> None:
|
||||||
super().__init__(key, language)
|
super().__init__(key, language)
|
||||||
|
generation_config["temperature"] = temperature
|
||||||
model = genai.GenerativeModel(
|
model = genai.GenerativeModel(
|
||||||
model_name="gemini-pro",
|
model_name="gemini-pro",
|
||||||
generation_config=generation_config,
|
generation_config=generation_config,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user