Skip to content

Commit 04d061f

Browse files
committed
Formatting for clients
1 parent 9e8e1cc commit 04d061f

File tree

6 files changed

+116
-26
lines changed

6 files changed

+116
-26
lines changed

examples/spanish/agentframework_basic.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,27 @@
1515
if API_HOST == "azure":
1616
async_credential = DefaultAzureCredential()
1717
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
18-
client = OpenAIChatClient(base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/", api_key=token_provider, model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"])
18+
client = OpenAIChatClient(
19+
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
20+
api_key=token_provider,
21+
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
22+
)
1923
elif API_HOST == "github":
20-
client = OpenAIChatClient(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"], model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"))
24+
client = OpenAIChatClient(
25+
base_url="https://models.github.ai/inference",
26+
api_key=os.environ["GITHUB_TOKEN"],
27+
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
28+
)
2129
elif API_HOST == "ollama":
22-
client = OpenAIChatClient(base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"), api_key="none", model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"))
30+
client = OpenAIChatClient(
31+
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
32+
api_key="none",
33+
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
34+
)
2335
else:
2436
client = OpenAIChatClient(api_key=os.environ["OPENAI_API_KEY"], model_id=os.environ.get("OPENAI_MODEL", "gpt-4o"))
2537

38+
2639
agent = ChatAgent(chat_client=client, instructions="Eres un agente informativo. Responde a las preguntas con alegría.")
2740

2841

examples/spanish/agentframework_magenticone.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,29 +28,45 @@
2828
if API_HOST == "azure":
2929
async_credential = DefaultAzureCredential()
3030
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
31-
client = OpenAIChatClient(base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/", api_key=token_provider, model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"])
31+
client = OpenAIChatClient(
32+
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
33+
api_key=token_provider,
34+
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
35+
)
3236
elif API_HOST == "github":
33-
client = OpenAIChatClient(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"], model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"))
37+
client = OpenAIChatClient(
38+
base_url="https://models.github.ai/inference",
39+
api_key=os.environ["GITHUB_TOKEN"],
40+
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
41+
)
3442
elif API_HOST == "ollama":
35-
client = OpenAIChatClient(base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"), api_key="none", model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"))
43+
client = OpenAIChatClient(
44+
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
45+
api_key="none",
46+
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
47+
)
3648
else:
3749
client = OpenAIChatClient(api_key=os.environ["OPENAI_API_KEY"], model_id=os.environ.get("OPENAI_MODEL", "gpt-4o"))
3850

51+
3952
# Initializar la consola rich
4053
console = Console()
4154

4255
# Crear los agentes
4356
agente_local = ChatAgent(
4457
chat_client=client,
45-
instructions=("Sos un asistente útil que puede sugerir actividades locales auténticas e interesantes " "o lugares para visitar para un usuario y puede utilizar cualquier información de contexto proporcionada."),
58+
instructions=(
59+
"Sos un asistente útil que puede sugerir actividades locales auténticas e interesantes "
60+
"o lugares para visitar para un usuario y puede utilizar cualquier información de contexto proporcionada."
61+
),
4662
name="agente_local",
4763
description="Un asistente local que puede sugerir actividades locales o lugares para visitar.",
4864
)
4965

