Skip to content

Commit acc7847

Browse files
committed
udpated readme
1 parent 7bf90c8 commit acc7847

File tree

5 files changed

+33
-11
lines changed

5 files changed

+33
-11
lines changed

community/gemini/README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
1-
# Restack AI - Gemini Example
1+
# Restack AI - Gemini Example for Autonomous Agents
22

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.
3+
This example demonstrates how to build reliable and scalable autonomous AI agents using Google's Gemini API with Restack. It shows how to handle rate limits (10 requests per minute for free tier with 1500 requests per day limit, concurrency limit), concurrent API calls, and workflow orchestration effectively to create agents that can independently perform complex tasks.
44

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.
5+
Example workflows in `src/workflows/`:
6+
- [Content Generation](src/workflows/generate_content.py): Basic natural language understanding
7+
- [Function Calling](src/workflows/function_call.py): Toolexecution
8+
- [Multi-Function Calling](src/workflows/multi_function_call.py): Complex decision making
9+
- [Multi-Function Calling](src/workflows/multi_function_call_advanced.py): Complex decision making with tools, executed as restack functions (e.g. third party APIs)
10+
- [Swarm](src/workflows/swarm.py): Parallel execution of multiple coordinated agents
611

712

813
## Motivation
914

1015
When building AI applications with Gemini, you need to handle various production challenges:
1116

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.
17+
1. **API Rate Limits**: Gemini API has concurrent request limits that need to be managed across multiple workflows.
1318

1419
2. **Reliability**: AI workflows need retry mechanisms and graceful failure handling for production use.
1520

1621
3. **Scalability**: As your application grows to handle thousands of concurrent agents or requests, you need robust queue management and execution control.
1722

23+
4. **Scheduling**: Coordinating and managing multiple workflows running at different frequencies requires robust scheduling capabilities.
24+
1825
### How Restack Helps
1926

2027
Restack provides built-in solutions for these challenges:
@@ -35,6 +42,8 @@ client.start_service(
3542

3643
3. **Queue Management**: Efficiently manages thousands of concurrent workflows while respecting API limits.
3744

45+
4. **Scheduling**: Run workflows on various schedules (minutely, hourly, daily) or with custom cron expressions.
46+
3847
## Prerequisites
3948

4049
- Python 3.9 or higher
@@ -96,6 +105,20 @@ client.start_service(
96105

97106
8. Schedule workflows via the UI
98107

108+
All workflows are auto-exposed with an RestAPI endpoint, ready to be run or scheduled via api request, or directly from the UI during development.
109+
110+
![UI RestAPI Endpoints](ui-restapi-endpoints.png)
111+
112+
Run or schedule individual workflows.
113+
114+
![UI Run workflow](ui-run-workflow.png)
115+
116+
Run or schedule a workflow, triggering many agents as childworkflows.
117+
118+
![UI Schedule swarm](ui-schedule-swarm.png)
119+
120+
121+
99122
## Project Structure
100123

101124
- `src/`: Main source code directory

community/gemini/schedule_workflow.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import asyncio
22
import time
33
from restack_ai import Restack
4-
from dataclasses import dataclass
4+
from pydantic import BaseModel
55

6-
@dataclass
7-
class InputParams:
8-
user_content: str
6+
class InputParams(BaseModel):
7+
num_cities: int = 10
98

109
async def main():
1110
client = Restack()
1211

13-
workflow_id = f"{int(time.time() * 1000)}-GeminiGenerateOppositeWorkflow"
12+
workflow_id = f"{int(time.time() * 1000)}-GeminiSwarmWorkflow"
1413
runId = await client.schedule_workflow(
15-
workflow_name="GeminiGenerateOppositeWorkflow",
14+
workflow_name="GeminiSwarmWorkflow",
1615
workflow_id=workflow_id,
17-
input=InputParams(user_content="The opposite of hot is")
16+
input=InputParams(num_cities=10)
1817
)
1918

2019
await client.get_workflow_result(
126 KB
Loading

community/gemini/ui-run-workflow.png

43 KB
Loading
38.2 KB
Loading

0 commit comments

Comments
 (0)