This is an automated email from the ASF dual-hosted git repository.
jin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git
The following commit(s) were added to refs/heads/main by this push:
new 153d7f4 fix(llm): answer prompt None value effect (#116)
153d7f4 is described below
commit 153d7f417352bea93294e832dee211dee0e36556
Author: Hongjun Li <[email protected]>
AuthorDate: Tue Nov 19 11:24:24 2024 +0800
fix(llm): answer prompt None value effect (#116)
Solve the problem that the final result is not as expected when the
`answer_prompt` in the body parameter of `/rag` api is `None` or an empty string
---------
Co-authored-by: imbajin <[email protected]>
---
hugegraph-llm/src/hugegraph_llm/api/models/rag_requests.py | 4 ++--
hugegraph-llm/src/hugegraph_llm/api/rag_api.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hugegraph-llm/src/hugegraph_llm/api/models/rag_requests.py
b/hugegraph-llm/src/hugegraph_llm/api/models/rag_requests.py
index d832859..dcf19db 100644
--- a/hugegraph-llm/src/hugegraph_llm/api/models/rag_requests.py
+++ b/hugegraph-llm/src/hugegraph_llm/api/models/rag_requests.py
@@ -30,7 +30,7 @@ class RAGRequest(BaseModel):
rerank_method: Literal["bleu", "reranker"] = "bleu"
near_neighbor_first: bool = False
custom_priority_info: str = ""
- answer_prompt: str = ""
+ answer_prompt: Optional[str] = None
class GraphRAGRequest(BaseModel):
@@ -43,7 +43,7 @@ class GraphRAGRequest(BaseModel):
rerank_method: Literal["bleu", "reranker"] = "bleu"
near_neighbor_first: bool = False
custom_priority_info: str = ""
- answer_prompt: str = ""
+ answer_prompt: Optional[str] = None
class GraphConfigRequest(BaseModel):
diff --git a/hugegraph-llm/src/hugegraph_llm/api/rag_api.py
b/hugegraph-llm/src/hugegraph_llm/api/rag_api.py
index 26f42e5..e5c4375 100644
--- a/hugegraph-llm/src/hugegraph_llm/api/rag_api.py
+++ b/hugegraph-llm/src/hugegraph_llm/api/rag_api.py
@@ -27,7 +27,7 @@ from hugegraph_llm.api.models.rag_requests import (
RerankerConfigRequest, GraphRAGRequest,
)
from hugegraph_llm.api.models.rag_response import RAGResponse
-from hugegraph_llm.config import settings
+from hugegraph_llm.config import settings, prompt
from hugegraph_llm.utils.log import log
@@ -63,7 +63,7 @@ def rag_http_api(
req.rerank_method,
req.near_neighbor_first,
req.custom_priority_info,
- req.answer_prompt
+ req.answer_prompt or prompt.answer_prompt
)
return {
key: value