File tree Expand file tree Collapse file tree 4 files changed +27
-8
lines changed
Expand file tree Collapse file tree 4 files changed +27
-8
lines changed Original file line number Diff line number Diff line change 1515//! Examples showing how to use the Vertex AI Gemini API.
1616
1717// ANCHOR: text-prompt
18- pub async fn text_prompt ( project_id : & str ) -> crate :: Result < ( ) > {
18+ pub async fn text_prompt ( project_id : & str ) -> anyhow :: Result < ( ) > {
1919 // ANCHOR: text-prompt-client
2020 use google_cloud_aiplatform_v1 as vertexai;
2121 let client = vertexai:: client:: PredictionService :: builder ( )
@@ -46,7 +46,7 @@ pub async fn text_prompt(project_id: &str) -> crate::Result<()> {
4646// ANCHOR_END: text-prompt
4747
4848// ANCHOR: prompt-and-image
49- pub async fn prompt_and_image ( project_id : & str ) -> crate :: Result < ( ) > {
49+ pub async fn prompt_and_image ( project_id : & str ) -> anyhow :: Result < ( ) > {
5050 // ANCHOR: prompt-and-image-client
5151 use google_cloud_aiplatform_v1 as vertexai;
5252 let client = vertexai:: client:: PredictionService :: builder ( )
Original file line number Diff line number Diff line change @@ -19,13 +19,13 @@ mod driver {
1919 const SECRET_ID_LENGTH : usize = 32 ;
2020
2121 #[ tokio:: test( flavor = "multi_thread" ) ]
22- async fn gemini_text_prompt ( ) -> user_guide_samples :: Result < ( ) > {
22+ async fn gemini_text_prompt ( ) -> anyhow :: Result < ( ) > {
2323 let project_id = std:: env:: var ( "GOOGLE_CLOUD_PROJECT" ) . unwrap ( ) ;
2424 user_guide_samples:: gemini:: text_prompt ( & project_id) . await
2525 }
2626
2727 #[ tokio:: test( flavor = "multi_thread" ) ]
28- async fn gemini_prompt_and_image ( ) -> user_guide_samples :: Result < ( ) > {
28+ async fn gemini_prompt_and_image ( ) -> anyhow :: Result < ( ) > {
2929 let project_id = std:: env:: var ( "GOOGLE_CLOUD_PROJECT" ) . unwrap ( ) ;
3030 user_guide_samples:: gemini:: prompt_and_image ( & project_id) . await
3131 }
Original file line number Diff line number Diff line change 1313// limitations under the License.
1414
1515// [START test_only_snippet] ANCHOR: all
16- pub type Result = std:: result:: Result < ( ) , Box < dyn std:: error:: Error > > ;
17-
18- pub async fn initialize_client ( project_id : & str ) -> Result {
16+ pub async fn initialize_client ( project_id : & str ) -> anyhow:: Result < ( ) > {
1917 // [START test_only] ANCHOR: use
2018 use google_cloud_secretmanager_v1:: client:: SecretManagerService ;
2119 // [END test_only] ANCHOR_END: use
@@ -44,14 +42,21 @@ pub async fn initialize_client(project_id: &str) -> Result {
4442
4543 Ok ( ( ) )
4644}
45+
46+ #[ tokio:: main]
47+ async fn main ( ) -> anyhow:: Result < ( ) > {
48+ let project_id = std:: env:: args ( ) . nth ( 1 ) . unwrap ( ) ;
49+
50+ initialize_client ( & project_id) . await
51+ }
4752// [END test_only_snippet] ANCHOR_END: all
4853
4954#[ cfg( all( test, feature = "run-integration-tests" ) ) ]
5055mod tests {
5156 use super :: * ;
5257
5358 #[ tokio:: test( flavor = "multi_thread" ) ]
54- async fn driver ( ) -> Result {
59+ async fn driver ( ) -> anyhow :: Result < ( ) > {
5560 let project_id = std:: env:: var ( "GOOGLE_CLOUD_PROJECT" ) . unwrap ( ) ;
5661 initialize_client ( & project_id) . await
5762 }
Original file line number Diff line number Diff line change @@ -95,6 +95,20 @@ Cloud Shell.
9595 [ create a secret] and rerun the program, and you should see the secret
9696 printed in the output.
9797
98+ You might see a "no space left on device" error. Run the following to remove
99+ build artifacts:
100+
101+ ``` shell
102+ cargo clean
103+ ```
104+
105+ Alternatively, you can build in release mode, which should also use less disk
106+ space:
107+
108+ ``` shell
109+ cargo build --release
110+ ```
111+
98112<!-- markdownlint-enable MD029 -->
99113
100114[ authorize cloud shell ] : https://cloud.google.com/shell/docs/auth
You can’t perform that action at this time.
0 commit comments