voxel51/voxelgpt

[BUG] FewShotPromptTemplate formatting error

ehofesmann opened this issue · 0 comments

I got this error when trying the query "show me all cats and dogs in the dataset" on the quickstart dataset. It seems to be due to the parsing of this example:

{'input': 'map the cat and dog animal labels to pet and shark to wild', 'output': "[map_labels(\r\n    'animal', {'cat': 'pet', 'dog': 'pet', 'shark':'wild'}\r\n)]"}

Which I assume is some issue with the curly braces. We may need to change how this formatting is done, or remove examples that include dictionaries.

<ipython-input-82-40d757423699> in <module>
      1 for example in examples:
      2     print(example)
----> 3     FewShotPromptTemplate(
      4         examples=[example],
      5         example_prompt=example_prompt,

~/.pyenv/versions/3.9.13/envs/fo/lib/python3.9/site-packages/langchain/prompts/few_shot.py in format(self, **kwargs)
    114
    115         # Format the template with the input variables.
--> 116         return DEFAULT_FORMATTER_MAPPING[self.template_format](template, **kwargs)
    117
    118     @property

~/.pyenv/versions/3.9.13/lib/python3.9/string.py in format(self, format_string, *args, **kwargs)
    159 class Formatter:
    160     def format(self, format_string, /, *args, **kwargs):
--> 161         return self.vformat(format_string, args, kwargs)
    162
    163     def vformat(self, format_string, args, kwargs):

~/.pyenv/versions/3.9.13/envs/fo/lib/python3.9/site-packages/langchain/formatting.py in vformat(self, format_string, args, kwargs)
     27                 "everything should be passed as keyword arguments."
     28             )
---> 29         return super().vformat(format_string, args, kwargs)
     30
     31     def validate_input_variables(

~/.pyenv/versions/3.9.13/lib/python3.9/string.py in vformat(self, format_string, args, kwargs)
    163     def vformat(self, format_string, args, kwargs):
    164         used_args = set()
--> 165         result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
    166         self.check_unused_args(used_args, args, kwargs)
    167         return result

~/.pyenv/versions/3.9.13/lib/python3.9/string.py in _vformat(self, format_string, args, kwargs, used_args, recursion_depth, auto_arg_index)
    203                 # given the field_name, find the object it references
    204                 #  and the argument it came from
--> 205                 obj, arg_used = self.get_field(field_name, args, kwargs)
    206                 used_args.add(arg_used)
    207

~/.pyenv/versions/3.9.13/lib/python3.9/string.py in get_field(self, field_name, args, kwargs)
    268         first, rest = _string.formatter_field_name_split(field_name)
    269
--> 270         obj = self.get_value(first, args, kwargs)
    271
    272         # loop through the rest of the field_name, doing

~/.pyenv/versions/3.9.13/lib/python3.9/string.py in get_value(self, key, args, kwargs)
    225             return args[key]
    226         else:
--> 227             return kwargs[key]
    228
    229

KeyError: "'cat'"