()
| 175 | |
| 176 | |
| 177 | def main(): |
| 178 | parser = argparse.ArgumentParser( |
| 179 | description="Process conversations with MemOS. Run 'add', then 'search', then 'response'." |
| 180 | ) |
| 181 | parser.add_argument( |
| 182 | "mode", |
| 183 | choices=["add", "search", "response"], |
| 184 | help="The mode to run the script in ('add', 'search', or 'response').", |
| 185 | ) |
| 186 | parser.add_argument("--input", required=True, help="Path to the input JSONL file.") |
| 187 | parser.add_argument("--output", required=True, help="Path to the output JSONL file.") |
| 188 | parser.add_argument( |
| 189 | "--top-k", |
| 190 | type=int, |
| 191 | default=10, |
| 192 | help="Number of memories to retrieve (used in 'search' mode).", |
| 193 | ) |
| 194 | parser.add_argument( |
| 195 | "--add-turn", |
| 196 | type=int, |
| 197 | choices=[0, 10, 300], |
| 198 | default=0, |
| 199 | help="Number of irrelevant turns to add (used in 'add' mode).", |
| 200 | ) |
| 201 | parser.add_argument( |
| 202 | "--lib", |
| 203 | type=str, |
| 204 | choices=["memos-api", "memos-api-online"], |
| 205 | default="memos-api", |
| 206 | help="Which MemOS library to use (used in 'add' mode).", |
| 207 | ) |
| 208 | parser.add_argument( |
| 209 | "--version", |
| 210 | type=str, |
| 211 | default="0929-1", |
| 212 | help="Version identifier for user_id generation (used in 'add' mode).", |
| 213 | ) |
| 214 | parser.add_argument( |
| 215 | "--max-workers", type=int, default=20, help="Maximum number of concurrent workers." |
| 216 | ) |
| 217 | |
| 218 | args = parser.parse_args() |
| 219 | |
| 220 | try: |
| 221 | with open(args.input, encoding="utf-8") as infile: |
| 222 | lines = infile.readlines() |
| 223 | except FileNotFoundError: |
| 224 | print(f"Error: Input file '{args.input}' not found") |
| 225 | return |
| 226 | |
| 227 | from utils.client import MemosApiClient, MemosApiOnlineClient |
| 228 | |
| 229 | if args.lib == "memos-api": |
| 230 | mem_client = MemosApiClient() |
| 231 | elif args.lib == "memos-api-online": |
| 232 | mem_client = MemosApiOnlineClient() |
| 233 | |
| 234 | os.makedirs(f"results/prefeval/{args.lib}_{args.version}", exist_ok=True) |
no test coverage detected