transitive-bullshit / OpenOpenAI

Self-hosted version of OpenAI’s new stateful Assistants API
MIT License
509 stars 44 forks source link

Add support for custom models #1

Open transitive-bullshit opened 11 months ago

transitive-bullshit commented 11 months ago

Currently, the models is hard-coded to use the OpenAI chat completion API, but it wouldn't be very difficult to use custom LLMs or external model providers.

The only real constraint is that the custom models need to support function calling and/or ideally parallel tool calling using OpenAI's tool_calls format.

Will consider implementing this depending on how much love this issue gets.

ChuckJonas commented 9 months ago

Seems like this could be done using one of the function calling models on hugging face.

Most of the work would just revolve around converting the open.chat.completions payload to a prompt that the model likes.

Looking at the example notebook, the format seems to be something like this:

<s> <FUNCTIONS>{
    "function": "search_bing",
    "description": "Search the web for content on Bing. This allows users to search online/the internet/the web for content.",
    "arguments": [
        {
            "name": "query",
            "type": "string",
            "description": "The search query string"
        }
    ]
}</FUNCTIONS>

[INST] Search bing for the tallest mountain in Ireland [/INST]
</s>

Was able to run this using a hugging face endpoint with Llama-2-7b-chat-hf-function-calling-v2, and it seemed to work ok.

praneybehl commented 8 months ago

Possibly add support for Mistral API? Ref: https://docs.mistral.ai/platform/overview/