fix(ChatKnowledge): summary support zhipu message_converter (#1085)

This commit is contained in:
Aries-ckt
2024-01-18 15:09:09 +08:00
committed by GitHub
parent 0936856c3a
commit 0162dee474
3 changed files with 11 additions and 10 deletions

View File

@@ -21,11 +21,9 @@ This example shows how to use AWEL to build a simple rag summary example.
.. code-block:: shell
DBGPT_SERVER="http://127.0.0.1:5000"
FILE_PATH="{your_file_path}"
curl -X POST http://127.0.0.1:5555/api/v1/awel/trigger/examples/rag/summary \
-H "Content-Type: application/json" -d '{
"file_path": $FILE_PATH
"url": "https://docs.dbgpt.site/docs/awel"
}'
"""
from typing import Dict
@@ -33,12 +31,13 @@ from typing import Dict
from dbgpt._private.pydantic import BaseModel, Field
from dbgpt.core.awel import DAG, HttpTrigger, MapOperator
from dbgpt.model import OpenAILLMClient
from dbgpt.rag.knowledge.base import KnowledgeType
from dbgpt.rag.operator.knowledge import KnowledgeOperator
from dbgpt.rag.operator.summary import SummaryAssemblerOperator
class TriggerReqBody(BaseModel):
file_path: str = Field(..., description="file_path")
url: str = Field(..., description="url")
class RequestHandleOperator(MapOperator[TriggerReqBody, Dict]):
@@ -47,7 +46,7 @@ class RequestHandleOperator(MapOperator[TriggerReqBody, Dict]):
async def map(self, input_value: TriggerReqBody) -> Dict:
params = {
"file_path": input_value.file_path,
"url": input_value.url,
}
print(f"Receive input value: {input_value}")
return params
@@ -58,9 +57,9 @@ with DAG("dbgpt_awel_simple_rag_summary_example") as dag:
"/examples/rag/summary", methods="POST", request_body=TriggerReqBody
)
request_handle_task = RequestHandleOperator()
path_operator = MapOperator(lambda request: request["file_path"])
path_operator = MapOperator(lambda request: request["url"])
# build knowledge operator
knowledge_operator = KnowledgeOperator()
knowledge_operator = KnowledgeOperator(knowledge_type=KnowledgeType.URL)
# build summary assembler operator
summary_operator = SummaryAssemblerOperator(
llm_client=OpenAILLMClient(), language="en"