Skip to content

feat: add function calling to ragbits LLM #533

Open
@mhordynski

Description

@mhordynski

Feature description

The LLM class should allow to pass list of tools for function calling.

For example:

async def get_weather(
    location: str,
    units: str
) -> dict:
    """
    Returns the current weather for a given location.
    
    Args:
        location: The location to get the weather for.
        units: The units to use for the weather information.

    Returns:
        The current weather for the given location.
    """
    return await weather_api.get_current_weather(
        location=location,
        units=units
    )


llm = LiteLLM(model_name="gpt-4o-2024-08-06", use_structured_output=True)

await llm.generate(MyPrompt(), tools=[get_weather])

Tools should be definable in the following ways:

  • passing function to tools - schema will be infered and docstring parsed for descriptions etc.
  • passing dictionary in openai tool format

Output of the LLM will be expanded - it may return tool_calls from now on.

Motivation

Adding tools to the LLM class lets it work on its own and handle different tasks easily, allowing to start agentic workflows with ragbits.

Additional context

No response

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions