Skip to content

Commit d2bf9c9

Browse files
committed
fix: replace repeated hard-coded string with constant
Signed-off-by: Mark Sturdevant <mark.sturdevant@ibm.com>
1 parent 5f56396 commit d2bf9c9

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

docs/examples/m_serve/m_serve_example_tool_calling.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import mellea
1313
from cli.serve.models import ChatMessage
14+
from mellea.backends import ModelOption
1415
from mellea.core import ModelOutputThunk, Requirement
1516
from mellea.core.base import AbstractMelleaTool
1617
from mellea.stdlib.context import ChatContext
@@ -140,9 +141,9 @@ def serve(
140141

141142
# Extract tools from model_options if provided
142143
tools = None
143-
if model_options and "@@@tools@@@" in model_options:
144+
if model_options and ModelOption.TOOLS in model_options:
144145
# Convert OpenAI tool format to Mellea tool format
145-
openai_tools = model_options["@@@tools@@@"]
146+
openai_tools = model_options[ModelOption.TOOLS]
146147
tools = {}
147148
for tool_def in openai_tools:
148149
tool_name = tool_def["function"]["name"]
@@ -152,7 +153,7 @@ def serve(
152153
# Build model options with tools
153154
final_model_options = model_options or {}
154155
if tools:
155-
final_model_options["@@@tools@@@"] = tools
156+
final_model_options[ModelOption.TOOLS] = tools
156157

157158
# Use instruct to generate response with potential tool calls
158159
result = session.instruct(
@@ -170,7 +171,7 @@ def serve(
170171

171172
# Simulate tool definitions being passed
172173
test_model_options = {
173-
"@@@tools@@@": [weather_tool.as_json_tool, stock_price_tool.as_json_tool]
174+
ModelOption.TOOLS: [weather_tool.as_json_tool, stock_price_tool.as_json_tool]
174175
}
175176

176177
response = serve(input=test_messages, model_options=test_model_options)

0 commit comments

Comments
 (0)