diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 52d1d7c..e6eb82c 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-24T22:22:57","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.1","generation_timestamp":"2024-02-24T23:10:48","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index ad4f7d2..f83d400 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -1,6 +1,13 @@ -API · GoogleGenAI.jl

API

GoogleProvider
-generate_content
-count_tokens
-embed_content
-list_models
+API · GoogleGenAI.jl

API

GoogleGenAI.GoogleProviderType
Base.@kwdef struct GoogleProvider <: AbstractGoogleProvider
+    api_key::String = ""
+    base_url::String = "https://generativelanguage.googleapis.com"
+    api_version::String = "v1beta"
+end

A configuration object used to set up and authenticate requests to the Google Generative Language API.

Fields

  • api_key::String: Your Google API key.
  • base_url::String: The base URL for the Google Generative Language API. The default is set to "https://generativelanguage.googleapis.com".
  • api_version::String: The version of the API you wish to access. The default is set to "v1beta".
source
GoogleGenAI.generate_contentFunction
generate_content(provider::AbstractGoogleProvider, model_name::String, prompt::String, image_path::String; kwargs...) -> GoogleTextResponse
+generate_content(api_key::String, model_name::String, prompt::String, image_path::String; kwargs...) -> GoogleTextResponse
+
+generate_content(provider::AbstractGoogleProvider, model_name::String, conversation::Vector{Dict{Symbol,Any}}; kwargs...) -> GoogleTextResponse
+generate_content(api_key::String, model_name::String, conversation::Vector{Dict{Symbol,Any}}; kwargs...) -> GoogleTextResponse

Generate content based on a combination of text prompt and an image (optional).

Arguments

  • provider::AbstractGoogleProvider: The provider instance for API requests.
  • api_key::String: Your Google API key as a string.
  • model_name::String: The model to use for content generation.
  • prompt::String: The text prompt to accompany the image.
  • image_path::String (optional): The path to the image file to include in the request.

Keyword Arguments

  • temperature::Float64 (optional): Controls the randomness in the generation process. Higher values result in more random outputs. Typically ranges between 0 and 1.
  • candidate_count::Int (optional): The number of generation candidates to consider. Currently, only one candidate can be specified.
  • max_output_tokens::Int (optional): The maximum number of tokens that the generated content should contain.
  • stop_sequences::Vector{String} (optional): A list of sequences where the generation should stop. Useful for defining natural endpoints in generated content.
  • safety_settings::Vector{Dict} (optional): Settings to control the safety aspects of the generated content, such as filtering out unsafe or inappropriate content.

Returns

  • GoogleTextResponse: The generated content response.
source
GoogleGenAI.count_tokensFunction
count_tokens(provider::AbstractGoogleProvider, model_name::String, prompt::String) -> Int
+count_tokens(api_key::String, model_name::String, prompt::String) -> Int

Calculate the number of tokens generated by the specified model for a given prompt string.

Arguments

  • provider::AbstractGoogleProvider: The provider instance containing API key and base URL information.
  • api_key::String: Your Google API key as a string.
  • model_name::String: The name of the model to use for generating content.
  • prompt::String: The prompt prompt based on which the text is generated.

Returns

  • Int: The total number of tokens that the given prompt string would be broken into by the specified model's tokenizer.
source
GoogleGenAI.embed_contentFunction
embed_content(provider::AbstractGoogleProvider, model_name::String, prompt::String) -> GoogleEmbeddingResponse
+embed_content(api_key::String, model_name::String, prompt::String) -> GoogleEmbeddingResponse

Generate an embedding for the given prompt text using the specified model.

Arguments

  • provider::AbstractGoogleProvider: The provider instance containing API key and base URL information.
  • api_key::String: Your Google API key as a string.
  • model_name::String: The name of the model to use for generating content.
  • prompt::String: The prompt prompt based on which the text is generated.

Returns

  • GoogleEmbeddingResponse
source
GoogleGenAI.list_modelsFunction
list_models(provider::AbstractGoogleProvider) -> Vector{Dict}
+list_models(api_key::String) -> Vector{Dict}

Retrieve a list of available models along with their details from the Google AI API.

Arguments

  • provider::AbstractGoogleProvider: The provider instance containing API key and base URL information.
  • api_key::String: Your Google API key as a string.

Returns

  • Vector{Dict}: A list of dictionaries, each containing details about an available model.
source
diff --git a/dev/index.html b/dev/index.html index 6dd477f..44730a1 100644 --- a/dev/index.html +++ b/dev/index.html @@ -6,4 +6,4 @@ model = "gemini-pro" prompt = "Hello" response = generate_content(secret_key, model, prompt) -println(response.text)

returns

"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! 😊"
+println(response.text)

returns

"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! 😊"
diff --git a/dev/search_index.js b/dev/search_index.js index d9c6fd2..fa0ba61 100644 --- a/dev/search_index.js +++ b/dev/search_index.js @@ -1,3 +1,3 @@ var documenterSearchIndex = {"docs": -[{"location":"api/","page":"API","title":"API","text":"CurrentModule = GoogleGenAI","category":"page"},{"location":"api/#API","page":"API","title":"API","text":"","category":"section"},{"location":"api/","page":"API","title":"API","text":"GoogleProvider\ngenerate_content\ncount_tokens\nembed_content\nlist_models","category":"page"},{"location":"#GoogleGenAI.jl-Docs","page":"Home","title":"GoogleGenAI.jl Docs","text":"","category":"section"},{"location":"#Overview","page":"Home","title":"Overview","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"A Julia wrapper to the Google generative AI API. For API functionality, see reference documentation.","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"From source:","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> using Pkg; Pkg.add(url=\"https://github.com/tylerjthomas9/GoogleGenAI.jl/\")","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> ] # enters the pkg interface\nPkg> add https://github.com/tylerjthomas9/GoogleGenAI.jl/","category":"page"},{"location":"#Quick-Start","page":"Home","title":"Quick Start","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Create a secret API key in Google AI Studio","category":"page"},{"location":"","page":"Home","title":"Home","text":"using GoogleGenAI\n\nsecret_key = ENV[\"GOOGLE_API_KEY\"]\nmodel = \"gemini-pro\"\nprompt = \"Hello\"\nresponse = generate_content(secret_key, model, prompt)\nprintln(response.text)","category":"page"},{"location":"","page":"Home","title":"Home","text":"returns","category":"page"},{"location":"","page":"Home","title":"Home","text":"\"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! 😊\"","category":"page"}] +[{"location":"api/","page":"API","title":"API","text":"CurrentModule = GoogleGenAI","category":"page"},{"location":"api/","page":"API","title":"API","text":"","category":"page"},{"location":"api/#API","page":"API","title":"API","text":"","category":"section"},{"location":"api/","page":"API","title":"API","text":"GoogleProvider\ngenerate_content\ncount_tokens\nembed_content\nlist_models","category":"page"},{"location":"api/#GoogleGenAI.GoogleProvider","page":"API","title":"GoogleGenAI.GoogleProvider","text":"Base.@kwdef struct GoogleProvider <: AbstractGoogleProvider\n api_key::String = \"\"\n base_url::String = \"https://generativelanguage.googleapis.com\"\n api_version::String = \"v1beta\"\nend\n\nA configuration object used to set up and authenticate requests to the Google Generative Language API.\n\nFields\n\napi_key::String: Your Google API key. \nbase_url::String: The base URL for the Google Generative Language API. The default is set to \"https://generativelanguage.googleapis.com\".\napi_version::String: The version of the API you wish to access. The default is set to \"v1beta\".\n\n\n\n\n\n","category":"type"},{"location":"api/#GoogleGenAI.generate_content","page":"API","title":"GoogleGenAI.generate_content","text":"generate_content(provider::AbstractGoogleProvider, model_name::String, prompt::String, image_path::String; kwargs...) -> GoogleTextResponse\ngenerate_content(api_key::String, model_name::String, prompt::String, image_path::String; kwargs...) -> GoogleTextResponse\n\ngenerate_content(provider::AbstractGoogleProvider, model_name::String, conversation::Vector{Dict{Symbol,Any}}; kwargs...) -> GoogleTextResponse\ngenerate_content(api_key::String, model_name::String, conversation::Vector{Dict{Symbol,Any}}; kwargs...) -> GoogleTextResponse\n\nGenerate content based on a combination of text prompt and an image (optional).\n\nArguments\n\nprovider::AbstractGoogleProvider: The provider instance for API requests.\napi_key::String: Your Google API key as a string. \nmodel_name::String: The model to use for content generation.\nprompt::String: The text prompt to accompany the image.\nimage_path::String (optional): The path to the image file to include in the request.\n\nKeyword Arguments\n\ntemperature::Float64 (optional): Controls the randomness in the generation process. Higher values result in more random outputs. Typically ranges between 0 and 1.\ncandidate_count::Int (optional): The number of generation candidates to consider. Currently, only one candidate can be specified.\nmax_output_tokens::Int (optional): The maximum number of tokens that the generated content should contain.\nstop_sequences::Vector{String} (optional): A list of sequences where the generation should stop. Useful for defining natural endpoints in generated content.\nsafety_settings::Vector{Dict} (optional): Settings to control the safety aspects of the generated content, such as filtering out unsafe or inappropriate content.\n\nReturns\n\nGoogleTextResponse: The generated content response.\n\n\n\n\n\n","category":"function"},{"location":"api/#GoogleGenAI.count_tokens","page":"API","title":"GoogleGenAI.count_tokens","text":"count_tokens(provider::AbstractGoogleProvider, model_name::String, prompt::String) -> Int\ncount_tokens(api_key::String, model_name::String, prompt::String) -> Int\n\nCalculate the number of tokens generated by the specified model for a given prompt string.\n\nArguments\n\nprovider::AbstractGoogleProvider: The provider instance containing API key and base URL information.\napi_key::String: Your Google API key as a string. \nmodel_name::String: The name of the model to use for generating content. \nprompt::String: The prompt prompt based on which the text is generated.\n\nReturns\n\nInt: The total number of tokens that the given prompt string would be broken into by the specified model's tokenizer.\n\n\n\n\n\n","category":"function"},{"location":"api/#GoogleGenAI.embed_content","page":"API","title":"GoogleGenAI.embed_content","text":"embed_content(provider::AbstractGoogleProvider, model_name::String, prompt::String) -> GoogleEmbeddingResponse\nembed_content(api_key::String, model_name::String, prompt::String) -> GoogleEmbeddingResponse\n\nGenerate an embedding for the given prompt text using the specified model.\n\nArguments\n\nprovider::AbstractGoogleProvider: The provider instance containing API key and base URL information.\napi_key::String: Your Google API key as a string. \nmodel_name::String: The name of the model to use for generating content. \nprompt::String: The prompt prompt based on which the text is generated.\n\nReturns\n\nGoogleEmbeddingResponse\n\n\n\n\n\n","category":"function"},{"location":"api/#GoogleGenAI.list_models","page":"API","title":"GoogleGenAI.list_models","text":"list_models(provider::AbstractGoogleProvider) -> Vector{Dict}\nlist_models(api_key::String) -> Vector{Dict}\n\nRetrieve a list of available models along with their details from the Google AI API.\n\nArguments\n\nprovider::AbstractGoogleProvider: The provider instance containing API key and base URL information.\napi_key::String: Your Google API key as a string. \n\nReturns\n\nVector{Dict}: A list of dictionaries, each containing details about an available model.\n\n\n\n\n\n","category":"function"},{"location":"#GoogleGenAI.jl-Docs","page":"Home","title":"GoogleGenAI.jl Docs","text":"","category":"section"},{"location":"#Overview","page":"Home","title":"Overview","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"A Julia wrapper to the Google generative AI API. For API functionality, see reference documentation.","category":"page"},{"location":"#Installation","page":"Home","title":"Installation","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"From source:","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> using Pkg; Pkg.add(url=\"https://github.com/tylerjthomas9/GoogleGenAI.jl/\")","category":"page"},{"location":"","page":"Home","title":"Home","text":"julia> ] # enters the pkg interface\nPkg> add https://github.com/tylerjthomas9/GoogleGenAI.jl/","category":"page"},{"location":"#Quick-Start","page":"Home","title":"Quick Start","text":"","category":"section"},{"location":"","page":"Home","title":"Home","text":"Create a secret API key in Google AI Studio","category":"page"},{"location":"","page":"Home","title":"Home","text":"using GoogleGenAI\n\nsecret_key = ENV[\"GOOGLE_API_KEY\"]\nmodel = \"gemini-pro\"\nprompt = \"Hello\"\nresponse = generate_content(secret_key, model, prompt)\nprintln(response.text)","category":"page"},{"location":"","page":"Home","title":"Home","text":"returns","category":"page"},{"location":"","page":"Home","title":"Home","text":"\"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! 😊\"","category":"page"}] }