Skip to content

Utils

get_plugin_response_content

get_plugin_response_content(output)

Wrapper for AgentOutput content return

Source code in libs/kotaemon/kotaemon/agents/utils.py
def get_plugin_response_content(output) -> str:
    """
    Wrapper for AgentOutput content return
    """
    if isinstance(output, Document):
        return output.text
    else:
        return str(output)

calculate_cost

calculate_cost(model_name, prompt_token, completion_token)

Calculate the cost of a prompt and completion.

Returns:

Name Type Description
float float

Cost of the provided model name with provided token information

Source code in libs/kotaemon/kotaemon/agents/utils.py
def calculate_cost(model_name: str, prompt_token: int, completion_token: int) -> float:
    """
    Calculate the cost of a prompt and completion.

    Returns:
        float: Cost of the provided model name with provided token information
    """
    # TODO: to be implemented
    return 0.0