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

cancel support for LLMDynamicHandle.respond #179

Closed
Smilebags opened this issue Jan 19, 2025 · 2 comments
Closed

cancel support for LLMDynamicHandle.respond #179

Smilebags opened this issue Jan 19, 2025 · 2 comments

Comments

@Smilebags
Copy link

Smilebags commented Jan 19, 2025

As in the title, I would like to be able to call cancel on the returned object from LLMDynamicHandle.respond like is available for LLMDynamicHandle.complete.

I can see two ways to achieve this:

  1. Make the returned value from respond contain a suitable cancel property. Depending on the internal architecture this might not be feasible.
  2. For me to use complete, and convert the ChatHistoryLike history into a single text prompt on my side, so that I can use complete.cancel. I assume such a function exists somewhere within lmstudio.js internals, is it exported in the built package? If not, can someone point me to the relevant source?

I'm open to alternative suggestions - I'd love to be able to cancel requests for my use-case, and the respond API feels more suitable for my needs.

@Smilebags Smilebags changed the title cancel support for LLMDynamicHandle.respond. cancel support for LLMDynamicHandle.respond Jan 19, 2025
@ryan-the-crayon
Copy link
Contributor

I believe respond returns a OngoingPrediction which already has a cancel method.

Returning OngoingPrediction: https://github.com/lmstudio-ai/lmstudio.js/blob/main/packages/lms-client/src/llm/LLMDynamicHandle.ts#L383
Cancel method: https://github.com/lmstudio-ai/lmstudio.js/blob/main/packages/lms-client/src/llm/OngoingPrediction.ts#L130

Also, we do have a way to convert history to text. It is available as llm.applyPromptTemplate: https://github.com/lmstudio-ai/lmstudio.js/blob/main/packages/lms-client/src/llm/LLMDynamicHandle.ts#L392

@Smilebags
Copy link
Author

Thanks! I didn't see that when first looking, but it looks like I have everything I need.

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

No branches or pull requests

3 participants