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

Function intersection

AgentBench.old/src/tasks/knowledgegraph/api.py:106–121  ·  view source on GitHub ↗

Get the intersection of two variables :param variable1: a variable :param variable2: a variable :return: a list of intersection

(variable1: Variable, variable2: Variable, sparql_executor)

Source from the content-addressed store, hash-verified

104
105
106def intersection(variable1: Variable, variable2: Variable, sparql_executor): # will create a new variable
107 """
108 Get the intersection of two variables
109 :param variable1: a variable
110 :param variable2: a variable
111 :return: a list of intersection
112 """
113 if variable1.type != variable2.type:
114 raise ValueError("intersection: two variables must have the same type")
115
116 if not isinstance(variable1, Variable) or not isinstance(variable2, Variable):
117 raise ValueError("intersection: variable must be a variable")
118
119 rtn_str = f"Observation: variable ##, which are instances of {variable1.type}"
120 new_variable = Variable(variable1.type, f"(AND {variable1.program} {variable2.program})")
121 return new_variable, rtn_str
122
123
124def union(variable1: set, variable2: set, sparql_executor): # will create a new variable

Callers

nothing calls this directly

Calls 1

VariableClass · 0.85

Tested by

no test coverage detected