Skip to content

Commit 987ea93

Browse files
committed
Readme
1 parent 8bf5f01 commit 987ea93

File tree

1 file changed

+40
-16
lines changed

1 file changed

+40
-16
lines changed

community/gemini/README.md

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
1-
# Restack AI SDK - Gemini Generate Content Example
1+
# Restack AI - Gemini Example
2+
3+
This example demonstrates how to build reliable and scalable AI applications using Google's Gemini API with Restack. It shows how to handle rate limits, concurrent API calls, and workflow orchestration effectively.
4+
5+
We build four example workflows: a basic content generation workflow, a function calling workflow, a multi-function calling workflow, and a swarm workflow that demonstrates parallel execution.
6+
7+
8+
## Motivation
9+
10+
When building AI applications with Gemini, you need to handle various production challenges:
11+
12+
1. **API Rate Limits**: Gemini API has concurrent request limits (e.g., 3 concurrent calls)([1](https://googleapis.github.io/python-genai)) that need to be managed across multiple workflows.
13+
14+
2. **Reliability**: AI workflows need retry mechanisms and graceful failure handling for production use.
15+
16+
3. **Scalability**: As your application grows to handle thousands of concurrent agents or requests, you need robust queue management and execution control.
17+
18+
### How Restack Helps
19+
20+
Restack provides built-in solutions for these challenges:
21+
22+
1. **Automated Rate Limiting**: Define rate limits in service options and let Restack handle the queuing:
23+
```python
24+
client.start_service(
25+
task_queue="gemini",
26+
functions=[generate_content, function_call],
27+
options=ServiceOptions(
28+
rate_limit=3, # Match Gemini's concurrent call limit
29+
max_concurrent_function_runs=3
30+
)
31+
)
32+
```
33+
34+
2. **Built-in Retries**: Restack automatically handles retries and failure scenarios.
35+
36+
3. **Queue Management**: Efficiently manages thousands of concurrent workflows while respecting API limits.
237

338
## Prerequisites
439

@@ -25,8 +60,7 @@
2560

2661
```bash
2762
git clone https://github.com/restackio/examples-python
28-
cd examples-python/examples/gemini_generate_content
29-
```
63+
cd examples-python/community/gemini
3064

3165
4. Install dependencies using Poetry:
3266

@@ -52,25 +86,15 @@
5286
export GEMINI_API_KEY=<your-api-key>
5387
```
5488

55-
6. Run the services:
89+
6. Run the services in dev:
5690

5791
```bash
58-
poetry run services
92+
poetry run dev
5993
```
6094

6195
This will start the Restack service with the defined workflows and functions.
6296

63-
7. In a new terminal, schedule the workflow:
64-
65-
```bash
66-
poetry shell
67-
```
68-
69-
```bash
70-
poetry run schedule
71-
```
72-
73-
This will schedule the `GeminiGenerateOppositeWorkflow` and print the result.
97+
8. Schedule workflows via the UI
7498

7599
## Project Structure
76100

0 commit comments

Comments
 (0)