浏览代码

fix: .startsWith on undefined

KernelDeimos 1 月之前
父节点
当前提交
9a12db2066
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      src/puter-js/src/modules/AI.js

+ 3 - 0
src/puter-js/src/modules/AI.js

@@ -274,6 +274,9 @@ class AI{
         if (userParams.max_tokens) {
             requestParams.max_tokens = userParams.max_tokens;
         }
+        
+        // convert undefined to empty string so that .startsWith works
+        requestParams.model = requestParams.model ?? '';
 
         // convert to the correct model name if necessary
         if( requestParams.model === 'claude-3-5-sonnet'){