Skip to content
Merged
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
70 changes: 26 additions & 44 deletions modules/src/agent_deployer/agent_deployer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,8 @@
},
{
"cell_type": "code",
"execution_count": 21,
"id": "be42e7c5-b2af-476f-8041-c17be56edb52",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"> 2025-12-03 07:17:36,530 [info] Project loaded successfully: {\"project_name\":\"langchain-example-10\"}\n"
]
}
],
"source": [
"%config Completer.use_jedi = False\n",
"\n",
Expand All @@ -31,7 +21,9 @@
"image = \"mlrun/mlrun\"\n",
"project_name = \"langchain-example\"\n",
"project = get_or_create_project(project_name, context=\"./\", allow_cross_project=True)"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -43,17 +35,17 @@
},
{
"cell_type": "code",
"execution_count": 23,
"id": "a47d7789-2ea2-493e-8905-f53b978e2abd",
"metadata": {},
"outputs": [],
"source": [
"# Create project secrets for project\n",
"secrets = {\"OPENAI_API_KEY\": \"\", # add your OpenAI API key here\n",
" \"OPENAI_BASE_URL\": \"\" # add your OpenAI base url here if needed\n",
" }\n",
"project.set_secrets(secrets=secrets, provider=\"kubernetes\")"
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -65,10 +57,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"id": "25cbd982-86de-43b5-91ef-24fc60b2d758",
"metadata": {},
"outputs": [],
"source": [
"%%writefile langchain_model.py\n",
"\n",
Expand Down Expand Up @@ -197,7 +187,9 @@
" result[\"total_cost_usd\"] = input_cost + output_cost\n",
" return result\n",
" "
]
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -209,20 +201,8 @@
},
{
"cell_type": "code",
"execution_count": 81,
"id": "691e9068-ec9c-40d6-9ac8-e6c3e605b44c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"> 2025-12-03 10:55:46,194 [info] Project loaded successfully: {\"project_name\":\"langchain-example-10\"}\n",
"> 2025-12-03 10:55:46,463 [info] Model monitoring credentials were set successfully. Please keep in mind that if you already had model monitoring functions / model monitoring infra / tracked model server deployed on your project, you will need to redeploy them. For redeploying the model monitoring infra, first disable it using `project.disable_model_monitoring()` and then enable it using `project.enable_model_monitoring()`.\n",
"details: MLRunConflictError(\"The following model-montioring infrastructure functions are already deployed, aborting: ['model-monitoring-controller', 'model-monitoring-writer']\\nIf you want to redeploy the model-monitoring controller (maybe with different base-period), use update_model_monitoring_controller.If you want to redeploy all of model-monitoring infrastructure, call disable_model_monitoringbefore calling enable_model_monitoring again.\")\n"
]
}
],
"source": [
"module = mlrun.import_module(\"hub://agent_deployer\")\n",
"\n",
Expand All @@ -237,11 +217,11 @@
" prompt_template= \"\"\"\n",
" Answer the following questions as best you can.\n",
" You have access to the following tools:\n",
" {tools}\n",
" {{tools}}\n",
" Use the following format:\n",
" Question: the input question you must answer\n",
" Thought: you should always think about what to do\n",
" Action: the action to take, should be one of [{tool_names}]\n",
" Action: the action to take, should be one of [{{tool_names}}]\n",
" Action Input: the input to the action\n",
" Observation: the result of the action\n",
" ... (this Thought/Action/Action Input/Observation can repeat N times)\n",
Expand All @@ -252,16 +232,18 @@
" Question: {input}\n",
" Thought:{agent_scratchpad}\n",
" \"\"\",\n",
")"
]
")\n"
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"execution_count": 82,
"id": "0bb1c4d1-5d7c-4d1c-bf51-8f53b319e91f",
"metadata": {},
"source": "func = agent.deploy_function(enable_tracking=True)",
"outputs": [],
"source": "func = agent.deploy_function(enable_tracking=True)"
"execution_count": null
},
{
"metadata": {},
Expand All @@ -272,10 +254,10 @@
{
"metadata": {},
"cell_type": "code",
"source": "func.invoke(\"./\", {\"question\" : \"If a pizza costs $18.75 and I want to buy 3, what is the total cost?\"})",
"id": "ac5c3ba174d2cf8b",
"outputs": [],
"execution_count": null,
"source": "func.invoke(\"./\", {\"question\" : \"If a pizza costs $18.75 and I want to buy 3, plus a 15% tip, what is the total cost?\"})",
"id": "ac5c3ba174d2cf8b"
"execution_count": null
},
{
"metadata": {},
Expand All @@ -289,8 +271,6 @@
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"%%writefile monitoring_application.py\n",
"\n",
Expand Down Expand Up @@ -405,7 +385,9 @@
" value=value,\n",
" )\n"
],
"id": "377487422f5ed289"
"id": "377487422f5ed289",
"outputs": [],
"execution_count": null
},
{
"metadata": {},
Expand All @@ -416,8 +398,6 @@
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"llm_monitoring_app = project.set_model_monitoring_function(\n",
" func=\"monitoring_application.py\",\n",
Expand All @@ -428,7 +408,9 @@
"\n",
"project.deploy_function(llm_monitoring_app)"
],
"id": "9d6ad2a4a47a44bd"
"id": "9d6ad2a4a47a44bd",
"outputs": [],
"execution_count": null
}
],
"metadata": {
Expand Down