From 85a06fd2582dd9f4d65c318542f945987a24664f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Grie=C3=9Fhaber?= <griesshaber@hdm-stuttgart.de> Date: Thu, 7 Mar 2024 08:47:10 +0100 Subject: [PATCH] add autogenerated prompt id --- utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 07a6c10..7548aa1 100644 --- a/utils.py +++ b/utils.py @@ -1,7 +1,7 @@ -from dataclasses import dataclass, field import inspect import json import logging +from dataclasses import dataclass, field from datetime import datetime from functools import wraps from hashlib import shake_256 @@ -96,11 +96,15 @@ class log_calls: @dataclass(frozen=True) class Prompt: + id: str = field(init=False) content: str score: float gen: int meta: dict = field(default_factory=dict) + def __post_init__(self): + self.id = shake_256(self.content.encode() + self.gen.to_bytes()).hexdigest(16) + def __str__(self) -> str: return self.content -- GitLab