Skip to content

ParserConstraint #9

@tonxxd

Description

@tonxxd

This seems like a very promising project!
I am trying to execute the ParserConstraint example but it get and error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[10], line 28
     20 openai.api_key = "..."
     23 prompt = Prompt("""
     24 %system%You are a sql expert%/system%
     25 %user%Write me a query that selects the column y from table b.%/user%
     26 """)
---> 28 prompt = await prompt.complete(model=hf, constraint=constraint, name='query', max_tokens=100)
     29 # Prompt('
     30 # %system%You are a sql expert%/system%
     31 # %user%Write me a query that selects the column y from table b.%/user%
     32 # SELECT y FROM b')

File /lib/python3.10/site-packages/keymaker/prompt.py:353, in Prompt.complete(self, *completion_args, **completion_kwargs)
    341         await stream(
    342             Completion(
    343                 value=value,
   (...)
    349             ),
    350         )
    352 while token_count < token_limit:
--> 353     selected_token_ids = await constraint.constrain_tokens(text, partial_completion, model)
    355     if selected_token_ids:
    356         # if the selected tokens have the same number than the vocab size, there's no real restriction
...
    131             model.tokens.keys(),
    132         ),
    133     )

TypeError: unhashable type: 'ParserConstraint'

Any idea why thsi could happen? Thanks

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions