MCPcopy Create free account
hub / github.com/THUDM/AgentTuning / get_attributes

Function get_attributes

AgentBench.old/src/tasks/knowledgegraph/api.py:153–171  ·  view source on GitHub ↗
(variable: Variable, sparql_executor)

Source from the content-addressed store, hash-verified

151
152
153def get_attributes(variable: Variable, sparql_executor):
154 program = variable.program
155
156 processed_code = postprocess_raw_code(program)
157 sparql_query = lisp_to_sparql(processed_code)
158 clauses = sparql_query.split("\n")
159
160 new_clauses = [clauses[0], "SELECT DISTINCT ?rel\nWHERE {\n?x ?rel ?obj .\n{"]
161 new_clauses.extend(clauses[1:])
162 new_clauses.append("}\n}")
163 new_query = '\n'.join(new_clauses)
164 out_relations = sparql_executor.execute_query(new_query)
165
166 out_relations = list(set(out_relations).intersection(set(attributes)))
167 variable_attributes_cache[variable] = out_relations
168
169 rtn_str = f"Observation: [{', '.join(out_relations)}]"
170
171 return None, rtn_str
172
173
174

Callers

nothing calls this directly

Calls 4

postprocess_raw_codeFunction · 0.85
lisp_to_sparqlFunction · 0.85
joinMethod · 0.80
execute_queryMethod · 0.80

Tested by

no test coverage detected