mirror of
https://gitee.com/dify_ai/dify.git
synced 2024-11-30 02:08:37 +08:00
fix: dataset destination error (#477)
This commit is contained in:
parent
408fbb0c70
commit
9d98669e7d
@ -1,4 +1,5 @@
|
|||||||
import math
|
import math
|
||||||
|
import re
|
||||||
from typing import Mapping, List, Dict, Any, Optional
|
from typing import Mapping, List, Dict, Any, Optional
|
||||||
|
|
||||||
from langchain import PromptTemplate
|
from langchain import PromptTemplate
|
||||||
@ -178,13 +179,20 @@ class MultiDatasetRouterChain(Chain):
|
|||||||
|
|
||||||
route = self.router_chain.route(inputs)
|
route = self.router_chain.route(inputs)
|
||||||
|
|
||||||
if not route.destination:
|
destination = ''
|
||||||
|
if route.destination:
|
||||||
|
pattern = r'\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b'
|
||||||
|
match = re.search(pattern, route.destination, re.IGNORECASE)
|
||||||
|
if match:
|
||||||
|
destination = match.group()
|
||||||
|
|
||||||
|
if not destination:
|
||||||
return {"text": ''}
|
return {"text": ''}
|
||||||
elif route.destination in self.dataset_tools:
|
elif destination in self.dataset_tools:
|
||||||
return {"text": self.dataset_tools[route.destination].run(
|
return {"text": self.dataset_tools[destination].run(
|
||||||
route.next_inputs['input']
|
route.next_inputs['input']
|
||||||
)}
|
)}
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"Received invalid destination chain name '{route.destination}'"
|
f"Received invalid destination chain name '{destination}'"
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user