-
Notifications
You must be signed in to change notification settings - Fork 533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add from_file
class method to the Prompt
object
#1345
Comments
What does the user code look like currently, and what would it look like after this change? This seems like a pretty standard design. Would you, at some point, like to have a CLI automation tool that helps users extract docstrings of interest to external files in a given subfolder, to help “standardize” what a project using outlines would look like? |
Why?Currently people would write their prompt in a long block between Current designThe current way to build import outlines
@outlines.prompt
def prompt_template(a: int, b: int):
"""You are a calculator.
What is {{ a }} + {{ b }}?""" This is not great design, and will be refactored for v1.0. For now we will keep this, but add the Other points
Maybe in a distant future, after we've had confirmation from users that transitioning is a pain point |
Just to specify a little more the user interface. Assume the following file structure:
such that
In from outlines import Prompt
template = Prompt.from_file("prompt.txt") So that we can can render the template as follows: examples = ... # List of NamedTuples for instance
question = "What is the Earth's diameter?"
prompt = template(examples, question)
print(prompt)
# The rendered prompt as a string So we'll need to extract the variables from the template. We need to be able to do so even with Jinja templates that use template inheritance or simple includes. The signature of the |
We keep coming back to the following pattern: first write the prompt in docstrings, and move it to a text file once it gets too large. It would be nice if Outlines made it easy for users to generate a prompt template from a text file. The file can contain plain text, or be written using the Jinja2 templating syntax.
I propose to add a
from_file
classmethod, which reads the file, extracts the names of the free variables (if any) in the template, and returns aPrompt
instance.The text was updated successfully, but these errors were encountered: