@fugood/llama.node 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/lib/binding.ts CHANGED
@@ -113,6 +113,8 @@ export type LlamaCompletionOptions = {
113
113
 
114
114
  export type LlamaCompletionResult = {
115
115
  text: string
116
+ reasoning_content?: string
117
+ content?: string
116
118
  tokens_predicted: number
117
119
  tokens_evaluated: number
118
120
  truncated: boolean
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fugood/llama.node",
3
3
  "access": "public",
4
- "version": "0.4.2",
4
+ "version": "0.4.3",
5
5
  "description": "An another Node binding of llama.cpp",
6
6
  "main": "lib/index.js",
7
7
  "scripts": {
@@ -551,16 +551,16 @@ void LlamaCompletionWorker::OnOK() {
551
551
  Napi::String::New(env, _result.text.c_str()));
552
552
 
553
553
  Napi::Array tool_calls = Napi::Array::New(Napi::AsyncWorker::Env());
554
- std::string * reasoning_content = nullptr;
555
- std::string * content = nullptr;
554
+ std::string reasoning_content = "";
555
+ std::string content;
556
556
  if (!_stop) {
557
557
  try {
558
558
  common_chat_msg message = common_chat_parse(_result.text, static_cast<common_chat_format>(_chat_format));
559
559
  if (!message.reasoning_content.empty()) {
560
- reasoning_content = &message.reasoning_content;
560
+ reasoning_content = message.reasoning_content;
561
561
  }
562
562
  if (!message.content.empty()) {
563
- content = &message.content;
563
+ content = message.content;
564
564
  }
565
565
  for (size_t i = 0; i < message.tool_calls.size(); i++) {
566
566
  const auto &tc = message.tool_calls[i];
@@ -582,11 +582,11 @@ void LlamaCompletionWorker::OnOK() {
582
582
  if (tool_calls.Length() > 0) {
583
583
  result.Set("tool_calls", tool_calls);
584
584
  }
585
- if (reasoning_content) {
586
- result.Set("reasoning_content", Napi::String::New(env, reasoning_content->c_str()));
585
+ if (!reasoning_content.empty()) {
586
+ result.Set("reasoning_content", Napi::String::New(env, reasoning_content.c_str()));
587
587
  }
588
- if (content) {
589
- result.Set("content", Napi::String::New(env, content->c_str()));
588
+ if (!content.empty()) {
589
+ result.Set("content", Napi::String::New(env, content.c_str()));
590
590
  }
591
591
 
592
592
  auto ctx = _sess->context();