The HeliconeManualLogger class can be used to log any Vector DB interactions to Helicone.

1

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

pip install helicone-helpers
2

Create a new HeliconeManualLogger instance

def vector_db_operation(result_recorder: HeliconeResultRecorder):
    # your vector db operation 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: "vector_db",
    operation: "search", # The operation performed
    # other data which you want to store about the vector db call
  },
  operation=vector_db_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: "vector_db";
  operation: "search" | "insert" | "delete" | "update";
  text: Optional[str];
  vector: Optional[List[float]];
  topK: Optional[int];
  filter: Optional[dict];
  databaseName: Optional[str];
  # 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