Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tools description,修复tools中存在的不正确描述 #3596

Open
wants to merge 35 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e042a76
Add files via upload
imClumsyPanda Feb 1, 2024
4f67f4a
Update README.md
imClumsyPanda Feb 1, 2024
ab65025
Merge pull request #2946 from chatchat-space/dev
zRzRzRzRzRzRzR Feb 6, 2024
0522a42
Add files via upload
imClumsyPanda Feb 6, 2024
f75ae3e
Update README.md
imClumsyPanda Feb 6, 2024
cd13aee
Merge pull request #2958 from chatchat-space/dev
zRzRzRzRzRzRzR Feb 6, 2024
051c599
requirements_webui.txt (#2960)
wusongbai139 Feb 7, 2024
d5edb08
Add files via upload
imClumsyPanda Feb 19, 2024
b2fabe2
Update README.md
imClumsyPanda Feb 19, 2024
1fa714e
Update README.md
imClumsyPanda Feb 19, 2024
7c89f88
Add files via upload
imClumsyPanda Feb 21, 2024
fb8fbe9
Update README.md
imClumsyPanda Feb 21, 2024
cf1c853
Add files via upload
imClumsyPanda Feb 24, 2024
574ea4f
Update README.md
imClumsyPanda Feb 24, 2024
76e82a9
Add files via upload
imClumsyPanda Feb 28, 2024
caf502d
Update README.md
imClumsyPanda Feb 28, 2024
54bed50
Add files via upload
imClumsyPanda Mar 2, 2024
bab9369
Update README.md
imClumsyPanda Mar 2, 2024
e48f4a2
修复使用Milvus数据库时上传知识库文件报错的问题 (#3155)
hollowdjj Mar 6, 2024
f40d415
Add files via upload
imClumsyPanda Mar 6, 2024
021d635
Update README.md
imClumsyPanda Mar 6, 2024
cd54eeb
Add files via upload
imClumsyPanda Mar 12, 2024
d879e86
Update README.md
imClumsyPanda Mar 12, 2024
5ad4d52
Add files via upload
imClumsyPanda Mar 19, 2024
d78b147
Update README.md
imClumsyPanda Mar 19, 2024
07b7c96
Dev fix csv loader (#3404)
oslijunw Mar 20, 2024
253d4b9
修复使用pgvector时get_doc_by_ids方法报错的bug及知识库文件删除后向量仍然存在的bug (#3407)
liudichen Mar 20, 2024
825e497
Add files via upload
imClumsyPanda Mar 22, 2024
40263dd
Update README.md
imClumsyPanda Mar 22, 2024
bfb76fa
Add files via upload
imClumsyPanda Mar 26, 2024
966c582
Update README.md
imClumsyPanda Mar 26, 2024
78290d3
Update README.md
imClumsyPanda Mar 29, 2024
ae9f4d2
Add files via upload
imClumsyPanda Mar 29, 2024
4872352
Update README.md (#3585)
RoceoRobin Apr 1, 2024
665d007
修复tools中存在的不正确描述
rongchenlin Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
### ⚠️ 重要提示

`0.2.10`将会是`0.2.x`系列的最后一个版本,`0.2.x`系列版本将会停止更新和技术支持,全力研发具有更强应用性的 `Langchain-Chatchat 0.3.x`。
`0.2.10` 的后续 bug 修复将会直接推送到`master`分支,而不在进行版本更新
`0.2.10` 的后续 bug 修复将会直接推送到`master`分支,而不再进行版本更新

---

Expand Down Expand Up @@ -193,7 +193,7 @@ $ python startup.py -a
[![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white "langchain-chatglm")](https://t.me/+RjliQ3jnJ1YyN2E9)

### 项目交流群
<img src="img/qr_code_90.jpg" alt="二维码" width="300" />
<img src="img/qr_code_100.jpg" alt="二维码" width="300" />

🎉 Langchain-Chatchat 项目微信交流群,如果你也对本项目感兴趣,欢迎加入群聊参与讨论交流。

Expand Down
35 changes: 19 additions & 16 deletions document_loaders/FilteredCSVloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,26 @@ def __read_file(self, csvfile: TextIOWrapper) -> List[Document]:
docs = []
csv_reader = csv.DictReader(csvfile, **self.csv_args) # type: ignore
for i, row in enumerate(csv_reader):
if self.columns_to_read[0] in row:
content = row[self.columns_to_read[0]]
# Extract the source if available
source = (
row.get(self.source_column, None)
if self.source_column is not None
else self.file_path
)
metadata = {"source": source, "row": i}
content = []
for col in self.columns_to_read:
if col in row:
content.append(f'{col}:{str(row[col])}')
else:
raise ValueError(f"Column '{self.columns_to_read[0]}' not found in CSV file.")
content = '\n'.join(content)
# Extract the source if available
source = (
row.get(self.source_column, None)
if self.source_column is not None
else self.file_path
)
metadata = {"source": source, "row": i}

for col in self.metadata_columns:
if col in row:
metadata[col] = row[col]
for col in self.metadata_columns:
if col in row:
metadata[col] = row[col]

doc = Document(page_content=content, metadata=metadata)
docs.append(doc)
else:
raise ValueError(f"Column '{self.columns_to_read[0]}' not found in CSV file.")
doc = Document(page_content=content, metadata=metadata)
docs.append(doc)

return docs
Binary file added img/qr_code_100.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_90.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_91.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_92.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_93.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_94.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_95.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_96.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_97.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_98.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qr_code_99.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/qrcode_90_2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion requirements_webui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ streamlit-modal==0.1.0
streamlit-aggrid==0.3.4.post3
httpx==0.26.0
httpx_sse==0.4.0
watchdog=s=3.0.0
watchdog==3.0.0
4 changes: 2 additions & 2 deletions server/agent/tools_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Tool.from_function(
func=search_knowledgebase_complex,
name="search_knowledgebase_complex",
description="Use Use this tool to search local knowledgebase and get information",
description="Use this tool to search local knowledgebase and get information",
args_schema=KnowledgeSearchInput,
),
Tool.from_function(
Expand All @@ -47,7 +47,7 @@
Tool.from_function(
func=search_youtube,
name="search_youtube",
description="use this tools to search youtube videos",
description="use this tool to search youtube videos",
args_schema=YoutubeInput,
),
]
Expand Down
3 changes: 3 additions & 0 deletions server/knowledge_base/kb_doc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ def search_docs(
data = [DocumentWithVSId(**x[0].dict(), score=x[1], id=x[0].metadata.get("id")) for x in docs]
elif file_name or metadata:
data = kb.list_docs(file_name=file_name, metadata=metadata)
for d in data:
if "vector" in d.metadata:
del d.metadata["vector"]
return data


Expand Down
14 changes: 14 additions & 0 deletions server/knowledge_base/kb_service/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,20 @@ def list_docs(self, file_name: str = None, metadata: Dict = {}) -> List[Document
pass
return docs

def get_relative_source_path(self,filepath: str):
'''
将文件路径转化为相对路径,保证查询时一致
'''
relative_path = filepath
if os.path.isabs(relative_path):
try:
relative_path = Path(filepath).relative_to(self.doc_path)
except Exception as e:
print(f"cannot convert absolute path ({source}) to relative path. error is : {e}")

relative_path = str(relative_path.as_posix().strip("/"))
return relative_path

@abstractmethod
def do_create_kb(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion server/knowledge_base/kb_service/es_kb_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def do_delete_doc(self, kb_file, **kwargs):
query = {
"query": {
"term": {
"metadata.source.keyword": kb_file.filepath
"metadata.source.keyword": self.get_relative_source_path(kb_file.filepath)
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions server/knowledge_base/kb_service/pg_kb_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def _load_pg_vector(self):

def get_doc_by_ids(self, ids: List[str]) -> List[Document]:
with Session(PGKBService.engine) as session:
stmt = text("SELECT document, cmetadata FROM langchain_pg_embedding WHERE collection_id in :ids")
stmt = text("SELECT document, cmetadata FROM langchain_pg_embedding WHERE custom_id = ANY(:ids)")
results = [Document(page_content=row[0], metadata=row[1]) for row in
session.execute(stmt, {'ids': ids}).fetchall()]
session.execute(stmt, {'ids': ids}).fetchall()]
return results
def del_doc_by_ids(self, ids: List[str]) -> bool:
return super().del_doc_by_ids(ids)
Expand Down Expand Up @@ -71,11 +71,10 @@ def do_add_doc(self, docs: List[Document], **kwargs) -> List[Dict]:

def do_delete_doc(self, kb_file: KnowledgeFile, **kwargs):
with Session(PGKBService.engine) as session:
filepath = kb_file.filepath.replace('\\', '\\\\')
session.execute(
text(
''' DELETE FROM langchain_pg_embedding WHERE cmetadata::jsonb @> '{"source": "filepath"}'::jsonb;'''.replace(
"filepath", filepath)))
"filepath", self.get_relative_source_path(kb_file.filepath))))
session.commit()

def do_clear_vs(self):
Expand Down