Skip to content

Add functions setter for LLMs #228

@pedro-a-n-moreira

Description

@pedro-a-n-moreira

I have a specific case where I'm modifying the functions' description, mostly enum options, at run time. The issue is that the current struct-based approach makes it too difficult.

The solution is having a SetFunctions method for the LLM, so we can create our own function's schema. This two lines of code will save a lot of pain:

// File: llm/openai/function.go

// SetFunctions is a setter the functions list
func (o *OpenAI) SetFunctions(funcs map[string]Function) { o.functions = funcs }

I have tried to bypass the function binding tool by using the invopop/jsonschema custom types support, but it doesn't work due to how LinGoose and OpenAI SDK handle serialization.

The proposed changes are addressed in this PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions