Explorar el Código

Fix:local variable 'response' referenced before assignment (#9230)

### What problem does this PR solve?

https://github.com/infiniflow/ragflow/issues/9227

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---------

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
tags/v0.20.1
Stephen Hu hace 2 meses
padre
commit
1deb0a2d42
No account linked to committer's email address
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5
    2
      rag/llm/cv_model.py

+ 5
- 2
rag/llm/cv_model.py Ver fichero

@@ -522,6 +522,7 @@ class GeminiCV(Base):
def chat_streamly(self, system, history, gen_conf, images=[]):
from transformers import GenerationConfig
ans = ""
response = None
try:
response = self.model.generate_content(
self._form_history(system, history, images),
@@ -537,8 +538,10 @@ class GeminiCV(Base):
except Exception as e:
yield ans + "\n**ERROR**: " + str(e)

yield response._chunks[-1].usage_metadata.total_token_count

if response and hasattr(response, "usage_metadata") and hasattr(response.usage_metadata, "total_token_count"):
yield response.usage_metadata.total_token_count
else:
yield 0

class NvidiaCV(Base):
_FACTORY_NAME = "NVIDIA"

Cargando…
Cancelar
Guardar