Fix api reference empty bug (#1655)

### What problem does this PR solve?

fix api reference empty bug
```
for chunk_i in answer['reference'].get('chunks',[]):
                   ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'list' object has no attribute 'get'
```
```
return np.array([d["relevance_score"] for d in res["results"]]), res["meta"]["tokens"]["input_tokens"]+res["meta"]["tokens"]["output_tokens"]
                                                   ~~~^^^^^^^^^^^
KeyError: 'results'
```
### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kung Quang
2024-07-24 18:02:22 +08:00
committed by GitHub
parent f4d182e4ee
commit 32d5885b68
2 changed files with 9 additions and 7 deletions

View File

@ -147,6 +147,8 @@ class XInferenceRerank(Base):
}
def similarity(self, query: str, texts: list):
if len(texts) == 0:
return np.array([]), 0
data = {
"model": self.model_name,
"query": query,