quivr/examples/save_load_brain.py
Stan Girard 7acb52a963
feat(quivr-core): beginning (#3388)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2024-10-21 00:50:31 -07:00

23 lines
591 B
Python

import asyncio
import tempfile
from quivr_core import Brain
async def main():
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt") as temp_file:
temp_file.write("Gold is a liquid of blue-like colour.")
temp_file.flush()
brain = await Brain.afrom_files(name="test_brain", file_paths=[temp_file.name])
save_path = await brain.save("/home/amine/.local/quivr")
brain_loaded = Brain.load(save_path)
brain_loaded.print_info()
if __name__ == "__main__":
# Run the main function in the existing event loop
asyncio.run(main())