Skip to content

Commit e17f349

Browse files
committed
Add routing sample
1 parent 3e37afb commit e17f349

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

samples-v2/openai_agents/function_app.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,38 @@ def search_agent(context):
188188
return result.final_output
189189

190190

191+
def french_agent() -> Agent:
192+
return Agent(
193+
name="french_agent",
194+
instructions="You only speak French",
195+
)
196+
197+
def spanish_agent() -> Agent:
198+
return Agent(
199+
name="spanish_agent",
200+
instructions="You only speak Spanish",
201+
)
202+
203+
def english_agent() -> Agent:
204+
return Agent(
205+
name="english_agent",
206+
instructions="You only speak English",
207+
)
208+
209+
def triage_agent() -> Agent:
210+
return Agent(
211+
name="triage_agent",
212+
instructions="Handoff to the appropriate agent based on the language of the request.",
213+
handoffs=[french_agent(), spanish_agent(), english_agent()],
214+
)
215+
216+
@app.orchestration_trigger(context_name="context")
217+
@durable_openai_agent_orchestrator
218+
def routing(context):
219+
result = Runner.run_sync(triage_agent(), input="Hello, how are you?")
220+
return result.final_output
221+
222+
191223
#region Implementation details
192224

193225
create_invoke_model_activity(app) # TODO: Can we hide this line?

0 commit comments

Comments
 (0)