From 05298d56261094daed307d8d5fd9709ea699d091 Mon Sep 17 00:00:00 2001
From: KevinHuSh <kevinhu.sh@gmail.com>
Date: Fri, 29 Mar 2024 10:48:29 +0800
Subject: [PATCH] refine README (#169)

---
 README.md                         | 14 ++++++++++++++
 api/apps/llm_app.py               |  3 ++-
 api/db/services/common_service.py |  2 +-
 rag/nlp/query.py                  |  3 ++-
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index f346b6c..0d898e8 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,20 @@
 
 ## 🤺RagFlow vs. other RAG applications
 
+| Feature | RagFlow | Langchain-Chatchat | Dify.AI | Assistants API | QAnythig | LangChain |
+|---------|:---------:|:----------------:|:-----------:|:-----------:|:-----------:|:-----------:|
+| **Well-Founded Answer** | :white_check_mark: | :x: | :x: | :x: | :x: | :x: |
+| **Trackable Chunking** | :white_check_mark: | :x: | :x: | :x: | :x: | :x: |
+| **Chunking Method** | Rich Variety | Naive | Naive | Naive | Naive | Naive |
+| **Table Structure Recognition** | :white_check_mark: | :x: | :x: | :x: | :x: | :x: |
+| **Structured Data Lookup** | :white_check_mark: | :x: | :x: | :x: | :x: | :x: |
+| **Programming Approach** | API-oriented | API-oriented | API-oriented | API-oriented | API-oriented | Python Code-oriented |
+| **RAG Engine** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: |
+| **Prompt IDE** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: |
+| **Supported LLMs** | Rich Variety | Rich Variety | Rich Variety | OpenAI-only | QwenLLM | Rich Variety |
+| **Local Deployment** | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: | :x: |
+| **Ecosystem Strategy** | Open Source | Open Source | Open Source | Close Source | Open Source | Open Source |
+
 ## 🔎 System Architecture
 
 <div align="center" style="margin-top:20px;margin-bottom:20px;">
diff --git a/api/apps/llm_app.py b/api/apps/llm_app.py
index 25bcca2..e8d42a3 100644
--- a/api/apps/llm_app.py
+++ b/api/apps/llm_app.py
@@ -69,7 +69,8 @@ def set_api_key():
         return get_data_error_result(retmsg=msg)
 
     llm = {
-        "api_key": req["api_key"]
+        "api_key": req["api_key"],
+        "api_base": req.get("base_url", "")
     }
     for n in ["model_type", "llm_name"]:
         if n in req:
diff --git a/api/db/services/common_service.py b/api/db/services/common_service.py
index ad87d65..43e7c73 100644
--- a/api/db/services/common_service.py
+++ b/api/db/services/common_service.py
@@ -143,7 +143,7 @@ class CommonService:
     @DB.connection_context()
     def filter_update(cls, filters, update_data):
         with DB.atomic():
-            cls.model.update(update_data).where(*filters).execute()
+            return cls.model.update(update_data).where(*filters).execute()
 
     @staticmethod
     def cut_list(tar_list, n):
diff --git a/rag/nlp/query.py b/rag/nlp/query.py
index ea5b5cb..6a829a1 100644
--- a/rag/nlp/query.py
+++ b/rag/nlp/query.py
@@ -1,6 +1,7 @@
 # -*- coding: utf-8 -*-
 
 import json
+import math
 import re
 import logging
 import copy
@@ -167,4 +168,4 @@ class EsQueryer:
         #d = 1e-9
         # for k, v in dtwt.items():
         #    d += v * v
-        return s / q  # math.sqrt(q) / math.sqrt(d)
+        return s / q / max(1, math.sqrt(math.log10(max(len(qtwt.keys()), len(dtwt.keys())))))# math.sqrt(q) / math.sqrt(d)
-- 
GitLab