Skip to content

Commit c6b6bcd

Browse files
authored
fix: overhaul crate structure and implement builder pattern (#15)
1 parent f9a6de7 commit c6b6bcd

File tree

18 files changed

+1500
-944
lines changed

18 files changed

+1500
-944
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ serde_json = "1.0.114"
2121
tokio = { version = "1.36.0", features = ["full"] }
2222
clap = { version = "4.5.1", features = ["derive"] , optional = true }
2323
base64 = "0.22.0"
24+
anyhow = "1.0.97"
25+
derive_builder = "0.20.2"
2426

2527
[features]
2628
cli = ["clap"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Mahmoud Harmouch
3+
Copyright (c) 2025 Kevin RS Foundation
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ gems count -t "Hello There!"
7979
### Embed content into a specified model:
8080

8181
```sh
82-
gems -m 'embedding-001' embed -t "Write a story about a magic backpack."
82+
gems embed -t "Write a story about a magic backpack."
8383
```
8484

8585
### Batch embed multiple contents:
8686

8787
```sh
88-
gems -m 'embedding-001' batch -t "Write a story about a magic backpack.","Generate a poem about nature."
88+
gems batch -t "Write a story about a magic backpack.","Generate a poem about nature."
8989
```
9090

9191
### Get information about the current model:
@@ -129,28 +129,44 @@ gems list
129129

130130
```toml
131131
[dependencies]
132-
gems = "0.0.9"
132+
gems = "0.1.0"
133133
```
134134

135135
1. Use the `Client` struct to interact with the Gemini API:
136136

137137
```rust
138138
use gems::Client;
139-
139+
use gems::traits::CTrait;
140+
use gems::messages::Content;
141+
use gems::messages::Message;
142+
use gems::models::Model;
143+
use gems::chat::ChatBuilder;
144+
use anyhow::Result;
145+
140146
#[tokio::main]
141-
async fn main() {
142-
let mut client = Client::new("your_api_key", "your_model");
143-
144-
// Use the various functions provided by the client
145-
// For example:
146-
match client.generate_content("Hello").await {
147+
async fn main() -> Result<()> {
148+
let mut gemini_client = Client::builder().model("your-model").build()?;
149+
150+
gemini_client.set_api_key("your-api-key".to_string());
151+
152+
let parameters = ChatBuilder::default()
153+
.model(Model::Flash20)
154+
.messages(vec![Message::User {
155+
content: Content::Text("Hello".to_string()),
156+
name: None,
157+
}])
158+
.build()?;
159+
160+
match gemini_client.chat().generate(parameters).await {
147161
Ok(response) => {
148162
println!("{}", response);
149163
}
150164
Err(err) => {
151165
eprintln!("Error: {:?}", err);
152166
}
153167
}
168+
169+
Ok(())
154170
}
155171
```
156172

@@ -161,7 +177,7 @@ This repository contains a list of notebooks examples on how to use the sdk and
161177
1. Clone the repository to your local machine:
162178

163179
```sh
164-
git clone https://github.com/wiseaidev/gems.git
180+
git clone https://github.com/kevin-rs/gems.git
165181
```
166182

167183
1. Install the required dependencies and libraries. Make sure you have [`Rust`](https://rustup.rs/), [`Jupyter Notebook`](https://jupyter.org/install), and [`evcxr_jupyter`](https://github.com/evcxr/evcxr/blob/main/evcxr_jupyter/README.md) installed on your system.
@@ -195,13 +211,13 @@ This repository contains a list of notebooks examples on how to use the sdk and
195211

196212
| ID | Example | Open on GitHub | Launch on Binder | Launch on Colab |
197213
|----|---------------|-----------|:-------------|-------------|
198-
| 1 | **Basic** | [![Github](https://img.shields.io/badge/launch-Github-181717.svg?logo=github&logoColor=white)](./examples/basic.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/wiseaidev/gems/main?filepath=examples/basic.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wiseaidev/gems/blob/main/examples/basic.ipynb) |
199-
| 2 | **Rocket** | [![Github](https://img.shields.io/badge/launch-Github-181717.svg?logo=github&logoColor=white)](./examples/rocket.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/wiseaidev/gems/main?filepath=examples/rocket.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wiseaidev/gems/blob/main/examples/rocket.ipynb) |
200-
| 3 | **Axum** | [![Github](https://img.shields.io/badge/launch-Github-181717.svg?logo=github&logoColor=white)](./examples/axum.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/wiseaidev/gems/main?filepath=examples/axum.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/wiseaidev/gems/blob/main/examples/axum.ipynb) |
214+
| 1 | **Basic** | [![Github](https://img.shields.io/badge/launch-Github-181717.svg?logo=github&logoColor=white)](./examples/basic.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/kevin-rs/gems/main?filepath=examples/basic.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/kevin-rs/gems/blob/main/examples/basic.ipynb) |
215+
| 2 | **Rocket** | [![Github](https://img.shields.io/badge/launch-Github-181717.svg?logo=github&logoColor=white)](./examples/rocket.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/kevin-rs/gems/main?filepath=examples/rocket.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/kevin-rs/gems/blob/main/examples/rocket.ipynb) |
216+
| 3 | **Axum** | [![Github](https://img.shields.io/badge/launch-Github-181717.svg?logo=github&logoColor=white)](./examples/axum.ipynb) | [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/kevin-rs/gems/main?filepath=examples/axum.ipynb) | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/kevin-rs/gems/blob/main/examples/axum.ipynb) |
201217

202218
## 🤝 Contributing
203219

204-
Contributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement, please engage with the project on [GitHub](https://github.com/wiseaidev/gems). Your contributions help improve this crate for the community.
220+
Contributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement, please engage with the project on [GitHub](https://github.com/kevin-rs/gems). Your contributions help improve this crate for the community.
205221

206222
## 📄 License
207223

examples/axum/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
GEMINI_API_KEY=
2-
GEMINI_MODEL=gemini-pro
2+
GEMINI_MODEL=gemini-2.0-flash

0 commit comments

Comments
 (0)