MCPcopy Create free account
hub / github.com/cisco/mindmeld / get_key

Method get_key

mindmeld/query_cache.py:128–146  ·  view source on GitHub ↗

Calculates a hash key for the domain, intent and text of an example. This key is required for further interactions with the query cache. Args: domain(str): The domain of the example intent(str): The intent of the example query_text(str):

(domain, intent, query_text)

Source from the content-addressed store, hash-verified

126
127 @staticmethod
128 def get_key(domain, intent, query_text):
129 """
130 Calculates a hash key for the domain, intent and text of an example.
131 This key is required for further interactions with the query cache.
132
133 Args:
134 domain(str): The domain of the example
135 intent(str): The intent of the example
136 query_text(str): The raw text of the example
137 Returns:
138 str: Hash id representing this query
139 """
140
141 h = sha256(domain.encode())
142 h.update(b"###")
143 h.update(intent.encode())
144 h.update(b"###")
145 h.update(query_text.encode())
146 return h.hexdigest()
147
148 @property
149 def connection(self):

Callers 6

get_valueMethod · 0.95
cache_query_fileFunction · 0.80
test_disk_query_cacheFunction · 0.80
test_memory_query_cacheFunction · 0.80

Calls 2

updateMethod · 0.80
encodeMethod · 0.45

Tested by 3

test_disk_query_cacheFunction · 0.64
test_memory_query_cacheFunction · 0.64