Skip to content

[Chore] Reorganize engine.ts#536

Merged
CharlieFRuan merged 1 commit intomlc-ai:mainfrom
CharlieFRuan:pr-0810-chore
Aug 10, 2024
Merged

[Chore] Reorganize engine.ts#536
CharlieFRuan merged 1 commit intomlc-ai:mainfrom
CharlieFRuan:pr-0810-chore

Conversation

@CharlieFRuan
Copy link
Copy Markdown
Member

@CharlieFRuan CharlieFRuan commented Aug 10, 2024

This PR reorganizes engine.ts to keep it relatively more organized.

  • We move getToolCallFromOutputMessage() from engine.ts to support.ts since it does not depend on any engine-related fields and is stateless
  • We move asyncLoadTokenizer() from engine.ts to cache_util.ts for the same reason
  • In future, we can implement a common helper for chatCompletion() and completion()
  • For engine.ts, we break down the functions into sections:
  1. Setters and getters
  2. Model/pipeline loading and unloading: reload(), unload()
  3. Underlying auto-regressive generation functions: _generate(), asyncGenerate(), interruptGenerate()
  4. High-level generation APIs: generate() (deprecated), chatCompletion(), completion()
  5. WebGPU info-querying helpers. Arguably, this can be implemented in support.ts as well. Currently these methods are in the MLCEngineInterface, and goes through the WebWorkerMLCEngine - MLCEngine message passing workflow
  6. Low-level APIs that interact with pipeline

@CharlieFRuan CharlieFRuan merged commit d21f00e into mlc-ai:main Aug 10, 2024
CharlieFRuan added a commit that referenced this pull request Aug 12, 2024
### Changes
- Reorganized internal code, which should have no affect on behaviors
#536
- Bumped version of tokenizers-cpp to fix potential error `The global
thread pool has not been initialized.`
  - For more, see mlc-ai/tokenizers-cpp#42

### TVMjs
- Still compiled at
apache/tvm@1fcb620,
no change
jingyi-zhao-01 pushed a commit to jingyi-zhao-01/web-llm that referenced this pull request Dec 8, 2024
This PR reorganizes `engine.ts` to keep it relatively more organized.
- We move `getToolCallFromOutputMessage()` from `engine.ts` to
`support.ts` since it does not depend on any engine-related fields and
is stateless
- We move `asyncLoadTokenizer()` from `engine.ts` to `cache_util.ts` for
the same reason
- For `engine.ts`, we break down the functions into sections
jingyi-zhao-01 pushed a commit to jingyi-zhao-01/web-llm that referenced this pull request Dec 8, 2024
### Changes
- Reorganized internal code, which should have no affect on behaviors
mlc-ai#536
- Bumped version of tokenizers-cpp to fix potential error `The global
thread pool has not been initialized.`
  - For more, see mlc-ai/tokenizers-cpp#42

### TVMjs
- Still compiled at
apache/tvm@1fcb620,
no change
atebites-hub pushed a commit to atebites-hub/web-llm that referenced this pull request Oct 4, 2025
This PR reorganizes `engine.ts` to keep it relatively more organized.
- We move `getToolCallFromOutputMessage()` from `engine.ts` to
`support.ts` since it does not depend on any engine-related fields and
is stateless
- We move `asyncLoadTokenizer()` from `engine.ts` to `cache_util.ts` for
the same reason
- For `engine.ts`, we break down the functions into sections
atebites-hub pushed a commit to atebites-hub/web-llm that referenced this pull request Oct 4, 2025
### Changes
- Reorganized internal code, which should have no affect on behaviors
mlc-ai#536
- Bumped version of tokenizers-cpp to fix potential error `The global
thread pool has not been initialized.`
  - For more, see mlc-ai/tokenizers-cpp#42

### TVMjs
- Still compiled at
apache/tvm@1fcb620,
no change
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.

1 participant