MCPcopy Create free account
hub / github.com/MemTensor/MemOS / main

Function main

evaluation/scripts/PrefEval/pref_supermemory.py:171–354  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

169
170
171def main():
172 parser = argparse.ArgumentParser(
173 description="Process conversations with MemOS. Run 'add', then 'search', then 'response'."
174 )
175 parser.add_argument(
176 "mode",
177 choices=["add", "search", "response"],
178 help="The mode to run the script in ('add', 'search', or 'response').",
179 )
180 parser.add_argument("--input", required=True, help="Path to the input JSONL file.")
181 parser.add_argument("--output", required=True, help="Path to the output JSONL file.")
182 parser.add_argument(
183 "--top-k",
184 type=int,
185 default=10,
186 help="Number of memories to retrieve (used in 'search' mode).",
187 )
188 parser.add_argument(
189 "--add-turn",
190 type=int,
191 choices=[0, 10, 300],
192 default=0,
193 help="Number of irrelevant turns to add (used in 'add' mode).",
194 )
195 parser.add_argument(
196 "--lib",
197 type=str,
198 choices=["supermemory"],
199 default="supermemory",
200 help="Which Supermemory library to use (used in 'add' mode).",
201 )
202 parser.add_argument(
203 "--version",
204 type=str,
205 default="0929-1",
206 help="Version identifier for user_id generation (used in 'add' mode).",
207 )
208 parser.add_argument(
209 "--max-workers", type=int, default=20, help="Maximum number of concurrent workers."
210 )
211
212 args = parser.parse_args()
213
214 try:
215 with open(args.input, encoding="utf-8") as infile:
216 lines = infile.readlines()
217 except FileNotFoundError:
218 print(f"Error: Input file '{args.input}' not found")
219 return
220
221 class SupermemoryClient:
222 def __init__(self):
223 from supermemory import Supermemory
224
225 self.client = Supermemory(api_key=os.getenv("SUPERMEMORY_API_KEY"))
226
227 def add(self, messages, user_id):
228 content = "\n".join([f"{msg['role']}: {msg['content']}" for msg in messages])

Callers 1

Calls 6

setFunction · 0.85
submitMethod · 0.80
SupermemoryClientClass · 0.70
writeMethod · 0.65
openFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected