prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  projects/convai2/interactive.py not using new message force_set feature
  **Bug description**
  The code hasn't been updated for the force_set.
  
  **Reproduction steps**
  python projects/convai2/interactive.py -mf models:convai2/seq2seq/convai2_self_seq2seq_model -m legacy:seq2seq:0 --no_cuda
  
  **Expected behavior**
  to just chat
  
  **Logs**
  
  ```
  Traceback (most recent call last):
    File "projects/convai2/interactive.py", line 126, in <module>
      interactive(parser.parse_args(print_args=False), print_parser=parser)
    File "projects/convai2/interactive.py", line 105, in interactive
      acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')
    File "/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/parlai-0.1.0-py3.6.egg/parlai/core/message.py", line 26, in __setitem__
      'please use the function `force_set(key, value)`.'.format(key)
  RuntimeError: Message already contains key `text`. If this was intentional, please use the function `force_set(key, value)`.
  ```
  
  **Additional context**
  possible fix
  ```
  index 61ead742..9d478d75 100644
  --- a/projects/convai2/interactive.py
  +++ b/projects/convai2/interactive.py
  @@ -102,7 +102,8 @@ def interactive(opt, print_parser=None):
           acts[0] = agents[0].act()
           # add the persona on to the first message
           if cnt == 0:
  -            acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')
  +            #acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')
  +            acts[0].force_set('text',bot_persona + acts[0].get('text', 'hi'))
           agents[1].observe(acts[0])
  
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `projects/convai2/interactive.py`
  Content:
  ```
  1 #!/usr/bin/env python3
  2 
  3 # Copyright (c) Facebook, Inc. and its affiliates.
  4 # This source code is licensed under the MIT license found in the
  5 # LICENSE file in the root directory of this source tree.
  6 """
  7 Basic script which allows local human keyboard input to talk to a trained model.
  8 
  9 Examples
  10 --------
  11 
  12 .. code-block:: shell
  13 
  14   python projects/convai2/interactive.py -mf models:convai2/kvmemnn/model
  15 
  16 When prompted, chat with the both, you will both be assigned personalities!
  17 Use "[DONE]" to indicate you are done with that chat partner, and want a new one.
  18 """
  19 from parlai.core.params import ParlaiParser
  20 from parlai.core.agents import create_agent
  21 from parlai.core.worlds import create_task
  22 from parlai.agents.repeat_label.repeat_label import RepeatLabelAgent
  23 from parlai.agents.local_human.local_human import LocalHumanAgent
  24 
  25 import random
  26 
  27 
  28 def setup_args(parser=None):
  29     if parser is None:
  30         parser = ParlaiParser(True, True, 'Interactive chat with a model')
  31     parser.add_argument('-d', '--display-examples', type='bool', default=False)
  32     parser.add_argument(
  33         '--display-prettify',
  34         type='bool',
  35         default=False,
  36         help='Set to use a prettytable when displaying '
  37         'examples with text candidates',
  38     )
  39     parser.add_argument(
  40         '--display-ignore-fields',
  41         type=str,
  42         default='label_candidates,text_candidates',
  43         help='Do not display these fields',
  44     )
  45     parser.set_defaults(model_file='models:convai2/kvmemnn/model')
  46     LocalHumanAgent.add_cmdline_args(parser)
  47     return parser
  48 
  49 
  50 def interactive(opt, print_parser=None):
  51     if print_parser is not None:
  52         if print_parser is True and isinstance(opt, ParlaiParser):
  53             print_parser = opt
  54         elif print_parser is False:
  55             print_parser = None
  56     if isinstance(opt, ParlaiParser):
  57         print('[ Deprecated Warning: interactive should be passed opt not Parser ]')
  58         opt = opt.parse_args()
  59     opt['task'] = 'parlai.agents.local_human.local_human:LocalHumanAgent'
  60     # Create model and assign it to the specified task
  61     agent = create_agent(opt, requireModelExists=True)
  62     world = create_task(opt, agent)
  63     if print_parser:
  64         # Show arguments after loading model
  65         print_parser.opt = agent.opt
  66         print_parser.print_args()
  67 
  68     # Create ConvAI2 data so we can assign personas.
  69     convai2_opt = opt.copy()
  70     convai2_opt['task'] = 'convai2:both'
  71     convai2_agent = RepeatLabelAgent(convai2_opt)
  72     convai2_world = create_task(convai2_opt, convai2_agent)
  73 
  74     def get_new_personas():
  75         # Find a new episode
  76         while True:
  77             convai2_world.parley()
  78             msg = convai2_world.get_acts()[0]
  79             if msg['episode_done']:
  80                 convai2_world.parley()
  81                 msg = convai2_world.get_acts()[0]
  82                 break
  83         txt = msg.get('text', '').split('\n')
  84         bot_persona = ""
  85         for t in txt:
  86             if t.startswith("partner's persona:"):
  87                 print(t.replace("partner's ", 'your '))
  88             if t.startswith('your persona:'):
  89                 bot_persona += t + '\n'
  90         print("Enter [DONE] if you want a new partner at any time.")
  91         return bot_persona
  92 
  93     # Now run interactive mode, chatting with personas!
  94     cnt = 0
  95     while True:
  96         if cnt == 0:
  97             bot_persona = get_new_personas()
  98         # Run the parts of world.parley() in turn,
  99         # but insert persona into user message.
  100         acts = world.acts
  101         agents = world.agents
  102         acts[0] = agents[0].act()
  103         # add the persona on to the first message
  104         if cnt == 0:
  105             acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')
  106         agents[1].observe(acts[0])
  107         acts[1] = agents[1].act()
  108         agents[0].observe(acts[1])
  109         world.update_counters()
  110         cnt = cnt + 1
  111 
  112         if opt.get('display_examples'):
  113             print("---")
  114             print(world.display())
  115         if world.episode_done():
  116             print("CHAT DONE ")
  117             print("In case you were curious you were talking to this bot:")
  118             print(bot_persona.split('\n'))
  119             print("\n... preparing new chat... \n")
  120             cnt = 0
  121 
  122 
  123 if __name__ == '__main__':
  124     random.seed(42)
  125     parser = setup_args()
  126     interactive(parser.parse_args(print_args=False), print_parser=parser)
  127
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/projects/convai2/interactive.py b/projects/convai2/interactive.py
  --- a/projects/convai2/interactive.py
  +++ b/projects/convai2/interactive.py
  @@ -102,7 +102,7 @@
           acts[0] = agents[0].act()
           # add the persona on to the first message
           if cnt == 0:
  -            acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')
  +            acts[0].force_set('text', bot_persona + acts[0].get('text', 'hi'))
           agents[1].observe(acts[0])
           acts[1] = agents[1].act()
           agents[0].observe(acts[1])
  