5066
agente_idioma = ChatAgent(
5167
chat_client=client,
5268
instructions=(
53-
"Sos un asistente útil que puede revisar planes de viaje, brindando comentarios sobre consejos importantes/críticos "
69+
"Sos un asistente útil que puede revisar planes de viaje, brindando comentarios sobre consejos importantes"
5470
"sobre cómo abordar mejor los desafíos de idioma o comunicación para el destino dado. "
5571
"Si el plan ya incluye consejos de idioma, podés mencionar que el plan es satisfactorio, con justificación."
5672
),
@@ -62,7 +78,7 @@
6278
chat_client=client,
6379
instructions=(
6480
"Sos un asistente útil que puede tomar todas las sugerencias y consejos de los otros agentes "
65-
"y proporcionar un plan de viaje final detallado. Debes asegurarte de que el plan final esté integrado y completo. "
81+
"y proporcionar un plan de viaje final detallado. Debes asegurarte de que el plan esté integrado y completo."
6682
"TU RESPUESTA FINAL DEBE SER EL PLAN COMPLETO. Proporciona un resumen exhaustivo cuando todas las perspectivas "
6783
"de otros agentes se hayan integrado."
6884
),

examples/spanish/agentframework_supervisor.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,27 @@
2727
if API_HOST == "azure":
2828
async_credential = DefaultAzureCredential()
2929
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
30-
client = OpenAIChatClient(base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/", api_key=token_provider, model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"])
30+
client = OpenAIChatClient(
31+
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
32+
api_key=token_provider,
33+
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
34+
)
3135
elif API_HOST == "github":
32-
client = OpenAIChatClient(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"], model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"))
36+
client = OpenAIChatClient(
37+
base_url="https://models.github.ai/inference",
38+
api_key=os.environ["GITHUB_TOKEN"],
39+
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
40+
)
3341
elif API_HOST == "ollama":
34-
client = OpenAIChatClient(base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"), api_key="none", model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"))
42+
client = OpenAIChatClient(
43+
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
44+
api_key="none",
45+
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
46+
)
3547
else:
3648
client = OpenAIChatClient(api_key=os.environ["OPENAI_API_KEY"], model_id=os.environ.get("OPENAI_MODEL", "gpt-4o"))
3749

50+
3851
# ----------------------------------------------------------------------------------
3952
# Subagente 1 herramientas: planificación del fin de semana
4053
# ----------------------------------------------------------------------------------
@@ -74,7 +87,9 @@ def get_current_date() -> str:
7487
weekend_agent = ChatAgent(
7588
chat_client=client,
7689
instructions=(
77-
"Ayudas a las personas a planear su fin de semana y elegir las mejores actividades según el clima. " "Si una actividad sería desagradable con el clima previsto, no la sugieras. " "Incluye la fecha del fin de semana en tu respuesta."
90+
"Ayudas a las personas a planear su fin de semana y elegir las mejores actividades según el clima. "
91+
"Si una actividad sería desagradable con el clima previsto, no la sugieras. "
92+
"Incluye la fecha del fin de semana en tu respuesta."
7893
),
7994
tools=[get_weather, get_activities, get_current_date],
8095
)

examples/spanish/agentframework_tool.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,23 @@
2626
if API_HOST == "azure":
2727
async_credential = DefaultAzureCredential()
2828
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
29-
client = OpenAIChatClient(base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/", api_key=token_provider, model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"])
29+
client = OpenAIChatClient(
30+
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
31+
api_key=token_provider,
32+
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
33+
)
3034
elif API_HOST == "github":
31-
client = OpenAIChatClient(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"], model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"))
35+
client = OpenAIChatClient(
36+
base_url="https://models.github.ai/inference",
37+
api_key=os.environ["GITHUB_TOKEN"],
38+
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
39+
)
3240
elif API_HOST == "ollama":
33-
client = OpenAIChatClient(base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"), api_key="none", model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"))
41+
client = OpenAIChatClient(
42+
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
43+
api_key="none",
44+
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
45+
)
3446
else:
3547
client = OpenAIChatClient(api_key=os.environ["OPENAI_API_KEY"], model_id=os.environ.get("OPENAI_MODEL", "gpt-4o"))
3648

examples/spanish/agentframework_tools.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,23 @@
2727
if API_HOST == "azure":
2828
async_credential = DefaultAzureCredential()
2929
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
30-
client = OpenAIChatClient(base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/", api_key=token_provider, model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"])
30+
client = OpenAIChatClient(
31+
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
32+
api_key=token_provider,
33+
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
34+
)
3135
elif API_HOST == "github":
32-
client = OpenAIChatClient(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"], model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"))
36+
client = OpenAIChatClient(
37+
base_url="https://models.github.ai/inference",
38+
api_key=os.environ["GITHUB_TOKEN"],
39+
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
40+
)
3341
elif API_HOST == "ollama":
34-
client = OpenAIChatClient(base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"), api_key="none", model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"))
42+
client = OpenAIChatClient(
43+
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
44+
api_key="none",
45+
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
46+
)
3547
else:
3648
client = OpenAIChatClient(api_key=os.environ["OPENAI_API_KEY"], model_id=os.environ.get("OPENAI_MODEL", "gpt-4o"))
3749

