Skip to content

A LLM agent capable of writing an API documentation and functional tests from a file containing the entrypoints code.

Notifications You must be signed in to change notification settings

Aschen/func-test-agent-llm

Repository files navigation

API Documentation and Functional Tests Agent

This project is a collection of agents working together to write the documentation and functional tests of an API.

Here is the workflow:

  • ExtractEntrypointsAgent: read a file and extract the code of all API routes entrypoints
  • for each entrypoint:
    -- WalkCallStackAgent: retrieve all the functions involved in the API route
    -- DocumentationAgent: write API documentation according to the code of the functions
    -- WriteTestsAgent: read the documentation of an API route and list all the possible test cases
    -- for each test case:
    --- describe what would be needed to test the current case (setup, teardown, test, matchers, etc)
    --- use the test description, route documentation and feedback from Jest runner (if any) to write the code
    --- run the code
    --- (repeat until all the tests pass)

The WriteTestsAgent use a chain of 2 prompt.

  • the first prompt is used to focus the LLM on writing the expected specifications for each test case
  • the second prompt focus the LLM attention on writing and correcting the corresponding test code (it analyze error message from Jest runner to fix the code iteratively)

Example

The code present in examples/fastify/doc and examples/fastify/tests has been generated by the agents.

To try yourself, run npx ts-node run.ts and be patient

About

A LLM agent capable of writing an API documentation and functional tests from a file containing the entrypoints code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published