Skip to content

Conversation

@anotherjesse
Copy link
Contributor

@anotherjesse anotherjesse commented Oct 4, 2024

generateData -> llm

  • simplified generate code to just be about LLM conversations
  • moves all the logic around prep / parsing / ... to recipe
  • ergo - json / html mode is now handled by lift inside recipes
  • example of using Zod / schemas to parse json results

llm improvements:

  • streaming
  • stop sequences
  • support for multiple messages (user -> assistant -> user -> assistant)
  • support for putting words into LLMs mouth (forcing it to generate json)
  • support for (base64) images

common file input:

  • added ability to load images / json data from file input

@anotherjesse anotherjesse force-pushed the streaming branch 2 times, most recently from 5102460 to 42928a7 Compare October 4, 2024 20:28
@anotherjesse
Copy link
Contributor Author

todo:

  • cleanup schema helpers / patterns (perhaps leverage zod?)
  • @seefeldb had mentioned migrating generateData to being a recipe - I used lifts...
  • is there a way to return multiple values from a lift?
        const { result: jsonResult } = generateText({
            messages: generateJSONMessages({ jsonprompt }),
            system: "You are a helpful assistant that generates JSON objects for testing.  Respond in JSON",
            stop: '```'
        });

replace that with something like:

        const { result: jsonResult } = generateText( prep({ jsonprompt }) )

perhaps this is the recipe idea @seefeldb had mentioned

@seefeldb
Copy link
Contributor

seefeldb commented Oct 6, 2024

Ah yes, when I meant convert to a recipe, I meant to a combination of recipe and lifted functions.

Lifted functions can return { multiple, things }, which you can then use in the recipe as const { multiple, things } = lifted_function(params).

@anotherjesse
Copy link
Contributor Author

cool - it might be nice to do:

   const maybeHtml = parse(generateText(prep({ prompt })

@seefeldb
Copy link
Contributor

seefeldb commented Oct 7, 2024

Yes, this should work! From a caller's perspective there is no difference between a lifted function or a recipe, btw.

@anotherjesse anotherjesse changed the title WIP Streaming generateData -> llm + lift methods Oct 8, 2024
@anotherjesse anotherjesse requested a review from seefeldb October 8, 2024 17:02
Copy link
Contributor

@seefeldb seefeldb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ship it! looks good overall and we can iterate over details later.

@anotherjesse anotherjesse merged commit 4931e75 into main Oct 8, 2024
3 of 11 checks passed
@anotherjesse anotherjesse deleted the streaming branch October 8, 2024 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants