CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-semantic-kernel

Semantic Kernel Python SDK - comprehensive AI development framework for building AI agents and multi-agent systems

Pending
Overview
Eval results
Files

core-plugins.mddocs/

Core Plugins

Built-in plugins providing essential functionality including HTTP requests, mathematical operations, text processing, time operations, web search, conversation summarization, and Python code execution.

Capabilities

HTTP Plugin

HTTP client functionality for making web requests and API calls.

class HttpPlugin:
    """
    Plugin for making HTTP requests.
    """
    
    @kernel_function(description="Send HTTP GET request")
    async def get(self, url: str, headers: str = "") -> str:
        """
        Send HTTP GET request.
        
        Parameters:
        - url: Target URL for the request
        - headers: Optional headers as JSON string
        
        Returns:
        Response content as string
        """
    
    @kernel_function(description="Send HTTP POST request")
    async def post(self, url: str, body: str = "", headers: str = "") -> str:
        """
        Send HTTP POST request.
        
        Parameters:
        - url: Target URL for the request
        - body: Request body content
        - headers: Optional headers as JSON string
        
        Returns:
        Response content as string
        """
    
    @kernel_function(description="Send HTTP PUT request")
    async def put(self, url: str, body: str = "", headers: str = "") -> str:
        """
        Send HTTP PUT request.
        
        Parameters:
        - url: Target URL for the request
        - body: Request body content
        - headers: Optional headers as JSON string
        
        Returns:
        Response content as string
        """
    
    @kernel_function(description="Send HTTP DELETE request")
    async def delete(self, url: str, headers: str = "") -> str:
        """
        Send HTTP DELETE request.
        
        Parameters:
        - url: Target URL for the request
        - headers: Optional headers as JSON string
        
        Returns:
        Response content as string
        """

Math Plugin

Mathematical operations and calculations.

class MathPlugin:
    """
    Plugin for mathematical operations.
    """
    
    @kernel_function(description="Add two numbers")
    def add(self, value1: float, value2: float) -> float:
        """
        Add two numbers.
        
        Parameters:
        - value1: First number
        - value2: Second number
        
        Returns:
        Sum of the two numbers
        """
    
    @kernel_function(description="Subtract two numbers")
    def subtract(self, value1: float, value2: float) -> float:
        """
        Subtract second number from first.
        
        Parameters:
        - value1: First number (minuend)
        - value2: Second number (subtrahend)
        
        Returns:
        Difference of the two numbers
        """
    
    @kernel_function(description="Multiply two numbers")
    def multiply(self, value1: float, value2: float) -> float:
        """
        Multiply two numbers.
        
        Parameters:
        - value1: First number
        - value2: Second number
        
        Returns:
        Product of the two numbers
        """
    
    @kernel_function(description="Divide two numbers")
    def divide(self, value1: float, value2: float) -> float:
        """
        Divide first number by second.
        
        Parameters:
        - value1: Dividend
        - value2: Divisor
        
        Returns:
        Quotient of the division
        """
    
    @kernel_function(description="Calculate absolute value")
    def abs(self, value: float) -> float:
        """
        Calculate absolute value.
        
        Parameters:
        - value: Input number
        
        Returns:
        Absolute value of the input
        """
    
    @kernel_function(description="Calculate ceiling of a number")
    def ceiling(self, value: float) -> int:
        """
        Calculate ceiling (round up) of a number.
        
        Parameters:
        - value: Input number
        
        Returns:
        Smallest integer greater than or equal to input
        """
    
    @kernel_function(description="Calculate floor of a number")
    def floor(self, value: float) -> int:
        """
        Calculate floor (round down) of a number.
        
        Parameters:
        - value: Input number
        
        Returns:
        Largest integer less than or equal to input
        """
    
    @kernel_function(description="Calculate maximum of two numbers")
    def max(self, value1: float, value2: float) -> float:
        """
        Find maximum of two numbers.
        
        Parameters:
        - value1: First number
        - value2: Second number
        
        Returns:
        Maximum of the two numbers
        """
    
    @kernel_function(description="Calculate minimum of two numbers")
    def min(self, value1: float, value2: float) -> float:
        """
        Find minimum of two numbers.
        
        Parameters:
        - value1: First number
        - value2: Second number
        
        Returns:
        Minimum of the two numbers
        """

Text Plugin

Text manipulation and processing utilities.

class TextPlugin:
    """
    Plugin for text manipulation operations.
    """
    
    @kernel_function(description="Convert text to uppercase")
    def uppercase(self, input: str) -> str:
        """
        Convert text to uppercase.
        
        Parameters:
        - input: Input text
        
        Returns:
        Text converted to uppercase
        """
    
    @kernel_function(description="Convert text to lowercase")
    def lowercase(self, input: str) -> str:
        """
        Convert text to lowercase.
        
        Parameters:
        - input: Input text
        
        Returns:
        Text converted to lowercase
        """
    
    @kernel_function(description="Trim whitespace from text")
    def trim(self, input: str) -> str:
        """
        Remove leading and trailing whitespace.
        
        Parameters:
        - input: Input text
        
        Returns:
        Text with whitespace trimmed
        """
    
    @kernel_function(description="Trim start whitespace from text")
    def trim_start(self, input: str) -> str:
        """
        Remove leading whitespace.
        
        Parameters:
        - input: Input text
        
        Returns:
        Text with leading whitespace removed
        """
    
    @kernel_function(description="Trim end whitespace from text")
    def trim_end(self, input: str) -> str:
        """
        Remove trailing whitespace.
        
        Parameters:
        - input: Input text
        
        Returns:
        Text with trailing whitespace removed
        """
    
    @kernel_function(description="Get text length")
    def length(self, input: str) -> int:
        """
        Get the length of text.
        
        Parameters:
        - input: Input text
        
        Returns:
        Number of characters in the text
        """
    
    @kernel_function(description="Concatenate two strings")
    def concat(self, input1: str, input2: str) -> str:
        """
        Concatenate two strings.
        
        Parameters:
        - input1: First string
        - input2: Second string
        
        Returns:
        Concatenated string
        """

Time Plugin

Date and time operations.

class TimePlugin:
    """
    Plugin for date and time operations.
    """
    
    @kernel_function(description="Get current date and time")
    def now(self) -> str:
        """
        Get current date and time.
        
        Returns:
        Current date and time as ISO string
        """
    
    @kernel_function(description="Get current UTC date and time")
    def utc_now(self) -> str:
        """
        Get current UTC date and time.
        
        Returns:
        Current UTC date and time as ISO string
        """
    
    @kernel_function(description="Get today's date")
    def today(self) -> str:
        """
        Get today's date.
        
        Returns:
        Today's date as string
        """
    
    @kernel_function(description="Get current time")
    def time(self) -> str:
        """
        Get current time.
        
        Returns:
        Current time as string
        """
    
    @kernel_function(description="Get current year")
    def year(self) -> int:
        """
        Get current year.
        
        Returns:
        Current year as integer
        """
    
    @kernel_function(description="Get current month")
    def month(self) -> int:
        """
        Get current month.
        
        Returns:
        Current month as integer (1-12)
        """
    
    @kernel_function(description="Get current day")
    def day(self) -> int:
        """
        Get current day of month.
        
        Returns:
        Current day as integer (1-31)
        """
    
    @kernel_function(description="Get day of week")
    def day_of_week(self) -> str:
        """
        Get current day of the week.
        
        Returns:
        Day of week as string (e.g., "Monday")
        """
    
    @kernel_function(description="Get current hour")
    def hour(self) -> int:
        """
        Get current hour.
        
        Returns:
        Current hour as integer (0-23)
        """
    
    @kernel_function(description="Get current minute")
    def minute(self) -> int:
        """
        Get current minute.
        
        Returns:
        Current minute as integer (0-59)
        """
    
    @kernel_function(description="Get current second")
    def second(self) -> int:
        """
        Get current second.
        
        Returns:
        Current second as integer (0-59)
        """

Web Search Engine Plugin

Web search capabilities for retrieving information from search engines.

class WebSearchEnginePlugin:
    """
    Plugin for web search functionality.
    """
    
    def __init__(self, search_engine: WebSearchEngineBase):
        """
        Initialize web search plugin.
        
        Parameters:
        - search_engine: Web search engine implementation
        """
    
    @kernel_function(description="Search the web for information")
    async def search(self, query: str, count: int = 1, offset: int = 0) -> str:
        """
        Search the web for information.
        
        Parameters:
        - query: Search query string
        - count: Number of results to return (default: 1)
        - offset: Number of results to skip (default: 0)
        
        Returns:
        Search results as formatted string
        """

Conversation Summary Plugin

Summarization capabilities for chat histories and conversations.

class ConversationSummaryPlugin:
    """
    Plugin for conversation summarization.
    """
    
    def __init__(self, kernel: Kernel):
        """
        Initialize conversation summary plugin.
        
        Parameters:
        - kernel: Kernel instance for AI operations
        """
    
    @kernel_function(description="Summarize a conversation")
    async def summarize_conversation(
        self,
        input: str,
        kernel: Kernel | None = None
    ) -> str:
        """
        Summarize a conversation or chat history.
        
        Parameters:
        - input: Conversation text to summarize
        - kernel: Kernel instance (uses plugin kernel if not provided)
        
        Returns:
        Summary of the conversation
        """
    
    @kernel_function(description="Get conversation action items")
    async def get_conversation_action_items(
        self,
        input: str,
        kernel: Kernel | None = None
    ) -> str:
        """
        Extract action items from a conversation.
        
        Parameters:
        - input: Conversation text to analyze
        - kernel: Kernel instance (uses plugin kernel if not provided)
        
        Returns:
        List of action items from the conversation
        """
    
    @kernel_function(description="Get conversation topics")
    async def get_conversation_topics(
        self,
        input: str,
        kernel: Kernel | None = None
    ) -> str:
        """
        Extract main topics from a conversation.
        
        Parameters:
        - input: Conversation text to analyze
        - kernel: Kernel instance (uses plugin kernel if not provided)
        
        Returns:
        List of main topics discussed
        """

Text Memory Plugin

Text-based memory operations for storing and retrieving information.

class TextMemoryPlugin:
    """
    Plugin for text memory operations.
    """
    
    def __init__(self, memory: SemanticTextMemory):
        """
        Initialize text memory plugin.
        
        Parameters:
        - memory: Semantic text memory instance
        """
    
    @kernel_function(description="Recall information from memory")
    async def recall(
        self,
        ask: str,
        collection: str = "generic",
        relevance: float = 0.0,
        limit: int = 1
    ) -> str:
        """
        Recall information from memory based on a query.
        
        Parameters:
        - ask: Question or query for memory search
        - collection: Memory collection to search in
        - relevance: Minimum relevance score (0.0 to 1.0)
        - limit: Maximum number of results to return
        
        Returns:
        Most relevant information from memory
        """
    
    @kernel_function(description="Save information to memory")
    async def save(
        self,
        text: str,
        key: str,
        collection: str = "generic"
    ) -> str:
        """
        Save information to memory.
        
        Parameters:
        - text: Information to save
        - key: Unique key for the information
        - collection: Memory collection to save to
        
        Returns:
        Confirmation message
        """

Sessions Python Tool

Python code execution environment for running Python code safely.

class SessionsPythonTool:
    """
    Plugin for executing Python code in isolated sessions.
    """
    
    def __init__(
        self,
        pool_management_endpoint: str | None = None,
        code_interpreter_user_identity: str | None = None
    ):
        """
        Initialize Sessions Python Tool.
        
        Parameters:
        - pool_management_endpoint: Endpoint for session pool management
        - code_interpreter_user_identity: User identity for code interpreter
        """
    
    @kernel_function(description="Execute Python code")
    async def execute_code(
        self,
        code: str,
        session_id: str | None = None
    ) -> str:
        """
        Execute Python code in an isolated session.
        
        Parameters:
        - code: Python code to execute
        - session_id: Optional session ID for persistence
        
        Returns:
        Execution result including output and any errors
        """
    
    @kernel_function(description="Create a new code session")
    async def create_session(self) -> str:
        """
        Create a new code execution session.
        
        Returns:
        Session ID for the new session
        """
    
    @kernel_function(description="List available sessions")
    async def list_sessions(self) -> str:
        """
        List all available code execution sessions.
        
        Returns:
        List of session IDs
        """
    
    @kernel_function(description="Delete a code session")
    async def delete_session(self, session_id: str) -> str:
        """
        Delete a code execution session.
        
        Parameters:
        - session_id: ID of the session to delete
        
        Returns:
        Confirmation message
        """

Usage Examples

Using Core Plugins

from semantic_kernel import Kernel
from semantic_kernel.core_plugins import HttpPlugin, MathPlugin, TextPlugin, TimePlugin

# Initialize kernel
kernel = Kernel()

# Add core plugins
kernel.add_plugin(HttpPlugin(), plugin_name="http")
kernel.add_plugin(MathPlugin(), plugin_name="math") 
kernel.add_plugin(TextPlugin(), plugin_name="text")
kernel.add_plugin(TimePlugin(), plugin_name="time")

# Use HTTP plugin
api_result = await kernel.invoke("http", "get", url="https://api.example.com/data")
print(f"API Response: {api_result.value}")

# Use math plugin
sum_result = await kernel.invoke("math", "add", value1=15, value2=25)
print(f"15 + 25 = {sum_result.value}")

# Use text plugin
upper_result = await kernel.invoke("text", "uppercase", input="hello world")
print(f"Uppercase: {upper_result.value}")

# Use time plugin
current_time = await kernel.invoke("time", "now")
print(f"Current time: {current_time.value}")

Memory and Summarization

from semantic_kernel.core_plugins import ConversationSummaryPlugin, TextMemoryPlugin
from semantic_kernel.memory import SemanticTextMemory

# Setup memory
memory = SemanticTextMemory(storage=vector_store, embeddings_generator=embedding_service)

# Add memory and summary plugins
kernel.add_plugin(TextMemoryPlugin(memory), plugin_name="memory")
kernel.add_plugin(ConversationSummaryPlugin(kernel), plugin_name="summary")

# Save information to memory
await kernel.invoke(
    "memory", 
    "save",
    text="Semantic Kernel supports multiple AI providers",
    key="sk_providers",
    collection="documentation"
)

# Recall information
result = await kernel.invoke(
    "memory",
    "recall", 
    ask="What AI providers does Semantic Kernel support?",
    collection="documentation"
)
print(f"Memory result: {result.value}")

# Summarize conversation
conversation = "User: Tell me about AI. Assistant: AI is artificial intelligence..."
summary = await kernel.invoke("summary", "summarize_conversation", input=conversation)
print(f"Summary: {summary.value}")

Python Code Execution

from semantic_kernel.core_plugins import SessionsPythonTool

# Add Python execution plugin
python_tool = SessionsPythonTool()
kernel.add_plugin(python_tool, plugin_name="python")

# Execute Python code
code = """
import math
result = math.sqrt(16) + math.pi
print(f"Result: {result}")
"""

execution_result = await kernel.invoke("python", "execute_code", code=code)
print(f"Python execution result: {execution_result.value}")

Install with Tessl CLI

npx tessl i tessl/pypi-semantic-kernel

docs

agents.md

ai-connectors.md

content-types.md

core-kernel.md

core-plugins.md

filters.md

index.md

memory-stores.md

processes.md

prompt-templates.md

tile.json