Python: ModuleNotFoundError: No module named ‘semantic_kernel.skill’, Python, AzureOpenAI

While trying to run the code for creating basic agents in Python using Semantic Kernel, it is giving ModuleNotFoundError: No module named ‘semantic_kernel.skill’. Facing the same error for semantic_kernel.skill_definition as well.

Referred to 4777 but the hyperlink to the “Example” provided in that issue is giving 404 error.

Can you please help me. This is a blocker for me. As per my knowledge, there is no executable code for Agents using Semantic Kernel in Python. Please share the resources if you have any.

To Reproduce: Execute the below code:


import os
import semantic_kernel as sk
from semantic_kernel.connectors.ai.open_ai import AzureTextCompletion
from semantic_kernel.skill import Skill
from semantic_kernel.skill import sk_function
from azure.core.credentials import AzureKeyCredential
from azure.search.documents import SearchClient
from azure.search.documents.models import QueryType

# Initialize the Semantic Kernel
kernel = sk.Kernel()

# Register Azure OpenAI text completion service
azure_text_completion = AzureTextCompletion(
    endpoint=AZURE_OPENAI_ENDPOINT,
    api_key=AZURE_OPENAI_API_KEY,
    deployment_name=DEPLOYMENT_NAME
)
kernel.register_service("text-completion", azure_text_completion)

# Initialize Azure Cognitive Search client
search_client = SearchClient(
    endpoint=AZURE_SEARCH_ENDPOINT,
    index_name=AZURE_SEARCH_INDEX_NAME,
    credential=AzureKeyCredential(AZURE_SEARCH_API_KEY)
)

# Define a simple skill
class GreetingSkill(Skill):
    @sk_function
    def say_hello(self, name: str) -> str:
        return f"Hello, {name}!"

# Define a search skill
class SearchSkill(Skill):
    @sk_function
    def search_documents(self, query: str) -> str:
        results = search_client.search(search_text=query, query_type=QueryType.SIMPLE)
        response = [doc['content'] for doc in results]
        return 'n'.join(response)

# Register the skills with the kernel
greeting_skill = GreetingSkill()
search_skill = SearchSkill()

kernel.register_skill("GreetingSkill", greeting_skill)
kernel.register_skill("SearchSkill", search_skill)

# Define a function to interact with the AI agent
def interact_with_agent(kernel, skill_name, function_name, **kwargs):
    result = kernel.execute(skill_name, function_name, **kwargs)
    return result

# Example interaction with the AI agent
result = interact_with_agent(kernel, "GreetingSkill", "say_hello", name="Alice")
print(result)  # Output: Hello, Alice!

# Example search interaction with the AI agent
search_result = interact_with_agent(kernel, "SearchSkill", "search_documents", query="Azure Cognitive Services")
print(search_result)  # Output: Search results related to "Azure Cognitive Services"

OS: [e.g. Windows, Mac] – Windows
IDE: [e.g. Visual Studio, VS Code] – VS Code

I have raised a GitHub issue as well

I tried executing the above code and I’m expecting an error free code execution

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật