Wiki Plugin
The Wiki Plugin enables your agent to retrieve blockchain knowledge from IQ.Wiki
Installation
Section titled โInstallationโnpm i @iqai/agent @iqai/plugin-wiki
pnpm add @iqai/agent @iqai/plugin-wiki
yarn add @iqai/agent @iqai/plugin-wiki
Basic Setup
Section titled โBasic SetupโHereโs a complete example of setting up an agent with the Wiki plugin:
import { AgentBuilder, ModelProviderName } from "@iqai/agent";import { createWikiPlugin } from "@iqai/plugin-wiki";
async function main() { // Initialize Wiki plugin const wikiPlugin = await createWikiPlugin();
// Create agent with plugin const agent = new AgentBuilder() .withModelProvider( ModelProviderName.OPENAI, process.env.OPENAI_API_KEY ) .withPlugin(wikiPlugin) .build();
await agent.start();}
main().catch(console.error);
Available Operations
Section titled โAvailable Operationsโ- Wiki Retrieval: Get specific wiki articles by ID
- User Created Wikis: Get wikis created by a specific user
- User Edited Wikis: Get wikis edited by a specific user
- User Wiki Activities: Get all wiki activities (both creations and edits) by a specific user
- Time-Filtered Activities: Filter any of the above operations by time range
Usage Examples
Section titled โUsage ExamplesโOperation | Example Query |
---|---|
Get Wiki | Show me the wiki for bitcoin |
User Created Wikis | Show wikis created by user 0x8AF7a19a26d8FBC48dEfB35AEfb15Ec8c407f889 |
User Edited Wikis | Show edited wikis by user 0x8AF7a19a26d8FBC48dEfB35AEfb15Ec8c407f889 |
User Wiki Activities | Show me wiki activities for 0x8AF7a19a26d8FBC48dEfB35AEfb15Ec8c407f889 |
Time-Filtered Activities | Show wiki activities for 0x8AF7a19a26d8FBC48dEfB35AEfb15Ec8c407f889 in last 24 hours |
Getting a wiki
Section titled โGetting a wikiโQuery:
Get me wiki on ai meme hub
The agent will process this to:
{ "id": "ai-meme-hub",}
Response will be formatted as:
๐ Wiki Details- Title: AI Meme Hub- Summary: AI Meme Hub is a decentralized platform for creating and sharing AI-generated memes...
๐ Source: https://iq.wiki/ai-meme-hub๐ Transaction: https://polygonscan.com/tx/0x123...
Getting user created wikis
Section titled โGetting user created wikisโQuery:
Get me wikis created by 0x9130241234123434
The agent will process this to:
{ "id": "0x9130241234123434"}
Response will be formatted as:
๐ Wiki Created- Title: Ethereum- Summary: Ethereum is a decentralized platform...- Created: 5/5/2023, 11:03:26 PM
๐ Source: https://iq.wiki/ethereum๐ Transaction: https://polygonscan.com/tx/0x456...
๐ Wiki Created- Title: Solana- Summary: Solana is a high-performance blockchain...- Created: 5/4/2023, 10:15:42 AM
๐ Source: https://iq.wiki/solana๐ Transaction: https://polygonscan.com/tx/0x789...
Getting user edited wikis
Section titled โGetting user edited wikisโQuery:
Show me edited wikis by 0x9130241234123434
The agent will process this to:
{ "id": "0x9130241234123434"}
Response will be formatted as:
๐ Wiki Edited- Title: Bitcoin- Summary: Bitcoin is a decentralized digital currency...- Edited: 5/6/2023, 1:26:58 AM- Changes: 52 words (21.36%)- Modified sections: content, tags
๐ Source: https://iq.wiki/revision/0f9ed751-f46a-40f7-af56-a54cc8951754๐ Transaction: https://polygonscan.com/tx/0xabc...
Getting user wiki activities
Section titled โGetting user wiki activitiesโQuery:
Show me wiki activities for 0x9130241234123434
The agent will process this to:
{ "id": "0x9130241234123434"}
Response will include both creations and edits:
๐ Wiki Edited- Title: Bitcoin- Summary: Bitcoin is a decentralized digital currency...- Edited: 5/6/2023, 1:26:58 AM- Changes: 52 words (21.36%)- Modified sections: content, tags
๐ Source: https://iq.wiki/revision/0f9ed751-f46a-40f7-af56-a54cc8951754๐ Transaction: https://polygonscan.com/tx/0xabc...
๐ Wiki Created- Title: Ethereum- Summary: Ethereum is a decentralized platform...- Created: 5/5/2023, 11:03:26 PM
๐ Source: https://iq.wiki/ethereum๐ Transaction: https://polygonscan.com/tx/0x456...
Getting time-filtered user activities
Section titled โGetting time-filtered user activitiesโQuery:
Get me wiki activities by 0x9130241234123434 in last 24 hours
The agent will process this to:
{ "id": "0x9130241234123434", "timeFrameSeconds": 86400}
Error Handling
Section titled โError HandlingโAlways implement proper error handling when using the plugin:
try { const wikiPlugin = await createWikiPlugin(); } catch (error) { console.error('Failed to initialize Wiki plugin:', error); }
Best Practices
Section titled โBest Practicesโ- ID Validation: Ensure wiki IDs are correctly formatted
- User Address Format: Use complete Ethereum addresses
- Time Filtering: Specify clear time periods for filtered results
- Error Handling: Implement robust error handling for all operations
Common Issues and Troubleshooting
Section titled โCommon Issues and Troubleshootingโ- Wiki Not Found: Verify the wiki ID exists on IQ.Wiki
- User Not Found: Ensure the Ethereum address is correct
- No Recent Activities: The user may not have any wiki activities in the specified time period
- API Connection: Check your network connection if requests fail