Update Code and README for GenAIComps Refactor (#1285)
Signed-off-by: lvliang-intel <liang1.lv@intel.com> Signed-off-by: chensuyue <suyue.chen@intel.com> Signed-off-by: Xinyao Wang <xinyao.wang@intel.com> Signed-off-by: letonghan <letong.han@intel.com> Signed-off-by: ZePan110 <ze.pan@intel.com> Signed-off-by: WenjiaoYue <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>
This commit is contained in:
@@ -21,10 +21,29 @@ RERANK_SERVICE_HOST_IP = os.getenv("RERANK_SERVICE_HOST_IP", "0.0.0.0")
|
||||
RERANK_SERVICE_PORT = os.getenv("RERANK_SERVICE_PORT", 8000)
|
||||
|
||||
|
||||
def align_inputs(self, inputs, cur_node, runtime_graph, llm_parameters_dict, **kwargs):
|
||||
if self.services[cur_node].service_type == ServiceType.EMBEDDING:
|
||||
inputs["input"] = inputs["text"]
|
||||
del inputs["text"]
|
||||
return inputs
|
||||
|
||||
|
||||
def align_outputs(self, data, cur_node, inputs, runtime_graph, llm_parameters_dict, **kwargs):
|
||||
next_data = {}
|
||||
if self.services[cur_node].service_type == ServiceType.EMBEDDING:
|
||||
next_data = {"text": inputs["input"], "embedding": [item["embedding"] for item in data["data"]]}
|
||||
else:
|
||||
next_data = data
|
||||
|
||||
return next_data
|
||||
|
||||
|
||||
class RetrievalToolService:
|
||||
def __init__(self, host="0.0.0.0", port=8000):
|
||||
self.host = host
|
||||
self.port = port
|
||||
ServiceOrchestrator.align_inputs = align_inputs
|
||||
ServiceOrchestrator.align_outputs = align_outputs
|
||||
self.megaservice = ServiceOrchestrator()
|
||||
self.endpoint = str(MegaServiceEndpoint.RETRIEVALTOOL)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user