Skip to content

Generation from partially done JSON/List #694

Answered by rlouf
isamu-isozaki asked this question in Q&A
Discussion options

You must be logged in to vote

If I understand correctly you can already do this, and it could be handled more elegantly once #667 is implemented. For instance:

gen_choice = generate.choice(model, [", ", "]"])
gen_task = generate.json(model, BaseTask)

prompt = "[BaseTask1, BaseTask"
while True:
    result = gen_choice(prompt)
    if result == "]":
        return prompt + "]"
    else:
        prompt += ", "
        result = gen_task(prompt)
        prompt += result

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@isamu-isozaki
Comment options

Answer selected by isamu-isozaki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #689 on February 21, 2024 12:27.