mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-05 19:15:34 +00:00
feat: add support for --use_context option to gemini
This commit is contained in:
parent
92cdadbfdf
commit
8dbefd6fc4
@ -59,11 +59,13 @@ class Gemini(Base):
|
|||||||
language,
|
language,
|
||||||
prompt_template=None,
|
prompt_template=None,
|
||||||
prompt_sys_msg=None,
|
prompt_sys_msg=None,
|
||||||
|
context_flag=False,
|
||||||
temperature=1.0,
|
temperature=1.0,
|
||||||
interval=0.01,
|
interval=0.01,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(key, language)
|
super().__init__(key, language)
|
||||||
|
self.context_flag = context_flag
|
||||||
self.interval = interval
|
self.interval = interval
|
||||||
self.prompt = (
|
self.prompt = (
|
||||||
prompt_template
|
prompt_template
|
||||||
@ -125,8 +127,12 @@ class Gemini(Base):
|
|||||||
print(str(e))
|
print(str(e))
|
||||||
t_text = "Can not translate by other reason.(因安全问题不能翻译)"
|
t_text = "Can not translate by other reason.(因安全问题不能翻译)"
|
||||||
|
|
||||||
if len(self.convo.history) > 10:
|
|
||||||
self.convo.history = self.convo.history[2:]
|
if self.context_flag:
|
||||||
|
if len(self.convo.history) > 10:
|
||||||
|
self.convo.history = self.convo.history[2:]
|
||||||
|
else:
|
||||||
|
self.convo.history = []
|
||||||
|
|
||||||
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
print("[bold green]" + re.sub("\n{3,}", "\n\n", t_text) + "[/bold green]")
|
||||||
# for rate limit(RPM)
|
# for rate limit(RPM)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user