Skip to content

A java library to construct java objects from LLM output

Notifications You must be signed in to change notification settings

nmnduy/formwork

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FormWork

A java library to construct java objects from LLM output

Usage

Model Definition and Basic Example

// Define your data class
public record UserProfile(String name, int age, String email) {}

// Create FormWork and LLM caller
import io.filesurf.formwork.FormWork;
import java.util.function.Function;

FormWork formWork = new FormWork();
Function<String, String> llmCaller = prompt -> {
    // call your LLM API and return JSON string
    return "{ \"name\": \"Alice\", \"age\": 30, \"email\": \"alice@example.com\" }";
};

// Construct a UserProfile
UserProfile result = formWork.construct(
    UserProfile.class,
    "Generate a UserProfile object",
    llmCaller
);

Custom Retries

// Retry with custom attempts for UserProfile
UserProfile result = formWork.construct(
    UserProfile.class,
    "Generate a UserProfile object",
    llmCaller,
    5
);

About

A java library to construct java objects from LLM output

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages