Skip to content

Commit 09c510e

Browse files
committed
wip: exploring cargo as library
1 parent 1daf620 commit 09c510e

File tree

4 files changed

+968
-10
lines changed

4 files changed

+968
-10
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
3+
---
4+
5+
---
6+
7+
---
8+
use std::{fs::canonicalize, path::PathBuf};
9+
10+
// use async_openai::{
11+
// types::{ChatCompletionRequestMessageArgs, CreateChatCompletionRequestArgs, Role},
12+
// Client,
13+
// };
14+
15+
use cargo::ops::compile;
16+
17+
#[tokio::main]
18+
async fn main() {
19+
println!("Hello, Cargo Self v0.2.0!");
20+
21+
// let manifest_path_buf = PathBuf::from("./Cargo.toml");
22+
let manifest_path = canonicalize(PathBuf::from("./Cargo.toml")).unwrap();
23+
// let a = Box::new(std::io::stdout());
24+
// let buf = BufWriter::new(Vec::new());
25+
// Shell::;
26+
27+
// let shell = Shell::from_write(Box::new(buf));
28+
// let shell = Shell::default();
29+
let config = cargo::util::config::Config::default().unwrap();
30+
31+
// config.registry_cache_path();
32+
33+
// cargo::core::Workspace::new(manifest_path, config)
34+
let ws = cargo::core::Workspace::new(&manifest_path, &config).unwrap();
35+
36+
let options =
37+
cargo::ops::CompileOptions::new(&config, cargo::core::compiler::CompileMode::Build)
38+
.unwrap();
39+
40+
// set example to named workspace member
41+
42+
// println!("options.spec: {}", options.spec);
43+
44+
// let client = Client::new();
45+
46+
// let request = CreateChatCompletionRequestArgs::default()
47+
// .max_tokens(512u16)
48+
// .model("gpt-3.5-turbo")
49+
// .messages([
50+
// ChatCompletionRequestMessageArgs::default()
51+
// .role(Role::System)
52+
// .content("You are a helpful assistant.")
53+
// .build()
54+
// .unwrap(),
55+
// ChatCompletionRequestMessageArgs::default()
56+
// .role(Role::User)
57+
// .content("Who won the world series in 2020?")
58+
// .build()
59+
// .unwrap(),
60+
// ChatCompletionRequestMessageArgs::default()
61+
// .role(Role::Assistant)
62+
// .content("The Los Angeles Dodgers won the World Series in 2020.")
63+
// .build()
64+
// .unwrap(),
65+
// ChatCompletionRequestMessageArgs::default()
66+
// .role(Role::User)
67+
// .content("Where was it played?")
68+
// .build()
69+
// .unwrap(),
70+
// ])
71+
// .build()
72+
// .unwrap();
73+
74+
// let response = client.chat().create(request).await.unwrap();
75+
76+
ws.members()
77+
// .filter(|member| member.library().is_some())
78+
.for_each(|member| {
79+
println!("member: {}", member.name());
80+
});
81+
82+
// let res = compile(&ws, &options).unwrap();
83+
84+
// res.binaries.iter().for_each(|bin| {
85+
// println!("bin: {}", bin.path.display());
86+
// });
87+
}

0 commit comments

Comments
 (0)