Skip to content

Commit f6a11dc

Browse files
authored
fix(deps): update pyproject config and add template documentation #2
fix(deps): update pyproject config and add template documentation
2 parents ece9c92 + 55cb94d commit f6a11dc

File tree

3 files changed

+127
-670
lines changed

3 files changed

+127
-670
lines changed

README.md

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@ Flare AI Kit template for AI x DeFi (DeFAI).
1818

1919
<img width="500" alt="Artemis" src="https://github.com/user-attachments/assets/921fbfe2-9d52-496c-9b48-9dfc32a86208" />
2020

21+
## 🏗️ Repository Structure
22+
23+
```plaintext
24+
src/flare_ai_defai/
25+
├── ai/ # AI Provider implementations
26+
│ ├── base.py # Base AI provider interface
27+
│ ├── gemini.py # Google Gemini integration
28+
│ └── openrouter.py # OpenRouter integration
29+
├── api/ # API layer
30+
│ ├── middleware/ # Request/response middleware
31+
│ └── routes/ # API endpoint definitions
32+
├── attestation/ # TEE attestation
33+
│ ├── vtpm_attestation.py # vTPM client
34+
│ └── vtpm_validation.py # Token validation
35+
├── blockchain/ # Blockchain operations
36+
│ ├── explorer.py # Chain explorer client
37+
│ └── flare.py # Flare network provider
38+
└── prompts/ # AI system prompts & templates
39+
```
40+
2141
## 🏗️ Build & Run Instructions
2242

2343
You can deploy Flare AI DeFAI using Docker (recommended) or set up the backend and frontend manually.
@@ -138,7 +158,7 @@ For deployment on Confidential Space (AMD SEV):
138158

139159
```bash
140160
gcloud compute instances create $INSTANCE_NAME \
141-
--project=pacific-smile-435514-h4 \
161+
--project=verifiable-ai-hackathon \
142162
--zone=us-central1-c \
143163
--machine-type=n2d-standard-2 \
144164
--network-interface=network-tier=PREMIUM,nic-type=GVNIC,stack-type=IPV4_ONLY,subnet=default \
@@ -150,7 +170,7 @@ tee-env-WEB3_PROVIDER_URL=$WEB3_PROVIDER_URL,\
150170
tee-env-SIMULATE_ATTESTATION=false \
151171
--maintenance-policy=MIGRATE \
152172
--provisioning-model=STANDARD \
153-
--service-account=magureanuhoria@pacific-smile-435514-h4.iam.gserviceaccount.com \
173+
--service-account=confidential-sa@verifiable-ai-hackathon.iam.gserviceaccount.com \
154174
--scopes=https://www.googleapis.com/auth/cloud-platform \
155175
--min-cpu-platform="AMD Milan" \
156176
--tags=flare-ai,http-server,https-server \
@@ -219,3 +239,97 @@ If you encounter issues, follow these steps:
219239

220240
3. **Check Firewall Settings:**
221241
Confirm that your instance is publicly accessible on port `80`.
242+
243+
## 🔑 Key Components
244+
245+
The following scripts are the crucial parts of this template and provide a strong base for building and customizing your autonomous AI agent. You can tweak these components to extend functionality, integrate additional features, or adapt them to your project's specific needs.
246+
247+
### Blockchain Integration (`blockchain/`)
248+
249+
This module handles interactions with the Flare blockchain. The `FlareProvider` class abstracts operations such as wallet creation, transaction construction, and secure transaction submission.
250+
251+
```python
252+
from flare_ai_defai.blockchain import FlareProvider
253+
254+
# Initialize provider
255+
provider = FlareProvider(web3_provider_url="https://flare-api.example")
256+
257+
# Generate a new wallet address
258+
address = provider.generate_account()
259+
print("New wallet address:", address)
260+
261+
# Create a token transfer transaction
262+
tx = provider.create_send_flr_tx(
263+
to_address="0xRecipientAddress",
264+
amount=1.5
265+
)
266+
267+
# Sign and send the transaction
268+
tx_hash = provider.sign_and_send_transaction(tx)
269+
print("Transaction Hash:", tx_hash)
270+
```
271+
272+
### AI Integration (`ai/`)
273+
274+
The AI integration layer allows you to interact with various AI providers through a unified interface. The architecture is modular enough to support alternative providers.
275+
276+
```python
277+
from flare_ai_defai.ai import GeminiProvider
278+
279+
# Initialize the AI provider with required credentials and model settings
280+
ai = GeminiProvider(
281+
api_key="YOUR_API_KEY",
282+
model="gemini-pro"
283+
)
284+
285+
# Generate a response from the AI based on your prompt
286+
response = ai.send_message("Explain Flare's FAssets")
287+
print("AI Response:", response.text)
288+
```
289+
290+
### TEE Attestation (`attestation/`)
291+
292+
The attestation module ensures that critical operations run securely within a Trusted Execution Environment.
293+
294+
```python
295+
from flare_ai_defai.attestation import Vtpm, VtpmValidation
296+
297+
# Obtain an attestation token from the TEE
298+
vtpm = Vtpm()
299+
token = vtpm.get_token(nonces=["random_nonce"])
300+
print("Attestation Token:", token)
301+
302+
# Validate the attestation token to ensure secure execution
303+
validator = VtpmValidation()
304+
claims = validator.validate_token(token)
305+
print("Token Claims:", claims)
306+
```
307+
308+
## 💡 Example Use Cases & Project Ideas
309+
310+
Below are several detailed project ideas demonstrating how the template can be used to build autonomous AI agents for Flare's DeFi ecosystem:
311+
312+
### NLP interface for Flare ecosystem
313+
314+
Implement a natural language command parser that translates user intent into specific protocol actions, e.g.:
315+
316+
```plaintext
317+
"Swap 100 FLR to USDC and deposit as collateral on Kinetic" →
318+
{
319+
action: ["swap", "deposit"],
320+
protocols: ["SparkDEX", "Kinetic"],
321+
amounts: [100],
322+
tokens: ["FLR", "USDC"]
323+
}
324+
```
325+
326+
- Add cross-protocol optimization features:
327+
328+
- Automatic route splitting across DEXs for better prices
329+
- Gas optimization by batching multiple transactions
330+
- Yield optimization by comparing lending rates across protocols
331+
332+
- Automated token swaps and integrations with Flare ecosystem applications:
333+
- [SparkDEX](http://sparkdex.ai/): Token swaps + Perpetual futures
334+
- [Kinetic](http://kinetic.market/): Borrow-lend protocol
335+
- [RainDEX](http://rainlang.xyz): Trading strategies

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ reportUnusedExpression = true
7878
reportUnnecessaryTypeIgnoreComment = true
7979
reportMatchNotExhaustive = true
8080
reportImplicitOverride = true
81-
reportShadowedImports = true
81+
reportShadowedImports = true

0 commit comments

Comments
 (0)