@@ -44,6 +44,7 @@ def __init__(self, conn: TigerGraphConnection) -> None:
4444 """
4545 self .conn = conn
4646 self .nlqs_host = None
47+ self .aiserver = "supportai"
4748 if conn .tgCloud :
4849 # split scheme and host
4950 scheme , host = conn .host .split ("://" )
@@ -70,6 +71,16 @@ def configureCoPilotHost(self, hostname: str):
7071 """
7172 self .nlqs_host = hostname
7273
74+ def configureServerHost (self , hostname : str , aiserver : str ):
75+ """ Configure the hostname of the AI service.
76+ Not necessary if using TigerGraph AI on TigerGraph Cloud.
77+ Args:
78+ hostname (str):
79+ The hostname (and port number) of the CoPilot serivce.
80+ """
81+ self .nlqs_host = hostname
82+ self .aiserver = aiserver
83+
7384 def registerCustomQuery (self , query_name : str , description : str = None , docstring : str = None , param_types : dict = None ):
7485 """ Register a custom query with the InquiryAI service.
7586 Args:
@@ -227,7 +238,22 @@ def initializeSupportAI(self):
227238 Returns:
228239 JSON response from the SupportAI service.
229240 """
230- url = self .nlqs_host + "/" + self .conn .graphname + "/supportai/initialize"
241+ return self .initializeAIServer ("supportai" )
242+
243+ def initializeGraphAI (self ):
244+ """ Initialize the GraphAI service.
245+ Returns:
246+ JSON response from the GraphAI service.
247+ """
248+ return self .initializeAIServer ("graphai" )
249+
250+ def initializeAIServer (self , server = "supportai" ):
251+ """ Initialize the given service.
252+ Returns:
253+ JSON response from the given service.
254+ """
255+ self .aiserver = server
256+ url = f"{ self .nlqs_host } /{ self .conn .graphname } /{ self .aiserver } /initialize"
231257 return self .conn ._req ("POST" , url , authMode = "pwd" , resKey = None )
232258
233259 def createDocumentIngest (self , data_source , data_source_config , loader_config , file_format ):
@@ -251,7 +277,7 @@ def createDocumentIngest(self, data_source, data_source_config, loader_config, f
251277 "file_format" : file_format
252278 }
253279
254- url = self .nlqs_host + "/" + self .conn .graphname + "/supportai /create_ingest"
280+ url = f" { self .nlqs_host } / { self .conn .graphname } / { self . aiserver } /create_ingest"
255281 return self .conn ._req ("POST" , url , authMode = "pwd" , data = data , jsonData = True , resKey = None )
256282
257283 def runDocumentIngest (self , load_job_id , data_source_id , data_path , data_source = "remote" ):
@@ -274,7 +300,7 @@ def runDocumentIngest(self, load_job_id, data_source_id, data_path, data_source=
274300 "data_source_id" : data_source_id ,
275301 "file_path" : data_path
276302 }
277- url = self .nlqs_host + "/" + self .conn .graphname + "/supportai /ingest"
303+ url = f" { self .nlqs_host } / { self .conn .graphname } / { self . aiserver } /ingest"
278304 return self .conn ._req ("POST" , url , authMode = "pwd" , data = data , jsonData = True , resKey = None )
279305
280306 def searchDocuments (self , query , method = "hnswoverlap" , method_parameters : dict = {"indices" : ["Document" , "DocumentChunk" , "Entity" , "Relationship" ], "top_k" : 2 , "num_hops" : 2 , "num_seen_min" : 2 }):
0 commit comments