Skip to content

Commit

Permalink
Merge pull request #12 from FederalCSUMission/andyc-federalized-20230918
Browse files Browse the repository at this point in the history
Update utils.py
  • Loading branch information
marktab committed Sep 18, 2023
2 parents 469bb82 + e89a42d commit 525f5f5
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,48 @@ def run_agent(question:str, agent_chain: AgentExecutor) -> str:

response = chatgpt_chain.run(str(e))
return response

# function to verify if Semantic Search is available is Cognitive Search instance
def semanticEnabled( searchService, azSubscription, azResourceGroup ) :

loginUrl = "https://login.microsoftonline.us/"
mgmtUrl = "https://management.usgovcloudapi.net/"
apiVersion = "2022-09-01"
csApiVersion = "2021-06-06-Preview"

# searchService = os.environ[ "AZURE_SEARCH_NAME" ] # update this value in env file
# azSubscription = os.environ[ "AZ_SUBSCRIPTION_ID" ]
# azResourceGroup = os.environ[ "AZ_RESOURCE_GROUP" ]

# variable to track if Semantic Search is enabled or disabled - disabled by default ( disabled = 0, enabled = 1 )
semanticStatus = 0

parentResourcePath = "/subscriptions/" + azSubscription

authEndpoint = loginUrl + azSubscription

# grab credential for authenticated user within notebook
currCredential = DefaultAzureCredential( authority = authEndpoint )

# create connection to Search Service instance via Azure Resource Manager
scopeurl = mgmtUrl + ".default"
resourceClient = ResourceManagementClient( currCredential, azSubscription, apiVersion, mgmtUrl, credential_scopes = [ scopeurl ] )

resourceInfo = resourceClient.resources.get( azResourceGroup, "Microsoft.Search", "", "searchServices", searchService, csApiVersion )

propSemantic = resourceInfo.properties[ "semanticSearch" ]

if propSemantic == "disabled" :

semanticStatus = 0

else :

semanticStatus = 1

return semanticStatus

# print( "Semantic Status: ", str( semanticStatus ) )


######## TOOL CLASSES #####################################
Expand Down Expand Up @@ -557,4 +599,4 @@ def _run(self, tool_input: Union[str, Dict],) -> str:

async def _arun(self, query: str) -> str:
"""Use the tool asynchronously."""
raise NotImplementedError("BingSearchTool does not support async")
raise NotImplementedError("BingSearchTool does not support async")

0 comments on commit 525f5f5

Please sign in to comment.