fix(builder): bugfix official_name node has same prop object (#372)

* bugfix official_name node has same prop object

* reformat by black
This commit is contained in:
royzhao 2025-02-25 18:16:08 +08:00 committed by GitHub
parent 8d51e66d6a
commit 6a16df3565
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 14 deletions

View File

@ -250,7 +250,7 @@ class SchemaConstraintExtractor(ExtractorABC):
id=official_name,
name=official_name,
label=s_label,
properties=properties,
properties=dict(properties),
)
graph.add_edge(
s_id=s_name,

View File

@ -14,6 +14,7 @@ from openai import OpenAI, AzureOpenAI
from kag.interface import VectorizeModelABC, EmbeddingVector
from typing import Callable
@VectorizeModelABC.register("openai")
class OpenAIVectorizeModel(VectorizeModelABC):
"""
@ -66,11 +67,12 @@ class OpenAIVectorizeModel(VectorizeModelABC):
assert len(results) == len(texts)
return results
@VectorizeModelABC.register("azure_openai")
class AzureOpenAIVectorizeModel(VectorizeModelABC):
''' A class that extends the VectorizeModelABC base class.
"""A class that extends the VectorizeModelABC base class.
It invokes Azure OpenAI or Azure OpenAI-compatible embedding services to convert texts into embedding vectors.
'''
"""
def __init__(
self,
@ -132,4 +134,4 @@ class AzureOpenAIVectorizeModel(VectorizeModelABC):
return results[0]
else:
assert len(results) == len(texts)
return results
return results

View File

@ -232,10 +232,12 @@ class SPOEntity(SPOBase):
{
"alias": self.alias_name.alias_name,
"id": info[0],
"type": info[1].std_entity_type
if "." in info[1].std_entity_type
else (prefix + "." if prefix is not None else "")
+ info[1].std_entity_type,
"type": (
info[1].std_entity_type
if "." in info[1].std_entity_type
else (prefix + "." if prefix is not None else "")
+ info[1].std_entity_type
),
}
for info in id_type_info
]
@ -396,7 +398,11 @@ class LFExecuteResult:
i = 0
for sub_plan in self.sub_plans:
sub_res = sub_plan.res
if sub_res.sub_answer is None or "i don't know" in sub_res.sub_answer.lower() or sub_res.sub_answer == "":
if (
sub_res.sub_answer is None
or "i don't know" in sub_res.sub_answer.lower()
or sub_res.sub_answer == ""
):
failed_sub_query.append(sub_res)
facts.append(
f"query{i + 1}:{sub_res.sub_query}. \nanswer:{sub_res.sub_answer}"

View File

@ -19,6 +19,7 @@ from kag.common.conf import KAG_CONFIG, KAG_PROJECT_CONF
logger = logging.getLogger()
class SolverMain:
def invoke(
self,
@ -98,15 +99,16 @@ class SolverMain:
state = ReporterIntermediateProcessTool.STATE.FINISH
logger.info(f"{query} answer={answer} tracelog={trace_log}")
except Exception as e:
if KAG_PROJECT_CONF.language == 'en':
if KAG_PROJECT_CONF.language == "en":
answer = f"Sorry, An exception occurred while processing query: {query}. Error: {str(e)}, please retry."
else:
answer = f"抱歉,处理查询 {query} 时发生异常。错误:{str(e)}, 请重试。"
state = ReporterIntermediateProcessTool.STATE.ERROR
logger.warning(f"An exception occurred while processing query: {query}. Error: {str(e)}", exc_info=True)
report_tool.report_final_answer(
query, answer, state
)
logger.warning(
f"An exception occurred while processing query: {query}. Error: {str(e)}",
exc_info=True,
)
report_tool.report_final_answer(query, answer, state)
return answer