Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
from azure.ai.agents.telemetry import trace_function


# Add parent directory to sys.path to import user_functions
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.abspath(os.path.join(current_dir, "..", "..", ".."))
if parent_dir not in sys.path:
sys.path.insert(0, parent_dir)
from samples.utils.user_functions import fetch_current_datetime, fetch_weather, send_email
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import fetch_weather, send_email


async def send_email_async(recipient: str, subject: str, body: str) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
)
from azure.identity import DefaultAzureCredential

current_path = os.path.dirname(__file__)
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
if root_path not in sys.path:
sys.path.insert(0, root_path)
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import user_functions

project_client = AIProjectClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@
import os, sys
from typing import Any

current_path = os.path.dirname(__file__)
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
if root_path not in sys.path:
sys.path.insert(0, root_path)
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import user_functions

project_client = AIProjectClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@
)
from azure.identity import DefaultAzureCredential

current_path = os.path.dirname(__file__)
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
if root_path not in sys.path:
sys.path.insert(0, root_path)
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import user_functions

project_client = AIProjectClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
from azure.ai.agents.models import FunctionTool, ToolSet
from azure.identity import DefaultAzureCredential

current_path = os.path.dirname(__file__)
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
if root_path not in sys.path:
sys.path.insert(0, root_path)
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import user_functions

project_client = AIProjectClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
from azure.ai.projects import AIProjectClient
from azure.identity import DefaultAzureCredential
from azure.ai.agents.models import FunctionTool

# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import user_functions

project_client = AIProjectClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@
ToolOutput,
)

current_path = os.path.dirname(__file__)
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
if root_path not in sys.path:
sys.path.insert(0, root_path)
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import user_functions

project_client = AIProjectClient(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
from azure.ai.agents.models import ToolSet, FunctionTool
from azure.identity import DefaultAzureCredential

# Example user function
current_path = os.path.dirname(__file__)
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
if root_path not in sys.path:
sys.path.insert(0, root_path)
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import fetch_current_datetime

# Import AzureLogicAppTool and the function factory from user_logic_apps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@
from azure.identity import DefaultAzureCredential
from azure.ai.agents.models import FunctionTool, ToolSet, CodeInterpreterTool

current_path = os.path.dirname(__file__)
root_path = os.path.abspath(os.path.join(current_path, os.pardir, os.pardir))
if root_path not in sys.path:
sys.path.insert(0, root_path)
# Add package directory to sys.path to import user_functions
current_dir = os.path.dirname(os.path.abspath(__file__))
package_dir = os.path.abspath(os.path.join(current_dir, os.pardir, os.pardir))
if package_dir not in sys.path:
sys.path.insert(0, package_dir)
from samples.utils.user_functions import user_functions

project_client = AIProjectClient(
Expand Down