promptslab / Promptify

Prompt Engineering | Prompt Versioning | Use GPT or other prompt based models to get structured output. Join our discord for Prompt-Engineering, LLMs and other latest research
https://discord.gg/m88xfYMbK6
Apache License 2.0
3.21k stars 238 forks source link

The example code fails after installation, MarkupSafe version does not match #9

Closed Huge closed 1 year ago

Huge commented 1 year ago

With python3.10, the code fails with ImportError: cannot import name 'soft_unicode' from 'markupsafe'.

https://github.com/aws/aws-sam-cli/issues/3661#issuecomment-1044340547 helps fixing that. Still with that change, with the introductory example we get

    assert len(variables_missing) == 0, f"Missing required variables in template {variables_missing}"
AssertionError: Missing required variables in template ['labels']

It would be great if the main setup instructions work out of the box.

monk1337 commented 1 year ago

Hi, Sorry for the confusion. I have corrected the main readme.md example. You need to pass labels = None and eval(result['text']). Here is a working example

from promptify import OpenAI
from promptify import Prompter

sentence     =  """The patient is a 93-year-old female with a medical
                history of chronic right hip pain, osteoporosis,
                hypertension, depression, and chronic atrial
                fibrillation admitted for evaluation and management
                of severe nausea and vomiting and urinary tract
                infection"""

model        = OpenAI("your_key")
nlp_prompter = Prompter(model)

result       = nlp_prompter.fit('ner.jinja', domain ='medical', text_input  = sentence, labels = None)
eval(result['text'])
tobwen commented 1 year ago

That's still an issue. It already occures on from promptify import OpenAI.

One solution is to downgrade markersafe: pip install markupsafe==2.0.1