-
Notifications
You must be signed in to change notification settings - Fork 256
Add Interactions API skill #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
efb19d1
93e7666
88ad4c0
687de96
e42e967
13adffd
36cce52
ad25063
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| --- | ||
| name: interactions-api | ||
| description: Use this skill when working with the Gemini Interactions API for building interactive chat experiences, managing conversation state, and implementing turn-based interactions with Gemini models. | ||
| --- | ||
|
|
||
| # Gemini Interactions API Skill | ||
|
|
||
| ## Overview | ||
|
|
||
| The Gemini Interactions API provides a structured way to build interactive conversational experiences with Gemini models. Key capabilities include: | ||
| - **Interactive Chat** - Build multi-turn conversations | ||
| - **State Management** - Maintain conversation context across interactions | ||
| - **Turn-based Communication** - Structured request/response patterns | ||
| - **Session Handling** - Manage conversation sessions efficiently | ||
|
|
||
| ## Quick Start | ||
|
|
||
| ### Python | ||
| ```python | ||
| import google.generativeai as genai | ||
|
||
|
|
||
| # Assumes GOOGLE_API_KEY is set as an environment variable | ||
| model = genai.GenerativeModel('gemini-1.5-flash-latest') | ||
| chat = model.start_chat() | ||
| response = chat.send_message("Hello there! Can you tell me a joke?") | ||
| print(response.text) | ||
| ``` | ||
|
|
||
| ### JavaScript/TypeScript | ||
| ```typescript | ||
| import { GoogleGenAI } from "@google/genai"; | ||
|
|
||
| const ai = new GoogleGenAI({}); | ||
|
|
||
| // To start a chat, use startChat() | ||
| async function runChat() { | ||
| const model = ai.getGenerativeModel({ model: "gemini-1.5-flash-latest" }); | ||
| const chat = model.startChat(); | ||
| const result = await chat.sendMessage("Hello there! Can you tell me a joke?"); | ||
| const response = await result.response; | ||
| const text = response.text(); | ||
| console.log(text); | ||
| } | ||
|
|
||
| runChat(); | ||
| ``` | ||
|
|
||
| ## Resources | ||
|
|
||
| - [Official Interactions API Documentation](https://ai.google.dev/gemini-api/docs/interactions?ua=chat) | ||
| - [Gemini API Reference](https://ai.google.dev/api) | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Maintain Context**: Keep track of conversation history for coherent interactions | ||
| 2. **Handle State**: Properly manage session state between turns | ||
| 3. **Error Handling**: Implement robust error handling for network and API issues | ||
| 4. **Rate Limiting**: Be mindful of API rate limits in interactive scenarios | ||
|
|
||
| ## Common Use Cases | ||
|
|
||
| - Multi-turn chatbots | ||
| - Interactive assistants | ||
| - Conversational interfaces | ||
| - Context-aware Q&A systems | ||
|
|
||
| --- | ||
|
|
||
| For more details, refer to the [official documentation](https://ai.google.dev/gemini-api/docs/interactions?ua=chat). | ||
Uh oh!
There was an error while loading. Please reload this page.