verification_info: {"golden_diff": "diff --git a/projects/convai2/interactive.py b/projects/convai2/interactive.py\n--- a/projects/convai2/interactive.py\n+++ b/projects/convai2/interactive.py\n@@ -102,7 +102,7 @@\n         acts[0] = agents[0].act()\n         # add the persona on to the first message\n         if cnt == 0:\n-            acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')\n+            acts[0].force_set('text', bot_persona + acts[0].get('text', 'hi'))\n         agents[1].observe(acts[0])\n         acts[1] = agents[1].act()\n         agents[0].observe(acts[1])\n", "issue": "projects/convai2/interactive.py not using new message force_set feature\n**Bug description**\r\nThe code hasn't been updated for the force_set.\r\n\r\n**Reproduction steps**\r\npython projects/convai2/interactive.py -mf models:convai2/seq2seq/convai2_self_seq2seq_model -m legacy:seq2seq:0 --no_cuda\r\n\r\n**Expected behavior**\r\nto just chat\r\n\r\n**Logs**\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"projects/convai2/interactive.py\", line 126, in <module>\r\n    interactive(parser.parse_args(print_args=False), print_parser=parser)\r\n  File \"projects/convai2/interactive.py\", line 105, in interactive\r\n    acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')\r\n  File \"/home/ubuntu/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/parlai-0.1.0-py3.6.egg/parlai/core/message.py\", line 26, in __setitem__\r\n    'please use the function `force_set(key, value)`.'.format(key)\r\nRuntimeError: Message already contains key `text`. If this was intentional, please use the function `force_set(key, value)`.\r\n```\r\n\r\n**Additional context**\r\npossible fix\r\n```\r\nindex 61ead742..9d478d75 100644\r\n--- a/projects/convai2/interactive.py\r\n+++ b/projects/convai2/interactive.py\r\n@@ -102,7 +102,8 @@ def interactive(opt, print_parser=None):\r\n         acts[0] = agents[0].act()\r\n         # add the persona on to the first message\r\n         if cnt == 0:\r\n-            acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')\r\n+            #acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')\r\n+            acts[0].force_set('text',bot_persona + acts[0].get('text', 'hi'))\r\n         agents[1].observe(acts[0])\r\n\r\n```\r\n\n", "before_files": [{"content": "#!/usr/bin/env python3\n\n# Copyright (c) Facebook, Inc. and its affiliates.\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\"\"\"\nBasic script which allows local human keyboard input to talk to a trained model.\n\nExamples\n--------\n\n.. code-block:: shell\n\n  python projects/convai2/interactive.py -mf models:convai2/kvmemnn/model\n\nWhen prompted, chat with the both, you will both be assigned personalities!\nUse \"[DONE]\" to indicate you are done with that chat partner, and want a new one.\n\"\"\"\nfrom parlai.core.params import ParlaiParser\nfrom parlai.core.agents import create_agent\nfrom parlai.core.worlds import create_task\nfrom parlai.agents.repeat_label.repeat_label import RepeatLabelAgent\nfrom parlai.agents.local_human.local_human import LocalHumanAgent\n\nimport random\n\n\ndef setup_args(parser=None):\n    if parser is None:\n        parser = ParlaiParser(True, True, 'Interactive chat with a model')\n    parser.add_argument('-d', '--display-examples', type='bool', default=False)\n    parser.add_argument(\n        '--display-prettify',\n        type='bool',\n        default=False,\n        help='Set to use a prettytable when displaying '\n        'examples with text candidates',\n    )\n    parser.add_argument(\n        '--display-ignore-fields',\n        type=str,\n        default='label_candidates,text_candidates',\n        help='Do not display these fields',\n    )\n    parser.set_defaults(model_file='models:convai2/kvmemnn/model')\n    LocalHumanAgent.add_cmdline_args(parser)\n    return parser\n\n\ndef interactive(opt, print_parser=None):\n    if print_parser is not None:\n        if print_parser is True and isinstance(opt, ParlaiParser):\n            print_parser = opt\n        elif print_parser is False:\n            print_parser = None\n    if isinstance(opt, ParlaiParser):\n        print('[ Deprecated Warning: interactive should be passed opt not Parser ]')\n        opt = opt.parse_args()\n    opt['task'] = 'parlai.agents.local_human.local_human:LocalHumanAgent'\n    # Create model and assign it to the specified task\n    agent = create_agent(opt, requireModelExists=True)\n    world = create_task(opt, agent)\n    if print_parser:\n        # Show arguments after loading model\n        print_parser.opt = agent.opt\n        print_parser.print_args()\n\n    # Create ConvAI2 data so we can assign personas.\n    convai2_opt = opt.copy()\n    convai2_opt['task'] = 'convai2:both'\n    convai2_agent = RepeatLabelAgent(convai2_opt)\n    convai2_world = create_task(convai2_opt, convai2_agent)\n\n    def get_new_personas():\n        # Find a new episode\n        while True:\n            convai2_world.parley()\n            msg = convai2_world.get_acts()[0]\n            if msg['episode_done']:\n                convai2_world.parley()\n                msg = convai2_world.get_acts()[0]\n                break\n        txt = msg.get('text', '').split('\\n')\n        bot_persona = \"\"\n        for t in txt:\n            if t.startswith(\"partner's persona:\"):\n                print(t.replace(\"partner's \", 'your '))\n            if t.startswith('your persona:'):\n                bot_persona += t + '\\n'\n        print(\"Enter [DONE] if you want a new partner at any time.\")\n        return bot_persona\n\n    # Now run interactive mode, chatting with personas!\n    cnt = 0\n    while True:\n        if cnt == 0:\n            bot_persona = get_new_personas()\n        # Run the parts of world.parley() in turn,\n        # but insert persona into user message.\n        acts = world.acts\n        agents = world.agents\n        acts[0] = agents[0].act()\n        # add the persona on to the first message\n        if cnt == 0:\n            acts[0]['text'] = bot_persona + acts[0].get('text', 'hi')\n        agents[1].observe(acts[0])\n        acts[1] = agents[1].act()\n        agents[0].observe(acts[1])\n        world.update_counters()\n        cnt = cnt + 1\n\n        if opt.get('display_examples'):\n            print(\"---\")\n            print(world.display())\n        if world.episode_done():\n            print(\"CHAT DONE \")\n            print(\"In case you were curious you were talking to this bot:\")\n            print(bot_persona.split('\\n'))\n            print(\"\\n... preparing new chat... \\n\")\n            cnt = 0\n\n\nif __name__ == '__main__':\n    random.seed(42)\n    parser = setup_args()\n    interactive(parser.parse_args(print_args=False), print_parser=parser)\n", "path": "projects/convai2/interactive.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\n# Copyright (c) Facebook, Inc. and its affiliates.\n# This source code is licensed under the MIT license found in the\n# LICENSE file in the root directory of this source tree.\n\"\"\"\nBasic script which allows local human keyboard input to talk to a trained model.\n\nExamples\n--------\n\n.. code-block:: shell\n\n  python projects/convai2/interactive.py -mf models:convai2/kvmemnn/model\n\nWhen prompted, chat with the both, you will both be assigned personalities!\nUse \"[DONE]\" to indicate you are done with that chat partner, and want a new one.\n\"\"\"\nfrom parlai.core.params import ParlaiParser\nfrom parlai.core.agents import create_agent\nfrom parlai.core.worlds import create_task\nfrom parlai.agents.repeat_label.repeat_label import RepeatLabelAgent\nfrom parlai.agents.local_human.local_human import LocalHumanAgent\n\nimport random\n\n\ndef setup_args(parser=None):\n    if parser is None:\n        parser = ParlaiParser(True, True, 'Interactive chat with a model')\n    parser.add_argument('-d', '--display-examples', type='bool', default=False)\n    parser.add_argument(\n        '--display-prettify',\n        type='bool',\n        default=False,\n        help='Set to use a prettytable when displaying '\n        'examples with text candidates',\n    )\n    parser.add_argument(\n        '--display-ignore-fields',\n        type=str,\n        default='label_candidates,text_candidates',\n        help='Do not display these fields',\n    )\n    parser.set_defaults(model_file='models:convai2/kvmemnn/model')\n    LocalHumanAgent.add_cmdline_args(parser)\n    return parser\n\n\ndef interactive(opt, print_parser=None):\n    if print_parser is not None:\n        if print_parser is True and isinstance(opt, ParlaiParser):\n            print_parser = opt\n        elif print_parser is False:\n            print_parser = None\n    if isinstance(opt, ParlaiParser):\n        print('[ Deprecated Warning: interactive should be passed opt not Parser ]')\n        opt = opt.parse_args()\n    opt['task'] = 'parlai.agents.local_human.local_human:LocalHumanAgent'\n    # Create model and assign it to the specified task\n    agent = create_agent(opt, requireModelExists=True)\n    world = create_task(opt, agent)\n    if print_parser:\n        # Show arguments after loading model\n        print_parser.opt = agent.opt\n        print_parser.print_args()\n\n    # Create ConvAI2 data so we can assign personas.\n    convai2_opt = opt.copy()\n    convai2_opt['task'] = 'convai2:both'\n    convai2_agent = RepeatLabelAgent(convai2_opt)\n    convai2_world = create_task(convai2_opt, convai2_agent)\n\n    def get_new_personas():\n        # Find a new episode\n        while True:\n            convai2_world.parley()\n            msg = convai2_world.get_acts()[0]\n            if msg['episode_done']:\n                convai2_world.parley()\n                msg = convai2_world.get_acts()[0]\n                break\n        txt = msg.get('text', '').split('\\n')\n        bot_persona = \"\"\n        for t in txt:\n            if t.startswith(\"partner's persona:\"):\n                print(t.replace(\"partner's \", 'your '))\n            if t.startswith('your persona:'):\n                bot_persona += t + '\\n'\n        print(\"Enter [DONE] if you want a new partner at any time.\")\n        return bot_persona\n\n    # Now run interactive mode, chatting with personas!\n    cnt = 0\n    while True:\n        if cnt == 0:\n            bot_persona = get_new_personas()\n        # Run the parts of world.parley() in turn,\n        # but insert persona into user message.\n        acts = world.acts\n        agents = world.agents\n        acts[0] = agents[0].act()\n        # add the persona on to the first message\n        if cnt == 0:\n            acts[0].force_set('text', bot_persona + acts[0].get('text', 'hi'))\n        agents[1].observe(acts[0])\n        acts[1] = agents[1].act()\n        agents[0].observe(acts[1])\n        world.update_counters()\n        cnt = cnt + 1\n\n        if opt.get('display_examples'):\n            print(\"---\")\n            print(world.display())\n        if world.episode_done():\n            print(\"CHAT DONE \")\n            print(\"In case you were curious you were talking to this bot:\")\n            print(bot_persona.split('\\n'))\n            print(\"\\n... preparing new chat... \\n\")\n            cnt = 0\n\n\nif __name__ == '__main__':\n    random.seed(42)\n    parser = setup_args()\n    interactive(parser.parse_args(print_args=False), print_parser=parser)\n", "path": "projects/convai2/interactive.py"}]}