Skip to content

Commit

Permalink
add label embedding field
Browse files Browse the repository at this point in the history
  • Loading branch information
haseebrabbani committed Dec 11, 2023
1 parent f16191b commit a621f0f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions cli/commands/run/server/agent.proto
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ message AlertEvent {
bool remove = 5;
repeated string metadata = 6;
string uniqueKey = 7;
repeated float embedding = 8;
}

// Unique string to identify this class of finding,
Expand Down
1 change: 1 addition & 0 deletions cli/commands/run/server/alert.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ message Label {
string label = 7;
repeated string metadata = 8;
string uniqueKey = 9;
repeated float embedding = 10;
}

message Source {
Expand Down
1 change: 1 addition & 0 deletions python-sdk/src/forta_agent/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def __init__(self, dict):
self.source = LabelSource(dict.get('source')) if dict.get(
'source') is not None else None
self.created_at = dict.get('createdAt', dict.get('created_at'))
self.embedding = dict.get('embedding')

def toDict(self):
d = dict(self.__dict__, **{
Expand Down
10 changes: 7 additions & 3 deletions sdk/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type LabelInput = {
createdAt?: string;
id?: string;
uniqueKey?: string;
embedding?: number[];
};

export class Label {
Expand All @@ -51,7 +52,8 @@ export class Label {
readonly source?: LabelSource,
readonly id?: string,
readonly createdAt?: string,
readonly uniqueKey?: string
readonly uniqueKey?: string,
readonly embedding?: number[]
) {}

static from(labelInput: LabelInput) {
Expand All @@ -68,7 +70,8 @@ export class Label {
source,
id,
createdAt,
uniqueKey
uniqueKey,
embedding
}: LabelInput) {
if (typeof entityType == "string") {
entityType = ENTITY_TYPE_STRING_TO_ENUM[entityType];
Expand All @@ -95,7 +98,8 @@ export class Label {
source,
id,
createdAt,
uniqueKey
uniqueKey,
embedding
);
}
}

0 comments on commit a621f0f

Please sign in to comment.