refactor: make service['url'] a key in a service configuratio
@@ -40,7 +40,8 @@ def _model_process(model_function: Callable, conn: Connection, batch_size: int =
def experimental_bot(
- model_function: Callable[..., Callable[[Collection[Message], Collection[Hashable]], Collection[str]]],
+ model_function: Callable[
+ ..., Callable[[Collection[Message], Collection[Hashable]], Collection[str]]],
token: str, proxy: Optional[str] = None, *, batch_size: int = -1, poll_period: float = 0.5):
"""
@@ -88,27 +89,32 @@ def run():
from core.postprocessor import DefaultPostprocessor
from core.response_selector import ConfidenceResponseSelector
from core.skill_selector import ChitchatQASelector
- from core.config import MAX_WORKERS, ANNOTATORS, SKILL_SELECTORS, SKILLS, RESPONSE_SELECTORS, POSTPROCESSORS
+ from core.config import MAX_WORKERS, ANNOTATORS, SKILL_SELECTORS, SKILLS, RESPONSE_SELECTORS, \
+ POSTPROCESSORS
import logging
+ for service in chain(ANNOTATORS, SKILL_SELECTORS, SKILLS, RESPONSE_SELECTORS, POSTPROCESSORS):
if getenv('DPA_LAUNCHING_ENV') != 'docker':
- for skill in chain(ANNOTATORS, SKILL_SELECTORS, SKILLS, RESPONSE_SELECTORS, POSTPROCESSORS):
- if not skill.get('external', False):
- skill['host'] = 'http://0.0.0.0'
+ if not service.get('external', False):
+ service['host'] = 'http://0.0.0.0'
+ service['url'] = service[
+ 'url'] = f"{service['host']}:{service['port']}/{service['endpoint']}"
logging.getLogger('requests.packages.urllib3.connectionpool').setLevel(logging.WARNING)
state_manager = StateManager()
- anno_names, anno_urls = zip(*[(anno['name'], f"{anno['host']}:{anno['port']}/{anno['endpoint']}") for anno in ANNOTATORS])
+ anno_names, anno_urls = zip(
+ *[(annotator['name'], annotator['url']) for annotator in ANNOTATORS])
preprocessor = Service(
rest_caller=RestCaller(max_workers=MAX_WORKERS, names=anno_names, urls=anno_urls))
postprocessor = DefaultPostprocessor()
skill_caller = RestCaller(max_workers=MAX_WORKERS)
response_selector = ConfidenceResponseSelector()
- ss_names, ss_urls = zip(*[(sselector['name'], f"{sselector['host']}:{sselector['port']}/{sselector['endpoint']}") for sselector in SKILL_SELECTORS])
- skill_selector = ChitchatQASelector(rest_caller=RestCaller(max_workers=MAX_WORKERS, names=ss_names, urls=ss_urls))
+ ss_names, ss_urls = zip(*[(selector['name'], selector['url']) for selector in SKILL_SELECTORS])
+ skill_selector = ChitchatQASelector(
+ rest_caller=RestCaller(max_workers=MAX_WORKERS, names=ss_names, urls=ss_urls))
skill_manager = SkillManager(skill_selector=skill_selector, response_selector=response_selector,
skill_caller=skill_caller, profile_handlers=[skill['name'] for skill in SKILLS
if skill.get('profile_handler')])
