From b7186b148880b526803c95d1fdc7505466cbe153 Mon Sep 17 00:00:00 2001 From: Mark McDonald Date: Wed, 14 Aug 2024 14:07:53 +0800 Subject: [PATCH 1/2] Add a README for /samples I'm making sure all samples in our various repos have a ToC. This matches the Python & REST READMEs, and I can add a GitHub action if you like - just LMK. * [Python and REST](https://github.com/google-gemini/generative-ai-python/commit/db311dd3f26233206a65b946a17417837ae12905) * [GitHub action](https://github.com/google-gemini/generative-ai-python/blob/main/.github/workflows/samples.yaml) --- samples/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 samples/README.md diff --git a/samples/README.md b/samples/README.md new file mode 100644 index 0000000..2953cde --- /dev/null +++ b/samples/README.md @@ -0,0 +1,22 @@ +# Gemini API Swift SDK sample code + +This directory contains sample code for key features of the SDK, organised by high level feature. + +These samples are embedded in parts of the [documentation](https://ai.google.dev), most notably in the [API reference](https://ai.google.dev/api). + +Each file is structured as a runnable test case, ensuring that samples are executable and functional. Each test demonstrates a single concept, and contains region tags that are used to demarcate the test scaffolding from the spotlight code. If you are contributing, code within region tags should follow sample code best practices - being clear, complete and concise. + +## Contents + +| File | Description | +| ---- | ----------- | +| [APIKey.swift](./APIKey.swift) | Seetting up your API key | +| [ChatSnippets.swift](./ChatSnippets.swift) | Multi-turn chat conversations | +| [CodeExecution.swift](./CodeExecution.swift) | Executing code | +| [ControlledGeneration.swift](./ControlledGeneration.swift) | Generating content with output constraints (e.g. JSON mode) | +| [CountTokens.swift](./CountTokens.swift) | Counting input and output tokens | +| [FunctionCalling.swift](./FunctionCalling.swift) | Using function calling | +| [GenerationConfig.swift](./GenerationConfig.swift) | Setting model parameters | +| [SafetySettings.swift](./SafetySettings.swift) | Setting and using safety controls | +| [SystemInstructions.swift](./SystemInstructions.swift) | Setting system instructions | +| [TextGeneration.swift](./TextGeneration.swift) | Generating text | From d5f110fbee5681630e6b7b1c81921abd05c4f203 Mon Sep 17 00:00:00 2001 From: Mark McDonald Date: Fri, 16 Aug 2024 10:28:07 +0800 Subject: [PATCH 2/2] Fix typo --- samples/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/README.md b/samples/README.md index 2953cde..86c9335 100644 --- a/samples/README.md +++ b/samples/README.md @@ -10,7 +10,7 @@ Each file is structured as a runnable test case, ensuring that samples are execu | File | Description | | ---- | ----------- | -| [APIKey.swift](./APIKey.swift) | Seetting up your API key | +| [APIKey.swift](./APIKey.swift) | Setting up your API key | | [ChatSnippets.swift](./ChatSnippets.swift) | Multi-turn chat conversations | | [CodeExecution.swift](./CodeExecution.swift) | Executing code | | [ControlledGeneration.swift](./ControlledGeneration.swift) | Generating content with output constraints (e.g. JSON mode) |