-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdll.aardio
51 lines (39 loc) · 1.33 KB
/
dll.aardio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//调用内存DLL
import fsys;
import process.rust;
import process.vswhere;
import console;
/*
Rust 快速入门:
https://quickref.me/rust
https://learnxinyminutes.com/docs/zh-cn/rust-cn/
*/
var vswhere = process.vswhere("-latest -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64");
if(!#vswhere){
console.log("运行 Rust 编译器必须先安装 VC++ 2017 或 2019");
console.pause();
process.execute("https://visualstudio.microsoft.com/downloads/")
return;
}
process.rust.workdir = "/"
console.open()
console.log(io.curDir())
if(!io.exist("/lib/chatgpt/.dll/src/rust/tiktoken_dll")){
process.rust.createDllProject("/lib/chatgpt/.dll/src/rust/tiktoken_dll")
/*
import process.code;
process.code.install();
process.code("/rust_aardio_dll");
*/
}
process.rust.workDir = "/lib/chatgpt/.dll/src/rust/tiktoken_dll"
if(process.rust.build()){
console.log("build")
console.pause(,"按任意键用 aardio 调用 Rust 生成的 DLL组件")
//DLL 已经配置为不依赖 VC++ 运行库
//注意默认为cdecl调用约定,在DLL路径前加上$符号就是加载为内存DLL(不再需要DLL文件)
//var dll = raw.loadDll($"\tiktoken_dll\target\i686-pc-windows-msvc\release\tiktoken_dll.dll",,"cdecl");
//var tokens_len = dll.gpt_num_tokens("Hello,Rust!");
//console.log( "tokens长度:",tokens_len)
}
console.pause()