The HeliconeManualLogger class can be used to log any external tools used in your LLM applications to Helicone.

1

To get started, install the `helicone-helpers` package

pip install helicone-helpers
2

Create a new HeliconeManualLogger instance

from helicone_helpers import HeliconeManualLogger

heliconeLogger = HeliconeManualLogger(
  api_key="your-helicone-api-key", # Can be set as env variable
  headers={} # Additional headers to be sent with the request
);
3

Log your request

def tool_call_operation(result_recorder: HeliconeResultRecorder):
    # your tool call here
    # you can access the request using result_recorder.request
    result_recorder.appendResults({
      ... # The results of the operation (this will be logged to Helicone)
    })
    return results # this will be returned by the logRequest function

res = heliconeLogger.logRequest(
  request={
    _type: "tool",
    toolName: "...", # The name of the tool used
    input: ..., # The input to the tool
    # other data which you want to store about the tool call
  },
  operation=tool_call_operation,
  additional_headers={
    # Additional headers to be sent with the request
  }
);

API Reference

HeliconeManualLogger

class HeliconeManualLogger:
    api_key: str
    headers: dict
    logging_endpoint: str # defaults to https://api.hconeai.com/custom/v1/log

logRequest

log_request(
      self,
      request: dict,
      operation: Callable[[HeliconeResultRecorder], T],
      additional_headers: dict = {},
      provider: Optional[Union[Literal["openai", "anthropic"], str]] = None, # for tools you don't have to specify the provider
  ) -> T

Parameters

  1. request: - The request object to log
{
  _type: "tool";
  toolName: str;
  input: any;
  # other data which you want to store about the tool call
}
  1. operation: Callable[[HeliconeResultRecorder], T] - The operation to be executed and logged
class HeliconeResultRecorder:
    def __init__(self, request: dict):
        self.request = request
        self.results = {}

    def append_results(self, data: dict):
        self.results.update(data)

    def get_results(self):
        return self.results
  1. additionalHeaders: dict