@@ -75,7 +87,9 @@ def get_current_date() -> str:
7587
agent = ChatAgent(
7688
chat_client=client,
7789
instructions=(
78-
"Ayudas a las personas a planear su fin de semana y elegir las mejores actividades según el clima. " "Si una actividad sería desagradable con el clima previsto, no la sugieras. " "Incluye la fecha del fin de semana en tu respuesta."
90+
"Ayudas a las personas a planear su fin de semana y elegir las mejores actividades según el clima. "
91+
"Si una actividad sería desagradable con el clima previsto, no la sugieras. "
92+
"Incluye la fecha del fin de semana en tu respuesta."
7993
),
8094
tools=[get_weather, get_activities, get_current_date],
8195
)

examples/spanish/agentframework_workflow.py

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,23 @@
1515
if API_HOST == "azure":
1616
async_credential = DefaultAzureCredential()
1717
token_provider = get_bearer_token_provider(async_credential, "https://cognitiveservices.azure.com/.default")
18-
client = OpenAIChatClient(base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/", api_key=token_provider, model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"])
18+
client = OpenAIChatClient(
19+
base_url=f"{os.environ['AZURE_OPENAI_ENDPOINT']}/openai/v1/",
20+
api_key=token_provider,
21+
model_id=os.environ["AZURE_OPENAI_CHAT_DEPLOYMENT"],
22+
)
1923
elif API_HOST == "github":
20-
client = OpenAIChatClient(base_url="https://models.github.ai/inference", api_key=os.environ["GITHUB_TOKEN"], model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"))
24+
client = OpenAIChatClient(
25+
base_url="https://models.github.ai/inference",
26+
api_key=os.environ["GITHUB_TOKEN"],
27+
model_id=os.getenv("GITHUB_MODEL", "openai/gpt-4o"),
28+
)
2129
elif API_HOST == "ollama":
22-
client = OpenAIChatClient(base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"), api_key="none", model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"))
30+
client = OpenAIChatClient(
31+
base_url=os.environ.get("OLLAMA_ENDPOINT", "http://localhost:11434/v1"),
32+
api_key="none",
33+
model_id=os.environ.get("OLLAMA_MODEL", "llama3.1:latest"),
34+
)
2335
else:
2436
client = OpenAIChatClient(api_key=os.environ["OPENAI_API_KEY"], model_id=os.environ.get("OPENAI_MODEL", "gpt-4o"))
2537

@@ -63,7 +75,11 @@ def esta_aprobado(message: Any) -> bool:
6375
# Crear agente Escritor - genera contenido
6476
escritor = client.create_agent(
6577
name="Escritor",
66-
instructions=("Sos un excelente escritor de contenido. " "Creá contenido claro y atractivo basado en la solicitud del usuario. " "Enfocate en la claridad, precisión y estructura adecuada."),
78+
instructions=(
79+
"Sos un excelente escritor de contenido. "
80+
"Creá contenido claro y atractivo basado en la solicitud del usuario. "
81+
"Enfocate en la claridad, precisión y estructura adecuada."
82+
),
6783
)
6884

6985
# Crear agente Revisor - evalúa y proporciona retroalimentación estructurada
@@ -98,7 +114,11 @@ def esta_aprobado(message: Any) -> bool:
98114
# Crear agente Publicador - formatea el contenido para publicación
99115
publicador = client.create_agent(
100116
name="Publicador",
101-
instructions=("Sos un agente de publicación. " "Recibís contenido aprobado o editado. " "Formatealo para publicación con encabezados y estructura adecuados."),
117+
instructions=(
118+
"Sos un agente de publicación. "
119+
"Recibís contenido aprobado o editado. "
120+
"Formatealo para publicación con encabezados y estructura adecuados."
121+
),
102122
)
103123

104124
# Crear agente Resumidor - crea el informe final de publicación
@@ -122,7 +142,7 @@ def esta_aprobado(message: Any) -> bool:
122142
flujo_trabajo = (
123143
WorkflowBuilder(
124144
name="Flujo de Trabajo de Revisión de Contenido",
125-
description="Flujo de trabajo de creación de contenido multi-agente con enrutamiento basado en calidad (Escritor → Revisor → Editor/Publicador)",
145+
description="Creación de contenido con enrutamiento basado en calidad (Escritor → Revisor → Editor/Publicador)",
126146
)
127147
.set_start_executor(escritor)
128148
.add_edge(escritor, revisor)

0 commit comments

Comments
 (0)