from memos.configs.mem_reader import SimpleStructMemReaderConfigfrom memos.mem_reader.simple_struct import SimpleStructMemReader config = SimpleStructMemReaderConfig( **{ "llm": { "backend": "huggingface", "config": { "model_name_or_path": "MemTensor/MemOperator-0.6B", "temperature": 0.6, "max_tokens": 6000, "top_p": 0.95, "top_k": 20, "extra_body": {"chat_template_kwargs": {"enable_thinking": false}} }, }, "embedder": { "backend": "ollama", "config": {"model_name_or_path": "nomic-embed-text:latest"}, }, "chunker": { "backend": "sentence", "config": { "tokenizer_or_token_counter": "gpt2", "chunk_size": 512, "chunk_overlap": 128, "min_sentences_per_chunk": 1, }, }, "remove_prompt_example": True, }) reader = SimpleStructMemReader(config) # Example chat datachat_data = [ [ { "role": "user", "chat_time": "June 26, 2025 at 3:00 PM", "content": "Hi Jerry! Yesterday at 3 PM I had a meeting with my team about the new project.", }, { "role": "assistant", "chat_time": "June 26, 2025 at 3:00 PM", "content": "Oh Tom! Do you think the team can finish by December 15?", }, { "role": "user", "chat_time": "June 26, 2025 at 3:00 PM", "content": "I’m worried. The backend won’t be done until December 10, so testing will be tight.", }, { "role": "assistant", "chat_time": "June 26, 2025 at 3:00 PM", "content": "Maybe propose an extension?", }, { "role": "user", "chat_time": "June 26, 2025 at 4:21 PM", "content": "Good idea. I’ll raise it in tomorrow’s 9:30 AM meeting—maybe shift the deadline to January 5.", }, ]] # Save document for testingwith open("tmp.txt", "w") as f: f.write( "Lou Henry Hoover (March 29, 1874 – January 7, 1944) was an American philanthropist, geologist, and the first lady of the United States from 1929 to 1933 as the wife of President Herbert Hoover. She was active in community organizations and volunteer groups throughout her life, including the Girl Scouts of the USA, which she led from 1922 to 1925 and from 1935 to 1937. Throughout her life, Hoover supported women's rights and women's independence. She was a polyglot, fluent in Mandarin and well-versed in Latin, and was the primary translator from Latin to English of the complex 16th-century metallurgy text De re metallica." ) # Extract chat and document memorieschat_memory = reader.get_memory( chat_data, type="chat", info={"user_id": "Tom", "session_id": "session1"})doc_memory = reader.get_memory( ["tmp.txt"], "doc", info={ "user_id": "Tom", "session_id": "session2", },) print(chat_memory)print(doc_memory)