Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions skills/dicto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 📚 Dicto - Dictionary Lookup Skill

Dicto is a skill for looking up English word definitions using the free [DictionaryAPI](https://dictionaryapi.dev). It returns detailed definitions, parts of speech, example usages, and a fallback Google link for further lookup.

## 🔍 Features

- Look up definitions of English words
- Part of speech identification (e.g., noun, verb)
- Example usages when available
- Fallback to Google definition search if no definitions are found

---

## 🚀 How It Works

When a user inputs a word (e.g., `run`), Dicto performs a search for said word and provides the user with relevant information relating to searched word

User: run
Dicto: 🔍 Looking up "run"
📖 Definition: To move swiftly on foot.
Verb: To run.
Noun: An act or instance of running. (Example: I went for a quick run this morning.)
Noun: A trip or errand. (Example: I'm making a run to the store.
View More on Dictionary: https://www.google.com/search?q=define+run

If the word is not found or an error occurs, Dicto informs the user and provides a Google search link as an alternative.

User: htftya
Dicto: Sorry, we couldn't find a definition for "htftya" in `en`.
View More on Dictionary: https://www.google.com/search?q=htftya


---

## 📁 File Structure

dicto/
├── base.py
├── word_lookup.py
├── __init__.py
├── schema.json
├── test_skill.py
├── dicto.png
└── README.md


6 changes: 6 additions & 0 deletions skills/dicto/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .word_lookup import LookupWord

def get_skills():
return {
"word_lookup": LookupWord,
}
35 changes: 35 additions & 0 deletions skills/dicto/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import requests

class DictionarySkillBase:
SUPPORTED_LANGUAGES = {
"en": "English",
"es": "Spanish",
"fr": "French",
"de": "German",
"it": "Italian",
"ja": "Japanese",
"ru": "Russian",
"ko": "Korean",
"pt-BR": "Portuguese (Brazil)",
"hi": "Hindi",
"tr": "Turkish"
}

def __init__(self, config=None):
self.api_url = "https://api.dictionaryapi.dev/api/v2/entries/"
self.default_lang = (config or {}).get("language", "en")
if self.default_lang not in self.SUPPORTED_LANGUAGES:
print(f"⚠️ Unsupported default language: {self.default_lang}. Falling back to English.")
self.default_lang = "en"

def fetch_word_data(self, word: str, lang: str = None):
lang_code = lang or self.default_lang
if lang_code not in self.SUPPORTED_LANGUAGES:
return None
try:
response = requests.get(f"{self.api_url}{lang_code}/{word}", timeout=5)
if response.status_code == 200:
return response.json()
except requests.RequestException as e:
print(f"Request error: {e}")
return None
Binary file added skills/dicto/dicto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions skills/dicto/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from pydantic import BaseModel
from typing import Optional

class DictoInput(BaseModel):
word: str
lang: Optional[str] = "en"

class DictoOutput(BaseModel):
result: str
47 changes: 47 additions & 0 deletions skills/dicto/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"title": "Dictionary Lookup Skill",
"description": "Looks up a word's definition, part of speech, and example usage from a free dictionary.",
"x-icon": "https://raw.githubusercontent.com/Negred0/intentkit/main/skills/dicto/dicto.png",
"x-tags": [
"Language",
"Utility"
],
"x-api-key": "none",
"properties": {
"enabled": {
"type": "boolean",
"title": "Enabled",
"description": "Enable or disable the Dictionary Lookup Skill",
"default": true
},
"states": {
"type": "object",
"properties": {
"word_lookup": {
"type": "string",
"title": "Word Lookup Access",
"enum": [
"disabled",
"public",
"private"
],
"x-enum-title": [
"Disabled",
"Agent Owner + All Users",
"Agent Owner Only"
],
"description": "Controls who can use the dictionary lookup functionality",
"default": "public"
}
},
"description": "Controls access level for the dictionary lookup functionality"
}
},
"required": [
"enabled",
"states"
],
"additionalProperties": true
}
24 changes: 24 additions & 0 deletions skills/dicto/word_lookup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from abstracts.skill import IntentKitSkill
from .models import DictoInput, DictoOutput
import requests

class DictoSkill(IntentKitSkill):
name: str = "dicto"
description: str = "Looks up dictionary definitions for a given word."
args_schema = DictoInput

def _run(self, word: str, lang: str = "en") -> DictoOutput:
word = word.strip().lower()
if not word:
return DictoOutput(result="Please provide a word to define.")

try:
response = requests.get(f"https://api.dictionaryapi.dev/api/v2/entries/{lang}/{word}")
if response.status_code != 200:
raise ValueError("Word not found.")
data = response.json()
definitions = data[0]['meanings'][0]['definitions'][0]['definition']
result = f"🔍 Looking up \"{word}\"\n📖 Definition: {definitions}\n\nView More on Dictionary: https://www.google.com/search?q=define+{word}"
return DictoOutput(result=result)
except Exception as e:
return DictoOutput(result=f"Sorry, we couldn't find a definition for \"{word}\" in `{lang}`.\n\nView More on Dictionary: https://www.google.com/search?q=define+{word}")