Skip to content

Commit

Permalink
fix:client path error and update chat_knowledge prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Aries-ckt committed Mar 21, 2024
1 parent b4b810d commit a1369c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
14 changes: 11 additions & 3 deletions dbgpt/app/scene/chat_knowledge/v1/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,22 @@
The assistant gives helpful, detailed, professional and polite answers to the user's questions. """


_DEFAULT_TEMPLATE_ZH = """ 基于以下已知的信息, 专业、简要的回答用户的问题,
如果无法从提供的内容中获取答案, 请说: "知识库中提供的内容不足以回答此问题" 禁止胡乱编造, 回答的时候最好按照1.2.3.点进行总结。
_DEFAULT_TEMPLATE_ZH = """ 基于以下给出的已知信息, 准守规范约束,专业、简要回答用户的问题.
规范约束:
1.如果已知信息包含的图片、链接、表格、代码块等特殊markdown标签格式的信息,确保在答案中包含原文这些图片、链接、表格和代码标签,不要丢弃不要修改,如:图片格式:![image.png](xxx), 链接格式:[xxx](xxx), 表格格式:|xxx|xxx|xxx|, 代码格式:```xxx```.
2.如果无法从提供的内容中获取答案, 请说: "知识库中提供的内容不足以回答此问题" 禁止胡乱编造.
3.回答的时候最好按照1.2.3.点进行总结.
已知内容:
{context}
问题:
{question},请使用和用户相同的语言进行回答.
"""
_DEFAULT_TEMPLATE_EN = """ Based on the known information below, provide users with professional and concise answers to their questions. If the answer cannot be obtained from the provided content, please say: "The information provided in the knowledge base is not sufficient to answer this question." It is forbidden to make up information randomly. When answering, it is best to summarize according to points 1.2.3.
_DEFAULT_TEMPLATE_EN = """ Based on the known information below, provide users with professional and concise answers to their questions.
constraints:
1.Ensure to include original markdown formatting elements such as images, links, tables, or code blocks without alteration in the response if they are present in the provided information.
For example, image format should be ![image.png](xxx), link format [xxx](xxx), table format should be represented with |xxx|xxx|xxx|, and code format with xxx.
2.If the information available in the knowledge base is insufficient to answer the question, state clearly: "The content provided in the knowledge base is not enough to answer this question," and avoid making up answers.
3.When responding, it is best to summarize the points in the order of 1, 2, 3.
known information:
{context}
question:
Expand Down
18 changes: 10 additions & 8 deletions dbgpt/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

from .schema import ChatCompletionRequestBody

CLIENT_API_PATH = "/api"
CLIENT_SERVE_PATH = "/serve"
CLIENT_API_PATH = "api"
CLIENT_SERVE_PATH = "serve"


class ClientException(Exception):
Expand Down Expand Up @@ -274,7 +274,7 @@ async def get(self, path: str, *args):
"""
try:
response = await self._http_client.get(
self._api_url + CLIENT_SERVE_PATH + path,
f"{self._api_url}/{CLIENT_SERVE_PATH}{path}",
*args,
)
return response
Expand All @@ -290,7 +290,7 @@ async def post(self, path: str, args):
"""
try:
return await self._http_client.post(
self._api_url + CLIENT_SERVE_PATH + path,
f"{self._api_url}/{CLIENT_SERVE_PATH}{path}",
json=args,
)
finally:
Expand All @@ -305,7 +305,7 @@ async def post_param(self, path: str, args):
"""
try:
return await self._http_client.post(
self._api_url + CLIENT_SERVE_PATH + path,
f"{self._api_url}/{CLIENT_SERVE_PATH}{path}",
params=args,
)
finally:
Expand All @@ -318,7 +318,9 @@ async def patch(self, path: str, *args):
path: str, The path to patch.
args: Any, The arguments to pass to the patch.
"""
return self._http_client.patch(self._api_url + CLIENT_SERVE_PATH + path, *args)
return self._http_client.patch(
f"{self._api_url}/{CLIENT_SERVE_PATH}{path}", *args
)

async def put(self, path: str, args):
"""Put method.
Expand All @@ -329,7 +331,7 @@ async def put(self, path: str, args):
"""
try:
return await self._http_client.put(
self._api_url + CLIENT_SERVE_PATH + path, json=args
f"{self._api_url}/{CLIENT_SERVE_PATH}{path}", json=args
)
finally:
await self._http_client.aclose()
Expand All @@ -343,7 +345,7 @@ async def delete(self, path: str, *args):
"""
try:
return await self._http_client.delete(
self._api_url + CLIENT_SERVE_PATH + path, *args
f"{self._api_url}/{CLIENT_SERVE_PATH}{path}", *args
)
finally:
await self._http_client.aclose()
Expand Down

0 comments on commit a1369c0

Please sign in to comment.