Skip to content

Commit

Permalink
Merge pull request #1 from iotexproject/feature/sentient-ai
Browse files Browse the repository at this point in the history
Introduce sentient AI to DePIN plugin
  • Loading branch information
guo authored Jan 7, 2025
2 parents bce1af0 + 66c1017 commit ca7af10
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 597 deletions.
14 changes: 6 additions & 8 deletions packages/plugin-depin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ Leverage **`@elizaos/plugin-depin`** to seamlessly integrate AI agents with the
Add the following to your `.env` file:

```env
MAPBOX_API_KEY=your-mapbox-api-key
NUBILA_API_KEY=your-nubila-api-key
SENTAI_API_KEY=your-sentai-api-key
```

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

### Current Weather and Weather Forecast
### Sentient AI

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

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

---

Expand Down
206 changes: 0 additions & 206 deletions packages/plugin-depin/src/actions/currentWeather.ts

This file was deleted.

107 changes: 107 additions & 0 deletions packages/plugin-depin/src/actions/sentientai.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import {
Action,
HandlerCallback,
IAgentRuntime,
Memory,
State
} from "@elizaos/core";

export const sentientAI: Action = {
name: "SENTIENT_AI",
similes: [
"SENTIENT",
"NEWS",
"WEATHER"
],
description: "Provde realtime information for Weather, News.",
examples: [
[
{
user: "user",
content: {
text: "What's the weather forecast for Tokyo?",
},
},
{
user: "assistant",
content: {
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.",
action: "WEATHER",
},
},
],
[
{
user: "user",
content: {
text: "Will it rain in London this week?",
},
},
{
user: "assistant",
content: {
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.",
action: "WEATHER",
},
}
],
[
{
user: "user",
content: {
text: "What is the latest news about Trump?",
},
},
{
user: "assistant",
content: {
text: "Here are some of the latest news articles related to Trump: Trump invites House Republicans to Mar-a-Lago for strategy meetings.",
action: "NEWS",
},
},
],
],
validate: async (runtime: IAgentRuntime, message: Memory) => {
// no extra validation needed
return true;
},
handler: async (
runtime: IAgentRuntime,
message: Memory,
state?: State,
options?: { [key: string]: unknown },
callback?: HandlerCallback
) => {
try {
const content = message.content;

const response = await fetch("https://quicksilver.iotex.ai/ask", {
method: "POST",
headers: {
"Content-Type": "application/json",
"API-KEY": runtime.getSetting("SENTAI_API_KEY"),
},
body: JSON.stringify({
q: content.text,
}),
});

if (!response.ok) {
throw new Error(`API error: ${response.statusText}`);
}

const res = await response.json();

callback({
text: res.data,
});
return true;
} catch (error) {
console.error("Error", error.message);
if (callback) {
callback({ text: `Error: ${error.message}` });
}
return false;
}
},
};
Loading

0 comments on commit ca7af10

Please sign in to comment.