()
| 169 | |
| 170 | |
| 171 | def 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]) |
no test coverage detected