mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: Gemini parameters error (#9520)
### What problem does this PR solve? Fix Gemini parameters error. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
@ -1146,60 +1146,35 @@
|
|||||||
"llm_name": "gemini-2.5-flash",
|
"llm_name": "gemini-2.5-flash",
|
||||||
"tags": "LLM,CHAT,1024K,IMAGE2TEXT",
|
"tags": "LLM,CHAT,1024K,IMAGE2TEXT",
|
||||||
"max_tokens": 1048576,
|
"max_tokens": 1048576,
|
||||||
"model_type": "image2text",
|
"model_type": "chat",
|
||||||
"is_tools": true
|
"is_tools": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"llm_name": "gemini-2.5-pro",
|
"llm_name": "gemini-2.5-pro",
|
||||||
"tags": "LLM,CHAT,IMAGE2TEXT,1024K",
|
"tags": "LLM,CHAT,IMAGE2TEXT,1024K",
|
||||||
"max_tokens": 1048576,
|
"max_tokens": 1048576,
|
||||||
"model_type": "image2text",
|
"model_type": "chat",
|
||||||
"is_tools": true
|
"is_tools": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"llm_name": "gemini-2.5-flash-preview-05-20",
|
"llm_name": "gemini-2.5-flash-lite",
|
||||||
"tags": "LLM,CHAT,1024K,IMAGE2TEXT",
|
"tags": "LLM,CHAT,1024K,IMAGE2TEXT",
|
||||||
"max_tokens": 1048576,
|
"max_tokens": 1048576,
|
||||||
"model_type": "image2text",
|
"model_type": "chat",
|
||||||
"is_tools": true
|
"is_tools": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"llm_name": "gemini-2.0-flash-001",
|
"llm_name": "gemini-2.0-flash",
|
||||||
"tags": "LLM,CHAT,1024K",
|
|
||||||
"max_tokens": 1048576,
|
|
||||||
"model_type": "image2text",
|
|
||||||
"is_tools": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"llm_name": "gemini-2.0-flash-thinking-exp-01-21",
|
|
||||||
"tags": "LLM,CHAT,1024K",
|
"tags": "LLM,CHAT,1024K",
|
||||||
"max_tokens": 1048576,
|
"max_tokens": 1048576,
|
||||||
"model_type": "chat",
|
"model_type": "chat",
|
||||||
"is_tools": true
|
"is_tools": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"llm_name": "gemini-1.5-flash",
|
"llm_name": "gemini-2.0-flash-lite",
|
||||||
"tags": "LLM,IMAGE2TEXT,1024K",
|
"tags": "LLM,CHAT,1024K",
|
||||||
"max_tokens": 1048576,
|
"max_tokens": 1048576,
|
||||||
"model_type": "image2text"
|
"model_type": "chat",
|
||||||
},
|
|
||||||
{
|
|
||||||
"llm_name": "gemini-2.5-pro-preview-05-06",
|
|
||||||
"tags": "LLM,IMAGE2TEXT,1024K",
|
|
||||||
"max_tokens": 1048576,
|
|
||||||
"model_type": "image2text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"llm_name": "gemini-1.5-pro",
|
|
||||||
"tags": "LLM,IMAGE2TEXT,2048K",
|
|
||||||
"max_tokens": 2097152,
|
|
||||||
"model_type": "image2text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"llm_name": "gemini-1.5-flash-8b",
|
|
||||||
"tags": "LLM,IMAGE2TEXT,1024K",
|
|
||||||
"max_tokens": 1048576,
|
|
||||||
"model_type": "image2text",
|
|
||||||
"is_tools": true
|
"is_tools": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@ -539,24 +539,24 @@ class GeminiCV(Base):
|
|||||||
return res.text, res.usage_metadata.total_token_count
|
return res.text, res.usage_metadata.total_token_count
|
||||||
|
|
||||||
def chat(self, system, history, gen_conf, images=[]):
|
def chat(self, system, history, gen_conf, images=[]):
|
||||||
from transformers import GenerationConfig
|
generation_config = dict(temperature=gen_conf.get("temperature", 0.3), top_p=gen_conf.get("top_p", 0.7))
|
||||||
try:
|
try:
|
||||||
response = self.model.generate_content(
|
response = self.model.generate_content(
|
||||||
self._form_history(system, history, images),
|
self._form_history(system, history, images),
|
||||||
generation_config=GenerationConfig(temperature=gen_conf.get("temperature", 0.3), top_p=gen_conf.get("top_p", 0.7)))
|
generation_config=generation_config)
|
||||||
ans = response.text
|
ans = response.text
|
||||||
return ans, response.usage_metadata.total_token_count
|
return ans, response.usage_metadata.total_token_count
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "**ERROR**: " + str(e), 0
|
return "**ERROR**: " + str(e), 0
|
||||||
|
|
||||||
def chat_streamly(self, system, history, gen_conf, images=[]):
|
def chat_streamly(self, system, history, gen_conf, images=[]):
|
||||||
from transformers import GenerationConfig
|
|
||||||
ans = ""
|
ans = ""
|
||||||
response = None
|
response = None
|
||||||
try:
|
try:
|
||||||
|
generation_config = dict(temperature=gen_conf.get("temperature", 0.3), top_p=gen_conf.get("top_p", 0.7))
|
||||||
response = self.model.generate_content(
|
response = self.model.generate_content(
|
||||||
self._form_history(system, history, images),
|
self._form_history(system, history, images),
|
||||||
generation_config=GenerationConfig(temperature=gen_conf.get("temperature", 0.3), top_p=gen_conf.get("top_p", 0.7)),
|
generation_config=generation_config,
|
||||||
stream=True,
|
stream=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -572,7 +572,7 @@ class GeminiCV(Base):
|
|||||||
yield response.usage_metadata.total_token_count
|
yield response.usage_metadata.total_token_count
|
||||||
else:
|
else:
|
||||||
yield 0
|
yield 0
|
||||||
|
|
||||||
|
|
||||||
class NvidiaCV(Base):
|
class NvidiaCV(Base):
|
||||||
_FACTORY_NAME = "NVIDIA"
|
_FACTORY_NAME = "NVIDIA"
|
||||||
|
|||||||
Reference in New Issue
Block a user