Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save and load sessions #2063

Merged
merged 12 commits into from
Jan 25, 2024
Merged

Save and load sessions #2063

merged 12 commits into from
Jan 25, 2024

Conversation

pdevine
Copy link
Contributor

@pdevine pdevine commented Jan 19, 2024

This change allows users to interactively save a session from the REPL, and then load it back up again later.

It also adds a new MESSAGE command for Modelfiles so that users can build their own session which can be created with ollama create.

opts.Messages = []api.Message{}
fmt.Printf("Loading model '%s'\n", opts.Model)
if err := loadModel(cmd, &opts); err != nil {
return err
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a bug here because of the way we handle errors w/ the chat api. Ideally it wouldn't close the repl if it can't load the model.

api/types.go Outdated Show resolved Hide resolved
cmd/interactive.go Show resolved Hide resolved
fmt.Fprintln(os.Stderr, " /?, /help Help for a command")
fmt.Fprintln(os.Stderr, " /? shortcuts Help for keyboard shortcuts")
fmt.Fprintln(os.Stderr, " /set Set session variables")
fmt.Fprintln(os.Stderr, " /show Show model information")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't have to be part of this change, but /show modelfile doesnt show MESSAGE parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/show modelfile is kinda messed up right now. It should really only include the deltas of things which have changed, and yes, include the messages. That's actually pretty easy to do (/save already is creating this modelfile), but the problem is what if you want to see the modelfile of the original model? Right now it kinda mixes the two up.

api/types.go Outdated Show resolved Hide resolved
Copy link
Contributor

@BruceMacD BruceMacD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested and reviewed, all looks good

@pdevine pdevine merged commit 7c40a67 into main Jan 25, 2024
10 checks passed
@pdevine pdevine deleted the savesession branch January 25, 2024 20:12
@d3cline
Copy link

d3cline commented Feb 12, 2024

is this available in the JSON API? I do see changes in routes but I am not familiar enough with the code base to understand if this is true. Any aid would be grateful. I want to resume session via API at a later time if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants