Fizz - the function wizard for LLMs.
npm install @monteloai/fizzFizz - the LLM function wizard.
Fizz is a tool to help you write LLM functions. It works by organizing your functions into files,
and attaching a schema, description, and handler to each tool.
Fizz will then generate a type-safe client for you, which you can use in your LLM calls. It will
generate the schema to pass into the LLM call based on your schema, leaving you to focus on writing
your function.
``bash`
npm install @monteloai/fizz@latest
Then init to create the fizz.config.json.
`bash`
npx fizz init
This will create a fizz.config.json file at the root of your project, add a functions
directory, and an example function.
`json lines`
{
"functionsDirectory": "src/functions"
}
Example directory structure:
`bash`
your-project/
├── functions/
│ ├── getCurrentWeather.ts
│ └── getFutureWeather.ts
├── package.json
└── tsconfig.json
Each file should look something like this. Notice that the function is exported as default.
`ts
import { FizzFunction } from "@monteloai/fizz";
import { z } from "zod";
const FunctionInput = z.object({
location: z.string().describe("The city, e.g San Francisco."),
unit: z.enum(["Celsius", "Fahrenheit"]).describe("The unit of temperature."),
});
type TFunctionInput = z.infer
const getCurrentWeather = async (params: TFunctionInput): Promise
return The weather in ${params.location} is currently 22 degrees ${params.unit}.;
};
export default FizzFunction({
function: getCurrentWeather,
description: "Get the current weather in a given location.",
schema: FunctionInput,
});
`
You've now created a function. You can create as many functions as you want, and they can be
organized into subdirectories.
Now you can generate a client for your function.
Simply run:
`bash`
npx fizz generate
And a type-safe client will be generated for you, which you can access as
`ts`
import { functions, getAllSchemas } from "@monteloai/fizz";
This client will have the schema, description, and handler attached to it, so you can use it like
this:
`ts
import { functions, getAllSchemas } from "@monteloai/fizz";
openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{ role: "user" as const, content: "What's the weather in New York right now?" }],
// as a tool
tools: getAllSchemas(),
// or as a function
functions: getAllSchemas().map((schema) => schema.function),
// specific tool only
// notice your IDE will autocomplete here!
tools: [functions.getCurrentWeather.schema],
});
`
- ✅ Introduce a config for fizz to change the default directory
- ✅ Find nicer naming and APIs (FizzFunction instead of createFunction?)functions.getAllDefinitions()
- ✅ Add a get all api describe
- Add a check to make sure that every input field has a on itcreateFunction`
- Support Joi/Yup/TypeBox/other schema libraries. Also refactor code base to make this an easy
process.
- Add decorator support instead of
- Add tests
- Browser support
- Remove zodToJsonSchema as dependency, write our own
- Looking into supporting other models