File size: 1,040 Bytes
923909d
 
 
 
 
 
 
 
 
 
 
 
 
a02a4b0
 
923909d
 
 
 
 
 
a02a4b0
 
923909d
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from pydantic import UUID4
from supabase import create_client
import os

FEEDBACK_TABLE_NAME = "llm_feedback"


class SupabaseClient:
    def __init__(self):
        url = os.environ.get("SUPABASE_URL")
        key = os.environ.get("SUPABASE_KEY")
        self.client = create_client(url, key)

    def post_feedback(self, run_id: UUID4, metric_type: str, metric_score: float,
                      sub_workflow: str, original_content: dict, modified_content: dict):
        try:
            response = self.client.table(FEEDBACK_TABLE_NAME).insert({
                "run_id": str(run_id),
                "sub_workflow": sub_workflow,
                "metric_type": metric_type,
                "metric_score": metric_score,
                "original_content": original_content,
                "modified_content": modified_content
            }).execute()
            print("Response: ", response)
            return response
        except Exception as exception:
            print("Exception: ", exception)
            return exception