Skip to content

Commit 16412fc

Browse files
committed
Custom agent features - str and dropdown
1 parent 9346324 commit 16412fc

1 file changed

Lines changed: 35 additions & 2 deletions

File tree

  • 37-vanilla-agent-custom-features/vanilla_agent_custom_features

37-vanilla-agent-custom-features/vanilla_agent_custom_features/main.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,25 @@ def get_copilot_description():
5252
"default": True,
5353
"description": "Allows the copilot to search the web.",
5454
},
55+
"model": {
56+
"label": "Model",
57+
"type": "select",
58+
"default": "claude-sonnet-4-20250514",
59+
"description": "Select the LLM model to use.",
60+
"options": [
61+
{"label": "Claude Opus 4", "value": "claude-opus-4-0-20250514"},
62+
{"label": "Claude Sonnet 4", "value": "claude-sonnet-4-20250514"},
63+
{"label": "GPT-4o", "value": "gpt-4o"},
64+
{"label": "GPT-4o mini", "value": "gpt-4o-mini"},
65+
],
66+
},
67+
"agent-name": {
68+
"label": "Name of Agent",
69+
"type": "text",
70+
"default": "Example Agent",
71+
"description": "Set the name the agent uses to introduce itself.",
72+
"placeholder": "e.g. My Custom Agent",
73+
},
5574
},
5675
}
5776
}
@@ -64,23 +83,37 @@ async def query(request: QueryRequest) -> EventSourceResponse:
6483

6584
# Check workspace_options from request payload
6685
# workspace_options is a list like ["web-search"] or ["deep-research", "web-search"]
86+
# Text/select features are sent as "key=value" entries
6787
workspace_options = getattr(request, "workspace_options", [])
6888

89+
# Helper to extract a value from "key=value" entries
90+
def get_option_value(key: str, default: str = "") -> str:
91+
for opt in workspace_options:
92+
if opt.startswith(f"{key}="):
93+
return opt.split("=", 1)[1]
94+
return default
95+
6996
# Check which features are enabled
7097
deep_research_enabled = "deep-research" in workspace_options
7198
web_search_enabled = "web-search" in workspace_options
7299

100+
# Read text/select feature values
101+
model = get_option_value("model", "claude-sonnet-4-20250514")
102+
agent_name = get_option_value("agent-name", "Example Agent")
103+
73104
# Build the feature status message
74105
features_msg = (
75106
f"- Deep Research: {'✅ Enabled' if deep_research_enabled else '❌ Disabled'}\n"
76-
f"- Web Search: {'✅ Enabled' if web_search_enabled else '❌ Disabled'}"
107+
f"- Web Search: {'✅ Enabled' if web_search_enabled else '❌ Disabled'}\n"
108+
f"- Model: {model}\n"
109+
f"- Agent Name: {agent_name}"
77110
)
78111

79112
openai_messages: list[ChatCompletionMessageParam] = [
80113
ChatCompletionSystemMessageParam(
81114
role="system",
82115
content=(
83-
"You are a simple greeting agent.\n"
116+
f'Your name is "{agent_name}".\n'
84117
"Greet the user and let them know their current feature settings:\n"
85118
f"{features_msg}\n"
86119
"Keep your response brief and friendly."

0 commit comments

Comments
 (0)