# Hermes-Function-Calling

> An open-source Python library enabling the Hermes Pro LLM to perform structured function calling and JSON mode inference using a ChatML prompt format.

Hermes-Function-Calling is an open-source repository by NousResearch that enables the Hermes Pro Large Language Model to perform structured function calling and JSON mode inference. It provides a complete inference pipeline with recursive tool-call execution, Pydantic-based schema validation, and OpenAI-compatible ChatML prompt formatting. The project supports both function calling (where the model selects and invokes tools) and JSON mode (where the model generates structured outputs conforming to a given schema).

- **Function Calling Inference** — *Run `functioncall.py` with a natural language query; the model selects the appropriate tool, generates a structured `tool_call` JSON, executes it, and returns a natural language response.*
- **JSON Mode / Structured Outputs** — *Use `jsonmode.py` with a Pydantic model schema to force the model to respond with a valid JSON object matching your schema.*
- **Custom Function Support** — *Add new tools by defining Python functions decorated with `@tool` in `functions.py` and registering them in `get_openai_tools()`.*
- **Custom Pydantic Models** — *Define your own Pydantic `BaseModel` classes and serialize them to JSON schema for use in JSON mode inference.*
- **ChatML Prompt Format** — *Uses the ChatML format with `<|im_start|>` / `<|im_end|>` tokens, compatible with OpenAI API conventions and multi-turn dialogue.*
- **Hermes-3 GOAP Reasoning** — *Supports Goal Oriented Action Planning (GOAP) via `<scratch_pad>` tags for structured reasoning before tool invocation.*
- **4-bit Quantization Support** — *Load models in 4-bit precision using bitsandbytes via the `--load_in_4bit` flag for reduced memory usage.*
- **Few-Shot Examples** — *Optionally include few-shot examples via `--num_fewshot` to guide model behavior.*
- **Recursive Depth Control** — *Configure maximum recursive function call iterations with `--max_depth` to prevent infinite loops.*
- **yfinance Integration** — *Built-in financial data functions (stock prices, fundamentals, financial statements) using the yfinance library as demonstration tools.*

## Features
- Function calling inference with recursive tool execution
- JSON mode / structured output generation
- ChatML prompt format (OpenAI-compatible)
- Custom function and tool registration
- Pydantic model schema support
- Hermes-3 GOAP reasoning with scratch_pad
- 4-bit quantization via bitsandbytes
- Few-shot example support
- Configurable recursive depth
- yfinance-based financial data tools

## Integrations
yfinance, Hugging Face Transformers, bitsandbytes, Pydantic, PyTorch

## Platforms
CLI, API, DEVELOPER_SDK

## Pricing
Open Source

## Links
- Website: https://github.com/NousResearch/Hermes-Function-Calling
- Documentation: https://github.com/NousResearch/Hermes-Function-Calling/blob/main/README.md
- Repository: https://github.com/NousResearch/Hermes-Function-Calling
- EveryDev.ai: https://www.everydev.ai/tools/hermes-function-calling
