Skip to content

Commit

Permalink
fix: dataset destination error (#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
takatost authored Jun 28, 2023
1 parent 408fbb0 commit 9d98669
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions api/core/chain/multi_dataset_router_chain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import math
import re
from typing import Mapping, List, Dict, Any, Optional

from langchain import PromptTemplate
Expand Down Expand Up @@ -178,13 +179,20 @@ def _call(

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": ''}
elif route.destination in self.dataset_tools:
return {"text": self.dataset_tools[route.destination].run(
elif destination in self.dataset_tools:
return {"text": self.dataset_tools[destination].run(
route.next_inputs['input']
)}
else:
raise ValueError(
f"Received invalid destination chain name '{route.destination}'"
f"Received invalid destination chain name '{destination}'"
)

0 comments on commit 9d98669

Please sign in to comment.