diff --git a/README.md b/README.md index a19a83b..2978188 100644 --- a/README.md +++ b/README.md @@ -24,8 +24,8 @@ Pkg> add https://github.com/tylerjthomas9/GoogleGenAI.jl/ ## Quick Start -Create a [secret API key in Google AI Studio](https://makersuite.google.com/) - +1. Create a [secret API key in Google AI Studio](https://aistudio.google.com). +2. Set the `GOOGLE_API_KEY` environment variable. ### Generate Content @@ -57,7 +57,7 @@ outputs using GoogleGenAI secret_key = ENV["GOOGLE_API_KEY"] -model = "gemini-pro-vision" +model = "gemini-1.5-flash-latest" prompt = "What is this image?" image_path = "test/example.jpg" response = generate_content(secret_key, model, prompt, image_path) @@ -146,14 +146,21 @@ end ``` outputs ```julia +gemini-1.0-pro-latest gemini-1.0-pro +gemini-pro gemini-1.0-pro-001 -gemini-1.0-pro-latest -gemini-1.0-pro-vision-latest -gemini-1.5-flash-latest gemini-1.5-pro-latest -gemini-pro -gemini-pro-vision +gemini-1.5-pro-001 +gemini-1.5-pro +gemini-1.5-pro-exp-0801 +gemini-1.5-pro-exp-0827 +gemini-1.5-flash-latest +gemini-1.5-flash-001 +gemini-1.5-flash-001-tuning +gemini-1.5-flash +gemini-1.5-flash-exp-0827 +gemini-1.5-flash-8b-exp-0827 ``` ### Safety Settings diff --git a/docs/src/index.md b/docs/src/index.md index 54f89fd..4b44a9c 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -18,8 +18,8 @@ Pkg> add https://github.com/tylerjthomas9/GoogleGenAI.jl/ ## Quick Start -Create a [secret API key in Google AI Studio](https://makersuite.google.com/) - +1. Create a [secret API key in Google AI Studio](https://aistudio.google.com). +2. Set the `GOOGLE_API_KEY` environment variable. ### Generate Content @@ -27,14 +27,14 @@ Create a [secret API key in Google AI Studio](https://makersuite.google.com/) using GoogleGenAI secret_key = ENV["GOOGLE_API_KEY"] -model = "gemini-pro" +model = "gemini-1.5-flash-latest" prompt = "Hello" response = generate_content(secret_key, model, prompt) println(response.text) ``` outputs ```julia -"Hello there! How may I assist you today? Feel free to ask me any questions you may have or give me a command. I'm here to help! 😊" +"Hello! 👋 How can I help you today? 😊" ``` ```julia @@ -44,14 +44,14 @@ println(response.text) ``` outputs ```julia -"Hello there, how may I assist you today?" +"Hello! 👋 How can I help you today? 😊" ``` ```julia using GoogleGenAI secret_key = ENV["GOOGLE_API_KEY"] -model = "gemini-pro-vision" +model = "gemini-1.5-flash-latest" prompt = "What is this image?" image_path = "test/example.jpg" response = generate_content(secret_key, model, prompt, image_path) @@ -65,40 +65,40 @@ outputs ### Multi-turn conversations ```julia -# Define the provider with your API key (placeholder here) +using GoogleGenAI + provider = GoogleProvider(api_key=ENV["GOOGLE_API_KEY"]) api_kwargs = (max_output_tokens=50,) -model_name = "gemini-pro" +model = "gemini-1.5-flash-latest" conversation = [ Dict(:role => "user", :parts => [Dict(:text => "When was Julia 1.0 released?")]) ] -response = generate_content(provider, model_name, conversation) +response = generate_content(provider, model, conversation) push!(conversation, Dict(:role => "model", :parts => [Dict(:text => response.text)])) println("Model: ", response.text) push!(conversation, Dict(:role => "user", :parts => [Dict(:text => "Who created the language?")])) -response = generate_content(provider, model_name, conversation; api_kwargs) +response = generate_content(provider, model, conversation; api_kwargs) println("Model: ", response.text) ``` outputs ```julia -"Model: August 8, 2018" - -"Model: Jeff Bezanson, Alan Edelman, Viral B. Shah, Stefan Karpinski, and Keno Fischer +"Model: Julia 1.0 was released on **August 8, 2018**." -Julia Computing, Inc. is the company that provides commercial support for Julia." +"Model: Julia was created by a team of developers at MIT, led by **Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and Alan Edelman**." ``` ### Count Tokens ```julia using GoogleGenAI -n_tokens = count_tokens(ENV["GOOGLE_API_KEY"], "gemini-pro", "Hello") +model = "gemini-1.5-flash-latest" +n_tokens = count_tokens(ENV["GOOGLE_API_KEY"], model, "The Julia programming language") println(n_tokens) ``` outputs ```julia -1 +4 ``` ### Create Embeddings @@ -140,12 +140,21 @@ end ``` outputs ```julia -gemini-1.0-pro -gemini-1.0-pro-001 gemini-1.0-pro-latest -gemini-1.0-pro-vision-latest +gemini-1.0-pro gemini-pro -gemini-pro-vision +gemini-1.0-pro-001 +gemini-1.5-pro-latest +gemini-1.5-pro-001 +gemini-1.5-pro +gemini-1.5-pro-exp-0801 +gemini-1.5-pro-exp-0827 +gemini-1.5-flash-latest +gemini-1.5-flash-001 +gemini-1.5-flash-001-tuning +gemini-1.5-flash +gemini-1.5-flash-exp-0827 +gemini-1.5-flash-8b-exp-0827 ``` ### Safety Settings @@ -161,7 +170,7 @@ safety_settings = [ Dict("category" => "HARM_CATEGORY_HARASSMENT", "threshold" => "BLOCK_MEDIUM_AND_ABOVE"), Dict("category" => "HARM_CATEGORY_DANGEROUS_CONTENT", "threshold" => "BLOCK_LOW_AND_ABOVE") ] -model = "gemini-pro" +model = "gemini-1.5-flash-latest" prompt = "Hello" api_kwargs = (safety_settings=safety_settings,) response = generate_content(secret_key, model, prompt; api_kwargs) diff --git a/test/runtests.jl b/test/runtests.jl index d24bcd1..f0c0740 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -16,7 +16,7 @@ if haskey(ENV, "GOOGLE_API_KEY") # Generate text from text+image response = generate_content( secret_key, - "gemini-pro-vision", + "gemini-1.5-flash-latest", "What is this picture?", "example.jpg"; api_kwargs,