Skip to content

Commit

Permalink
Merge pull request #74 from isi-nlp/Launch-task-dynamtially
Browse files Browse the repository at this point in the history
Launch task dynamically
  • Loading branch information
wise-east authored Mar 19, 2024
2 parents 2aa466d + 407af3a commit db18367
Show file tree
Hide file tree
Showing 34 changed files with 1,035 additions and 2,545 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ darma-task
# for PyCharm Users
.idea
*.log
boteval/templates
8 changes: 7 additions & 1 deletion boteval/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def init_app(**args):
app.config['SQLALCHEMY_DATABASE_URI'] = db_uri
log.info(f'SQLALCHEMY_DATABASE_URI = {db_uri}')

scheme = app.config.get('PREFERRED_URL_SCHEME', 'http')
app.config['PREFERRED_URL_SCHEME'] = scheme

if (task_dir / '__init__.py').exists(): # task dir has python code
log.info(f'{task_dir} is a python module. Going to import it.')
load_dir_as_module(task_dir)
Expand Down Expand Up @@ -118,7 +121,10 @@ def main():
base_prefix = args.get('base') or '/'
log.info(f'Internal URL http://{host}:{port}{base_prefix}')
#socket.run(app, port=port, host=host, debug=app.debug)
app.run(port=port, host=host)
if app.config['PREFERRED_URL_SCHEME'] == 'https':
app.run(port=port, host=host, ssl_context='adhoc')
else:
app.run(port=port, host=host)

if __name__ == "__main__":
main()
18 changes: 10 additions & 8 deletions boteval/bots.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ def __init__(self, *args, name=None, **kwargs) -> None:
self.update_signature(agent_name=name)
self.last_msg = None

def get_name(self) -> str:
raise NotImplementedError()

def update_signature(self, **kwargs):
self.signature.update(kwargs)
def init_chat_context(self, init_messages: List[Dict[str, Any]]):
raise NotImplementedError(f'{type(self)} must implement init_chat_context() method')

def hear(self, msg: Dict[str, Any]):
self.last_msg = msg
raise NotImplementedError(f'{type(self)} must implement hear() method')

def talk(self) -> Dict[str, Any]:
raise NotImplementedError(f'{type(self)} must implement talk() method')

def update_signature(self, **kwargs):
self.signature.update(kwargs)

def interactive_shell(self):
log.info(f'Launching an interactive shell with {type(self)}.\n'
'Type "exit" or press CTRL+D to quit.')
Expand All @@ -60,11 +60,13 @@ class DummyBot(BotAgent):

NAME = 'dummybot'

def talk(self):
def init_chat_context(self, init_messages: List[Dict[str, Any]]):
log.debug(f'Initializing chat context with {len(init_messages)} messages')
def talk(self, **kwargs):
context = (self.last_msg or {}).get('text', '')
if context.lower() == 'ping':
return 'pong'
return dict(text="dummybot reply --" + context[-30:])
return dict(text="dummybot reply --" + context[-30:], data={'speaker_id': 'Moderator'})


@R.register(R.BOT, 'hf-transformers')
Expand Down
2 changes: 2 additions & 0 deletions boteval/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ class Auth:
AWS_MAX_RESULTS = 100
MTURK_LOG_LEVEL = logging.INFO

BOT_REPLY_DELAY_START = 5.0 # bot reply delay in seconds, value is small for debugging
BOT_REPLY_DELAY_END = 10.0 # bot reply delay in seconds
Loading

0 comments on commit db18367

Please sign in to comment.