FormulaMonks / kurt

A wrapper for AI SDKs, for building LLM-agnostic structured AI applications in Typescript
MIT License
2 stars 0 forks source link

chore(example): created runnable example #38

Closed InfraK closed 1 month ago

InfraK commented 1 month ago

create new example folder with a basic example project, pulling in the required dependencies, updated readme files to point to this new folder

jemc commented 1 month ago

If these runnable examples are meant to replace the ones that were in the documentation, I'd prefer to have each example be its own file. As it stands, I think this PR improves testability of the code examples, but degrades the discoverability and readability of the code examples. I'd like to find a way to solve for both.

Additionally, as it stands currently, if I want to just run an example, I end up running all of the examples, and I also need to have credentials for every possible adapter that Kurt has.

I can see why you wanted to keep things DRY and avoid the expansion of generation examples multiplied by the number of adapter examples. However, I'd like to propose a different approach to solving that problem. Rather than having the top-level file be a consolidated place where all examples are run, I think it would be best to do have each example separate, but use a consolidated function for Kurt setup. Here's my concrete proposal:

This approach has a few benefits to mention:

What do you think?

InfraK commented 1 month ago

I mostly agree with everything, I'll take another pass at the comment tomorrow, but I think that we might want to use hard-coded values with multiple entry-points, one for each adapter, this at least gives more visibility into how the examples work, and we leave env variables strictly for credentials management, since the env files are not committed

I may just give you a brief call tomorrow so that we can align on an approach.

InfraK commented 1 month ago

So, after putting some more thought into it, given that these are meant to be examples, keeping it DRY doesn't make much sense, the priority should be in simplicity.

I'm thinking at this moment to create the following examples:

The environment variables will be used across all the examples for credentials, each example should be able to run on its own, as well as documenting how to run them in the readme.

How does this sound?

jemc commented 1 month ago

@InfraK - That sounds good.

I think the one thing I'd suggest is to ensure that in the model-agnostic example, we should show all three generation methods (similar to the 3 examples in the current Kurt README).

In a followup PR I will make a script that runs as a prepackage hook to copy snippets from each example file into the markdown READMEs prior to NPM publish.

InfraK commented 1 month ago

@jemc In order to keep the pull requests small, I'll split the examples here and leave the model-agnostic one for a follow up, does that sound good?

jemc commented 1 month ago

Sounds good!

github-actions[bot] commented 1 week ago

:tada: This PR is included in version @formula-monks/kurt-v1.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 week ago

:tada: This PR is included in version @formula-monks/kurt-open-ai-v1.5.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 1 week ago

:tada: This PR is included in version @formula-monks/kurt-vertex-ai-v1.4.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: