KevinHuSh
commited on
Commit
·
1cc57ab
1
Parent(s):
4f62080
fix set_api_key bug (#191)
Browse files### What problem does this PR solve?
_Briefly describe what this PR aims to solve. Include background context
that will help reviewers understand the purpose of the PR._
Issue link:#[Link the issue here]
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Breaking Change (fix or feature that could cause existing
functionality not to work as expected)
- [ ] Documentation Update
- [ ] Refactoring
- [ ] Performance Improvement
- [ ] Test cases
- [ ] Python SDK impacted, Need to update PyPI
- [ ] Other (please describe):
- api/apps/conversation_app.py +3 -1
- api/apps/llm_app.py +2 -2
- api/db/services/__init__.py +1 -1
- docs/CONTRIBUTING.md +52 -0
api/apps/conversation_app.py
CHANGED
@@ -248,8 +248,10 @@ def chat(dialog, messages, **kwargs):
|
|
248 |
tkweight=1 - dialog.vector_similarity_weight,
|
249 |
vtweight=dialog.vector_similarity_weight)
|
250 |
idx = set([kbinfos["chunks"][int(i)]["doc_id"] for i in idx])
|
251 |
-
|
252 |
d for d in kbinfos["doc_aggs"] if d["doc_id"] in idx]
|
|
|
|
|
253 |
for c in kbinfos["chunks"]:
|
254 |
if c.get("vector"):
|
255 |
del c["vector"]
|
|
|
248 |
tkweight=1 - dialog.vector_similarity_weight,
|
249 |
vtweight=dialog.vector_similarity_weight)
|
250 |
idx = set([kbinfos["chunks"][int(i)]["doc_id"] for i in idx])
|
251 |
+
recall_docs = [
|
252 |
d for d in kbinfos["doc_aggs"] if d["doc_id"] in idx]
|
253 |
+
if not recall_docs: recall_docs = kbinfos["doc_aggs"]
|
254 |
+
kbinfos["doc_aggs"] = recall_docs
|
255 |
for c in kbinfos["chunks"]:
|
256 |
if c.get("vector"):
|
257 |
del c["vector"]
|
api/apps/llm_app.py
CHANGED
@@ -45,7 +45,7 @@ def set_api_key():
|
|
45 |
for llm in LLMService.query(fid=factory):
|
46 |
if llm.model_type == LLMType.EMBEDDING.value:
|
47 |
mdl = EmbeddingModel[factory](
|
48 |
-
req["api_key"], llm.llm_name, req.get("base_url"))
|
49 |
try:
|
50 |
arr, tc = mdl.encode(["Test if the api key is available"])
|
51 |
if len(arr[0]) == 0 or tc == 0:
|
@@ -54,7 +54,7 @@ def set_api_key():
|
|
54 |
msg += f"\nFail to access embedding model({llm.llm_name}) using this api key." + str(e)
|
55 |
elif not chat_passed and llm.model_type == LLMType.CHAT.value:
|
56 |
mdl = ChatModel[factory](
|
57 |
-
req["api_key"], llm.llm_name, req.get("base_url"))
|
58 |
try:
|
59 |
m, tc = mdl.chat(None, [{"role": "user", "content": "Hello! How are you doing!"}], {
|
60 |
"temperature": 0.9})
|
|
|
45 |
for llm in LLMService.query(fid=factory):
|
46 |
if llm.model_type == LLMType.EMBEDDING.value:
|
47 |
mdl = EmbeddingModel[factory](
|
48 |
+
req["api_key"], llm.llm_name, base_url=req.get("base_url"))
|
49 |
try:
|
50 |
arr, tc = mdl.encode(["Test if the api key is available"])
|
51 |
if len(arr[0]) == 0 or tc == 0:
|
|
|
54 |
msg += f"\nFail to access embedding model({llm.llm_name}) using this api key." + str(e)
|
55 |
elif not chat_passed and llm.model_type == LLMType.CHAT.value:
|
56 |
mdl = ChatModel[factory](
|
57 |
+
req["api_key"], llm.llm_name, base_url=req.get("base_url"))
|
58 |
try:
|
59 |
m, tc = mdl.chat(None, [{"role": "user", "content": "Hello! How are you doing!"}], {
|
60 |
"temperature": 0.9})
|
api/db/services/__init__.py
CHANGED
@@ -24,7 +24,7 @@ def duplicate_name(query_func, **kwargs):
|
|
24 |
if not objs: return fnm
|
25 |
ext = pathlib.Path(fnm).suffix #.jpg
|
26 |
nm = re.sub(r"%s$"%ext, "", fnm)
|
27 |
-
r = re.search(r"\([0-9]
|
28 |
c = 0
|
29 |
if r:
|
30 |
c = int(r.group(1))
|
|
|
24 |
if not objs: return fnm
|
25 |
ext = pathlib.Path(fnm).suffix #.jpg
|
26 |
nm = re.sub(r"%s$"%ext, "", fnm)
|
27 |
+
r = re.search(r"\(([0-9]+)\)$", nm)
|
28 |
c = 0
|
29 |
if r:
|
30 |
c = int(r.group(1))
|
docs/CONTRIBUTING.md
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
sidebar_position: 0
|
3 |
+
slug: /contribution_guidelines
|
4 |
+
---
|
5 |
+
|
6 |
+
# Contribution Guidelines
|
7 |
+
|
8 |
+
Thanks for wanting to contribute to RAGFlow. This document offers guidlines and major considerations for submitting your contributions.
|
9 |
+
|
10 |
+
- To report a bug, file a [GitHub issue](https://github.com/infiniflow/ragflow/issues/new/choose) with us.
|
11 |
+
- For further questions, you can explore existing discussions or initiate a new one in [Discussions](https://github.com/orgs/infiniflow/discussions).
|
12 |
+
|
13 |
+
|
14 |
+
## What you can contribute
|
15 |
+
|
16 |
+
The list below mentions some contributions you can make, but it is not a complete list.
|
17 |
+
|
18 |
+
- Proposing or implementing new features
|
19 |
+
- Fixing a bug
|
20 |
+
- Adding test cases or demos
|
21 |
+
- Posting a blog or tutorial
|
22 |
+
- Updates to existing documents, codes, or annotations.
|
23 |
+
- Suggesting more user-friendly error codes
|
24 |
+
|
25 |
+
## File a pull request (PR)
|
26 |
+
|
27 |
+
### General workflow
|
28 |
+
|
29 |
+
1. Fork our GitHub repository.
|
30 |
+
2. Clone your fork to your local machine:
|
31 |
+
`git clone [email protected]:<yourname>/ragflow.git`
|
32 |
+
3. Create a local branch:
|
33 |
+
`git checkout -b my-branch`
|
34 |
+
4. Provide sufficient information in your commit message
|
35 |
+
`git commit -m 'Provide sufficient info in your commit message'`
|
36 |
+
5. Commit changes to your local branch, and push to GitHub: (include necessary commit message)
|
37 |
+
`git push origin my-branch.`
|
38 |
+
6. Submit a pull request for review.
|
39 |
+
|
40 |
+
### Before filing a PR
|
41 |
+
|
42 |
+
- Consider splitting a large PR into multiple smaller, standalone PRs to keep a traceable development history.
|
43 |
+
- Ensure that your PR addresses just one issue, or keep any unrelated changes small.
|
44 |
+
- Add test cases when contributing new features. They demonstrate that your code functions correctly and protect against potential issues from future changes.
|
45 |
+
### Describing your PR
|
46 |
+
|
47 |
+
- Ensure that your PR title is concise and clear, providing all the required information.
|
48 |
+
- Refer to a corresponding GitHub issue in your PR description if applicable.
|
49 |
+
- Include sufficient design details for *breaking changes* or *API changes* in your description.
|
50 |
+
|
51 |
+
### Reviewing & merging a PR
|
52 |
+
- Ensure that your PR passes all Continuous Integration (CI) tests before merging it.
|