Skip to content

Commit ca7af10

Browse files
authoredJan 7, 2025
Merge pull request #1 from iotexproject/feature/sentient-ai
Introduce sentient AI to DePIN plugin
2 parents bce1af0 + 66c1017 commit ca7af10

File tree

10 files changed

+116
-597
lines changed

10 files changed

+116
-597
lines changed
 

‎packages/plugin-depin/README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ Leverage **`@elizaos/plugin-depin`** to seamlessly integrate AI agents with the
3030
Add the following to your `.env` file:
3131

3232
```env
33-
MAPBOX_API_KEY=your-mapbox-api-key
34-
NUBILA_API_KEY=your-nubila-api-key
33+
SENTAI_API_KEY=your-sentai-api-key
3534
```
3635

3736
### Character Configuration
@@ -76,14 +75,13 @@ The **DEPIN_PROJECTS** action empowers Eliza agents to interact with and analyze
7675
- **Device and Revenue Analysis:** Explore statistics such as device deployment, operational costs, and revenue generation.
7776
- **In-depth Queries:** Answer detailed questions about specific DePIN projects by leveraging the rich dataset provided by the DePINScan API.
7877

79-
### Current Weather and Weather Forecast
78+
### Sentient AI
8079

81-
The **CURRENT_WEATHER** action integrates Nubila APIs to provide Eliza agents with weather-related capabilities. Key functionalities include:
80+
The **SENTIENT_AI** action integrates Sentient AI APIs to provide Eliza agents with weather-related capabilities. Key functionalities include:
8281

83-
- **Real-Time Weather Updates:** Deliver current temperature, humidity, and general conditions for specified locations.
84-
- **Forecast Analysis:** Generate short- and long-term forecasts to assist in planning and decision-making.
85-
- **Pattern Recognition:** Analyze weather trends and identify emerging patterns or anomalies.
86-
- **Interactive Content:** Create weather-related insights, summaries, or user-facing content such as memes and visuals.
82+
- **Real-Time Weather Updates:** Deliver current temperature, humidity, and general conditions for specified locations. (supported by Nubila)
83+
- **Forecast Analysis:** Generate short- and long-term forecasts to assist in planning and decision-making. (supported by Nubila)
84+
- **Other Actions** Sentient AI will continue to improve and add more actions based on DePIN data.
8785

8886
---
8987

‎packages/plugin-depin/src/actions/currentWeather.ts

-206
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import {
2+
Action,
3+
HandlerCallback,
4+
IAgentRuntime,
5+
Memory,
6+
State
7+
} from "@elizaos/core";
8+
9+
export const sentientAI: Action = {
10+
name: "SENTIENT_AI",
11+
similes: [
12+
"SENTIENT",
13+
"NEWS",
14+
"WEATHER"
15+
],
16+
description: "Provde realtime information for Weather, News.",
17+
examples: [
18+
[
19+
{
20+
user: "user",
21+
content: {
22+
text: "What's the weather forecast for Tokyo?",
23+
},
24+
},
25+
{
26+
user: "assistant",
27+
content: {
28+
text: "Here's the weather forecast for Tokyo: Tomorrow will be 22°C with partly cloudy skies. The next few days will see temperatures ranging from 18-24°C with a chance of rain on Thursday.",
29+
action: "WEATHER",
30+
},
31+
},
32+
],
33+
[
34+
{
35+
user: "user",
36+
content: {
37+
text: "Will it rain in London this week?",
38+
},
39+
},
40+
{
41+
user: "assistant",
42+
content: {
43+
text: "Looking at London's forecast: There's a 60% chance of rain on Wednesday with temperatures around 15°C. The rest of the week should be mostly cloudy with occasional showers.",
44+
action: "WEATHER",
45+
},
46+
}
47+
],
48+
[
49+
{
50+
user: "user",
51+
content: {
52+
text: "What is the latest news about Trump?",
53+
},
54+
},
55+
{
56+
user: "assistant",
57+
content: {
58+
text: "Here are some of the latest news articles related to Trump: Trump invites House Republicans to Mar-a-Lago for strategy meetings.",
59+
action: "NEWS",
60+
},
61+
},
62+
],
63+
],
64+
validate: async (runtime: IAgentRuntime, message: Memory) => {
65+
// no extra validation needed
66+
return true;
67+
},
68+
handler: async (
69+
runtime: IAgentRuntime,
70+
message: Memory,
71+
state?: State,
72+
options?: { [key: string]: unknown },
73+
callback?: HandlerCallback
74+
) => {
75+
try {
76+
const content = message.content;
77+
78+
const response = await fetch("https://quicksilver.iotex.ai/ask", {
79+
method: "POST",
80+
headers: {
81+
"Content-Type": "application/json",
82+
"API-KEY": runtime.getSetting("SENTAI_API_KEY"),
83+
},
84+
body: JSON.stringify({
85+
q: content.text,
86+
}),
87+
});
88+
89+
if (!response.ok) {
90+
throw new Error(`API error: ${response.statusText}`);
91+
}
92+
93+
const res = await response.json();
94+
95+
callback({
96+
text: res.data,
97+
});
98+
return true;
99+
} catch (error) {
100+
console.error("Error", error.message);
101+
if (callback) {
102+
callback({ text: `Error: ${error.message}` });
103+
}
104+
return false;
105+
}
106+
},
107+
};

0 commit comments

Comments
 (0)