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

Support for context in generate endpoint #15

Open
jmont-dev opened this issue Aug 12, 2024 · 2 comments
Open

Support for context in generate endpoint #15

jmont-dev opened this issue Aug 12, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jmont-dev
Copy link
Owner

Context tokens are supplied from the generate endpoint. Allow supplying these as an input to additional generations to allow responses that span multiple generations.

@jmont-dev jmont-dev added the enhancement New feature or request label Aug 12, 2024
@jmont-dev jmont-dev added this to the 1.0 Release milestone Aug 12, 2024
@jmont-dev jmont-dev self-assigned this Aug 12, 2024
@JG-Adams
Copy link

JG-Adams commented Aug 14, 2024

I figured out how to do in manual way.
First capture the context.
inline nlohmann::json Keepcontext;
if (response.as_json()["done"]==true) {
prompt_AI.busy=false;
if (response.as_json().contains("context")){
Keepcontext = response.as_json()["context"];
}
}
Then you put it in request in the next time.

ollama::request request(ollama::message_type::generation);
if (!Keepcontext.empty()){
request["context"] = Keepcontext;
}

@jmont-dev
Copy link
Owner Author

This was addressed in #23. You can now include previous responses to provide context when using the generate endpoint. See the sections added to the Readme on handling context and context length: https://github.com/jmont-dev/ollama-hpp?tab=readme-ov-file#handling-context.

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

No branches or pull requests

2 participants