Utilities to convert from the Horde LLM endpoint format to the OpenAI Chat API format. This allows us to
- use the AI Horde in existing applications that use the OpenAI API
- connect backends offering the OpenAI API to the AI Horde (e.g., Ollama)
Features are restricted to the intersection of both APIs:
- Formatting is not supported (
frmtadsnsp,frmtrmblln,frmtrmspch,frmttriminc,singleline)- There are utility functions for this tho and can be done by the proxy.
max_context_lengthis a constant passed to the converter.- Not supported at all are a, k, tfs, and typical sampling, and
rep_pen_range,rep_pen_slope,use_default_badwordsids,smoothing_factor,dynatemp_range,dynatemp_exponent - Only the first
modelis used.
- System message is not always supported, e.g., on Gemma based models.
logprobs,logit_biasis not supported.- Any response format or structured format is not supported.
- No tools, functions, seed, or streaming.
modelis a comma-separated list of models.
Convert freely between the two formats with the following functions:
from horde_openai_proxy import horde_to_openai, openai_to_horde, ChatCompletionRequest, HordeRequest
a: HordeRequest = ...
b: ChatCompletionRequest = horde_to_openai(a)
a: HordeRequest = openai_to_horde(b)horde_openai_proxy/endpoint.py provides a FastAPI example on how to access the AI Horde via
the OpenAI API, with a utility endpoint to retrieve filtered models.
horde_openai_proxy/bridge.py provides an example bridge, however it heavily struggles with keeping character.
Included are also utilities to clean up the model zoo mess:
- get_models() to fetch currently active models with name, parameters, quantization, and base model.
- apply_template() to convert a list of messages into a prompt.
Login or provide your HF token as HF_TOKEN env var to access restricted models.
You also have to manually accept all baseline models.
- data contains mappings between (partial) names and base model, param sizes, and base models and their template.
- horde_openai_proxy/chat_templates needs to be updated once in a while.