11import jwt
2- import requests
2+ import json
33import nilql
44import os
5+ import re
6+ import requests
57import time
68import uuid
79
8- from jsonschema import Draft7Validator , validators
10+ from collections import deque , defaultdict
911from ecdsa import SECP256k1 , SigningKey
12+ from jsonschema import Draft7Validator , validators
1013from langchain_openai import ChatOpenAI
1114from typing import Any , Generator
1215
13- # from collections import deque, defaultdict
14- # import json
15- # import re
16+ from .schemas import (
17+ NillionCreateSchemaInput ,
18+ NillionLookupSchemaInput ,
19+ NillionDataUploadInput ,
20+ NillionDataDownloadInput ,
21+ )
1622
1723class NillionPlugin :
1824 """
@@ -25,11 +31,6 @@ def __init__(self) -> None:
2531 self .name : str = "Nillion Plugin"
2632 self .secret_key = os .getenv ("NILLION_SECRET_KEY" )
2733 self .org_did = os .getenv ("NILLION_ORG_ID" )
28- self .key = None
29- self .nodes = None
30-
31- def initialize (self ):
32- """Initialize the plugin"""
3334 if not self .secret_key :
3435 raise ValueError ("NILLION_SECRET_KEY is not configured." )
3536 if not self .org_did :
@@ -39,7 +40,7 @@ def initialize(self):
3940
4041 """Initialize config with JWTs signed with ES256K for multiple node_ids; Add cluster key."""
4142 response = requests .post (
42- "https://sv-sda -registration.replit.app/api/config" ,
43+ "https://secret-vault -registration.replit.app/api/config" ,
4344 headers = {
4445 "Content-Type" : "application/json" ,
4546 },
@@ -183,7 +184,6 @@ def create_schema(self, args: dict[str, Any]) -> tuple:
183184 tuple[str, dict]: The schema_uuid and the corresponding schema definition
184185 """
185186 try :
186-
187187 validated_args = NillionCreateSchemaInput (** args )
188188 print (f"fn:create_schema [{ validated_args .schema_description } ]" )
189189
@@ -253,7 +253,6 @@ def create_schema(self, args: dict[str, Any]) -> tuple:
253253 response = llm .invoke (schema_prompt )
254254
255255 schema = json .loads (str (response .content ))
256-
257256 schema ["_id" ] = str (uuid .uuid4 ())
258257 schema ["owner" ] = self .org_did
259258
@@ -263,13 +262,14 @@ def create_schema(self, args: dict[str, Any]) -> tuple:
263262 print (f'fn:create_schema [{ schema ["_id" ]} ]' )
264263 return schema ["_id" ], schema
265264 except Exception as e :
266- print (f"Error creating schema: { str ( e ) } " )
265+ print (f"Error creating schema: { e !r } " )
267266 return None , None
268267
269268 def data_upload (self , args : dict [str , Any ]) -> list [str ]:
270- """Create a schema in your privacy preserving database, called the Nillion SecretVault
271- (or nildb), based on a natural language description. Do not use this tool for any other
272- purpose.
269+ """Upload specified data into your privacy preserving database, called the Nillion SecretVault
270+ (or nildb), using the specified schema UUID. The data must exactly fit the requirements of
271+ the desired schema itself.
272+ Success will return a list of created record UUIDs, failure is an empty list.
273273 Args:
274274 args (dict[str, Any]): Arguments containing a UUID and the data to upload.
275275 Returns:
@@ -322,9 +322,11 @@ def data_upload(self, args: dict[str, Any]) -> list[str]:
322322 return []
323323
324324 def data_download (self , args : dict [str , Any ]) -> list [dict ]:
325- """Create a schema in your privacy preserving database, called the Nillion SecretVault
326- (or nildb), based on a natural language description. Do not use this tool for any other
327- purpose.
325+ """Download all the data from your privacy preserving database, called the Nillion SecretVault
326+ (or nildb), using the specified schema UUID. You must know the schema UUID for the remote schema
327+ that you require. If you do not have the schema UUID you must use the lookup_schema action of the
328+ NillionActionProvider.
329+ Success will return true, whereas a failure response will return false.
328330 Args:
329331 args (dict[str, Any]): Arguments containing a target schema UUID
330332 Returns:
0 commit comments