Skip to main content

Built-in Skills

openstackai includes pre-built skills for common operations.

Available Skills

SkillDescription
SearchSkillWeb and local search
CodeSkillCode execution
FileSkillFile operations
WebSkillHTTP requests
MathSkillMathematical operations
DateTimeSkillDate/time utilities

SearchSkill

from openstackai.skills import SearchSkill

search = SearchSkill()

# Use with agent
agent = Agent(
name="Researcher",
tools=[search]
)

Methods

MethodDescription
search_web(query)Search the web
search_news(topic)Search news articles
search_images(query)Search images

Example

from openstackai.skills import SearchSkill

search = SearchSkill(api_key="...")

# Direct use
results = search.search_web("Python tutorials")
for result in results:
print(f"{result.title}: {result.url}")

CodeSkill

from openstackai.skills import CodeSkill

code = CodeSkill()

agent = Agent(
name="Code Assistant",
tools=[code]
)

Methods

MethodDescription
execute_python(code)Run Python code
execute_shell(command)Run shell command
format_code(code, language)Format code

Example

from openstackai.skills import CodeSkill

code = CodeSkill(sandbox=True)

# Execute code
result = code.execute_python("""
import math
print(math.sqrt(144))
""")
print(result.output) # "12.0"

FileSkill

from openstackai.skills import FileSkill

file = FileSkill(base_path="./workspace")

agent = Agent(
name="File Manager",
tools=[file]
)

Methods

MethodDescription
read_file(path)Read file contents
write_file(path, content)Write to file
list_files(directory)List directory
delete_file(path)Delete file

Example

from openstackai.skills import FileSkill

file = FileSkill()

# Read
content = file.read_file("config.json")

# Write
file.write_file("output.txt", "Hello World")

# List
files = file.list_files("./data/")

WebSkill

from openstackai.skills import WebSkill

web = WebSkill()

agent = Agent(
name="Web Agent",
tools=[web]
)

Methods

MethodDescription
fetch_url(url)GET request
post_data(url, data)POST request
download_file(url, path)Download file

Example

from openstackai.skills import WebSkill

web = WebSkill()

# Fetch webpage
content = web.fetch_url("https://example.com")

# POST data
response = web.post_data(
"https://api.example.com/data",
{"key": "value"}
)

MathSkill

from openstackai.skills import MathSkill

math = MathSkill()

agent = Agent(
name="Calculator",
tools=[math]
)

Methods

MethodDescription
calculate(expression)Evaluate expression
solve_equation(equation)Solve algebraically
statistics(data)Calculate stats
convert_units(value, from, to)Unit conversion

Example

from openstackai.skills import MathSkill

math = MathSkill()

result = math.calculate("sin(45) * 2 + sqrt(16)")
stats = math.statistics([1, 2, 3, 4, 5])
converted = math.convert_units(100, "celsius", "fahrenheit")

DateTimeSkill

from openstackai.skills import DateTimeSkill

datetime = DateTimeSkill()

agent = Agent(
name="Scheduler",
tools=[datetime]
)

Methods

MethodDescription
get_current_time(timezone)Current time
parse_date(text)Parse date string
add_time(date, duration)Add duration
diff_dates(date1, date2)Date difference

Combining Skills

from openstackai import Agent
from openstackai.skills import SearchSkill, CodeSkill, FileSkill

agent = Agent(
name="Power User",
instructions="Use your skills to help users",
tools=[
SearchSkill(),
CodeSkill(),
FileSkill()
]
)

See Also

  • [[Creating-Tools]] - Custom tools
  • [[OpenAPI-Tools]] - Generated tools
  • [[Agent]] - Agent class