A Guile Scheme implementation demonstrating the interaction between an Application (Actor 1) and an LLM Provider (Actor 2) for function calling capabilities.
View detailed sequence diagram
This project implements a two-actor pattern for LLM function calling, providing:
- Clear separation between application logic and LLM reasoning
- Asynchronous message passing between actors
- Extensible function registry
- Thread-safe communication channels
The system consists of two main actors:
- Application Actor: Manages function definitions, executes requested functions, and handles results
- LLM Actor: Processes prompts, decides whether to call functions or respond directly, and generates final answers
Communication happens through message queues with defined message types for each phase of interaction.
- GNU Guile 3.0 or later
- SRFI modules (srfi-1, srfi-9)
- ice-9 modules (match, format, threads)
git clone https://github.com/aygp-dr/llm-function-actors
cd llm-function-actors
gmake run
gmake demo
# or directly:
./examples/function-calling-demo.scm
The simulator comes with two built-in functions:
calculate
: Adds two numbersget-time
: Returns current timestamp
Additional functions can be registered:
(register-function! 'my-function
(lambda (arg1 arg2)
;; function implementation
result))
. ├── SETUP.org # Original design document ├── README.org # This file ├── Makefile # Build automation ├── src/ │ └── function-calling-simulator.scm # Main simulator ├── examples/ │ └── function-calling-demo.scm # Usage examples └── docs/ ├── function-flow.org # Sequence diagrams └── pattern-analysis.org # Architecture analysis
- Application sends initial prompt with function definitions
- LLM analyzes prompt and decides action
- If function needed: LLM requests function execution
- Application executes function and returns result
- LLM incorporates result and generates final answer
To add new capabilities:
- Register new functions using
register-function!
- Extend message types for new interaction patterns
- Add error handling for production use
- Implement timeout mechanisms for long-running functions
This project is part of the aygp-dr repository.