stanfordnlp / dspy

DSPy: The framework for programming—not prompting—foundation models
https://dspy-docs.vercel.app/
MIT License
13.82k stars 1.06k forks source link

How do I load a previously compiled agent? #1201

Closed ArslanS1997 closed 4 days ago

ArslanS1997 commented 1 week ago

Hi in a previous project I have saved an agent file, how do I load it back in my new project?

vikrantrathore commented 1 week ago

Based on information in the document you can save and load the optimized programs, they are saved as JSON. Check the information in the document at https://dspy-docs.vercel.app/docs/building-blocks/optimizers

optimized_program.save(YOUR_SAVE_PATH)
loaded_program = YOUR_PROGRAM_CLASS()
loaded_program.load(path=YOUR_SAVE_PATH)

Hope this helps.

Also one suggestion for future, if you seek help from community please provide bit more details.

okhat commented 4 days ago

thank you @vikrantrathore

okhat commented 4 days ago

feel free to reopen if problem persists @ArslanS1997