atendentepro 0.5.5__py3-none-any.whl → 0.5.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
atendentepro/__init__.py CHANGED
@@ -144,6 +144,14 @@ from atendentepro.utils import (
144
144
  get_async_client,
145
145
  get_provider,
146
146
  configure_tracing,
147
+ # MonkAI Trace
148
+ configure_monkai_trace,
149
+ get_monkai_hooks,
150
+ set_monkai_user,
151
+ set_monkai_input,
152
+ run_with_monkai_tracking,
153
+ # Application Insights
154
+ configure_application_insights,
147
155
  )
148
156
 
149
157
  __all__ = [
@@ -225,5 +233,13 @@ __all__ = [
225
233
  "get_async_client",
226
234
  "get_provider",
227
235
  "configure_tracing",
236
+ # MonkAI Trace
237
+ "configure_monkai_trace",
238
+ "get_monkai_hooks",
239
+ "set_monkai_user",
240
+ "set_monkai_input",
241
+ "run_with_monkai_tracking",
242
+ # Application Insights
243
+ "configure_application_insights",
228
244
  ]
229
245
 
atendentepro/network.py CHANGED
@@ -102,9 +102,17 @@ class AgentNetwork:
102
102
  def create_standard_network(
103
103
  templates_root: Path,
104
104
  client: str = "standard",
105
+ # Agents to include
106
+ include_flow: bool = True,
107
+ include_interview: bool = True,
108
+ include_answer: bool = True,
109
+ include_knowledge: bool = True,
110
+ include_confirmation: bool = True,
111
+ include_usage: bool = True,
105
112
  include_onboarding: bool = False,
106
113
  include_escalation: bool = True,
107
114
  include_feedback: bool = True,
115
+ # Agent-specific configurations
108
116
  escalation_channels: str = "",
109
117
  feedback_protocol_prefix: str = "TKT",
110
118
  feedback_brand_color: str = "#4A90D9",
@@ -114,7 +122,10 @@ def create_standard_network(
114
122
  """
115
123
  Create a standard agent network with proper handoff configuration.
116
124
 
117
- This creates the default network configuration with:
125
+ This creates a configurable network where you can enable/disable specific agents.
126
+ The Triage agent is always included as it's the entry point.
127
+
128
+ Default handoff configuration (when all agents are enabled):
118
129
  - Triage -> Flow, Confirmation, Knowledge, Usage, Escalation, Feedback
119
130
  - Flow -> Interview, Triage, Escalation, Feedback
120
131
  - Interview -> Answer, Escalation, Feedback
@@ -122,13 +133,19 @@ def create_standard_network(
122
133
  - Confirmation -> Triage, Escalation, Feedback
123
134
  - Knowledge -> Triage, Escalation, Feedback
124
135
  - Usage -> Triage, Escalation, Feedback
125
- - Escalation -> Triage
136
+ - Escalation -> Triage, Feedback
126
137
  - Feedback -> Triage, Escalation
127
138
 
128
139
  Args:
129
140
  templates_root: Root directory for template configurations.
130
141
  client: Client key to load configurations for.
131
- include_onboarding: Whether to include the onboarding agent.
142
+ include_flow: Whether to include the flow agent (default True).
143
+ include_interview: Whether to include the interview agent (default True).
144
+ include_answer: Whether to include the answer agent (default True).
145
+ include_knowledge: Whether to include the knowledge agent (default True).
146
+ include_confirmation: Whether to include the confirmation agent (default True).
147
+ include_usage: Whether to include the usage agent (default True).
148
+ include_onboarding: Whether to include the onboarding agent (default False).
132
149
  include_escalation: Whether to include the escalation agent (default True).
133
150
  include_feedback: Whether to include the feedback agent (default True).
134
151
  escalation_channels: Description of available escalation channels.
@@ -142,6 +159,25 @@ def create_standard_network(
142
159
 
143
160
  Raises:
144
161
  LicenseNotActivatedError: If the library is not activated.
162
+
163
+ Example:
164
+ # Create network without Knowledge agent
165
+ network = create_standard_network(
166
+ templates_root=Path("templates"),
167
+ client="my_client",
168
+ include_knowledge=False,
169
+ )
170
+
171
+ # Create minimal network (only Triage, Flow, Interview, Answer)
172
+ network = create_standard_network(
173
+ templates_root=Path("templates"),
174
+ client="my_client",
175
+ include_knowledge=False,
176
+ include_confirmation=False,
177
+ include_usage=False,
178
+ include_escalation=False,
179
+ include_feedback=False,
180
+ )
145
181
  """
146
182
  # Verificar licença
147
183
  require_activation()
@@ -210,50 +246,64 @@ def create_standard_network(
210
246
  tools = custom_tools or {}
211
247
 
212
248
  # Create agents without handoffs first
249
+ # Triage is always created (entry point)
213
250
  triage = create_triage_agent(
214
251
  keywords_text=triage_keywords,
215
252
  guardrails=get_guardrails_for_agent("Triage Agent", templates_root),
216
253
  )
217
254
 
218
- flow = create_flow_agent(
219
- flow_template=flow_template,
220
- flow_keywords=flow_keywords,
221
- guardrails=get_guardrails_for_agent("Flow Agent", templates_root),
222
- )
255
+ # Create optional agents based on include flags
256
+ flow = None
257
+ if include_flow:
258
+ flow = create_flow_agent(
259
+ flow_template=flow_template,
260
+ flow_keywords=flow_keywords,
261
+ guardrails=get_guardrails_for_agent("Flow Agent", templates_root),
262
+ )
223
263
 
224
- interview = create_interview_agent(
225
- interview_template=flow_template,
226
- interview_questions=interview_questions,
227
- tools=tools.get("interview", []),
228
- guardrails=get_guardrails_for_agent("Interview Agent", templates_root),
229
- )
264
+ interview = None
265
+ if include_interview:
266
+ interview = create_interview_agent(
267
+ interview_template=flow_template,
268
+ interview_questions=interview_questions,
269
+ tools=tools.get("interview", []),
270
+ guardrails=get_guardrails_for_agent("Interview Agent", templates_root),
271
+ )
230
272
 
231
- answer = create_answer_agent(
232
- answer_template="",
233
- guardrails=get_guardrails_for_agent("Answer Agent", templates_root),
234
- )
273
+ answer = None
274
+ if include_answer:
275
+ answer = create_answer_agent(
276
+ answer_template="",
277
+ guardrails=get_guardrails_for_agent("Answer Agent", templates_root),
278
+ )
235
279
 
236
- knowledge = create_knowledge_agent(
237
- knowledge_about=knowledge_about,
238
- knowledge_template=knowledge_template,
239
- knowledge_format=knowledge_format,
240
- embeddings_path=embeddings_path,
241
- data_sources_description=data_sources_description,
242
- include_rag_tool=has_embeddings,
243
- tools=tools.get("knowledge", []),
244
- guardrails=get_guardrails_for_agent("Knowledge Agent", templates_root),
245
- )
280
+ knowledge = None
281
+ if include_knowledge:
282
+ knowledge = create_knowledge_agent(
283
+ knowledge_about=knowledge_about,
284
+ knowledge_template=knowledge_template,
285
+ knowledge_format=knowledge_format,
286
+ embeddings_path=embeddings_path,
287
+ data_sources_description=data_sources_description,
288
+ include_rag_tool=has_embeddings,
289
+ tools=tools.get("knowledge", []),
290
+ guardrails=get_guardrails_for_agent("Knowledge Agent", templates_root),
291
+ )
246
292
 
247
- confirmation = create_confirmation_agent(
248
- confirmation_about=confirmation_about,
249
- confirmation_template=confirmation_template,
250
- confirmation_format=confirmation_format,
251
- guardrails=get_guardrails_for_agent("Confirmation Agent", templates_root),
252
- )
293
+ confirmation = None
294
+ if include_confirmation:
295
+ confirmation = create_confirmation_agent(
296
+ confirmation_about=confirmation_about,
297
+ confirmation_template=confirmation_template,
298
+ confirmation_format=confirmation_format,
299
+ guardrails=get_guardrails_for_agent("Confirmation Agent", templates_root),
300
+ )
253
301
 
254
- usage = create_usage_agent(
255
- guardrails=get_guardrails_for_agent("Usage Agent", templates_root),
256
- )
302
+ usage = None
303
+ if include_usage:
304
+ usage = create_usage_agent(
305
+ guardrails=get_guardrails_for_agent("Usage Agent", templates_root),
306
+ )
257
307
 
258
308
  # Create escalation agent if requested
259
309
  escalation = None
@@ -275,48 +325,74 @@ def create_standard_network(
275
325
  guardrails=get_guardrails_for_agent("Feedback Agent", templates_root),
276
326
  )
277
327
 
278
- # Configure handoffs
279
- triage_handoffs = [flow, confirmation, knowledge, usage]
280
- flow_handoffs = [interview, triage]
281
- confirmation_handoffs = [triage]
282
- knowledge_handoffs = [triage]
283
- usage_handoffs = [triage]
284
- interview_handoffs = [answer]
285
- answer_handoffs = [triage] # Answer só volta para Triage (não faz sentido voltar para Interview)
286
- escalation_handoffs = [triage]
287
- feedback_handoffs = [triage]
328
+ # Configure handoffs dynamically based on which agents are included
329
+ # Helper function to filter None values
330
+ def filter_agents(*agents):
331
+ return [a for a in agents if a is not None]
332
+
333
+ # Build triage handoffs (main routing)
334
+ triage_handoffs = filter_agents(flow, confirmation, knowledge, usage)
335
+
336
+ # Other agent handoffs
337
+ flow_handoffs = filter_agents(interview, triage) if flow else []
338
+ confirmation_handoffs = [triage] if confirmation else []
339
+ knowledge_handoffs = [triage] if knowledge else []
340
+ usage_handoffs = [triage] if usage else []
341
+ interview_handoffs = filter_agents(answer) if interview else []
342
+ answer_handoffs = [triage] if answer else []
343
+ escalation_handoffs = [triage] if escalation else []
344
+ feedback_handoffs = [triage] if feedback else []
288
345
 
289
346
  # Add escalation to all agents if enabled
290
347
  if escalation:
291
348
  triage_handoffs.append(escalation)
292
- flow_handoffs.append(escalation)
293
- confirmation_handoffs.append(escalation)
294
- knowledge_handoffs.append(escalation)
295
- usage_handoffs.append(escalation)
296
- interview_handoffs.append(escalation)
297
- answer_handoffs.append(escalation)
349
+ if flow:
350
+ flow_handoffs.append(escalation)
351
+ if confirmation:
352
+ confirmation_handoffs.append(escalation)
353
+ if knowledge:
354
+ knowledge_handoffs.append(escalation)
355
+ if usage:
356
+ usage_handoffs.append(escalation)
357
+ if interview:
358
+ interview_handoffs.append(escalation)
359
+ if answer:
360
+ answer_handoffs.append(escalation)
298
361
  if feedback:
299
362
  feedback_handoffs.append(escalation)
300
363
 
301
364
  # Add feedback to all agents if enabled
302
365
  if feedback:
303
366
  triage_handoffs.append(feedback)
304
- flow_handoffs.append(feedback)
305
- confirmation_handoffs.append(feedback)
306
- knowledge_handoffs.append(feedback)
307
- usage_handoffs.append(feedback)
308
- interview_handoffs.append(feedback)
309
- answer_handoffs.append(feedback)
367
+ if flow:
368
+ flow_handoffs.append(feedback)
369
+ if confirmation:
370
+ confirmation_handoffs.append(feedback)
371
+ if knowledge:
372
+ knowledge_handoffs.append(feedback)
373
+ if usage:
374
+ usage_handoffs.append(feedback)
375
+ if interview:
376
+ interview_handoffs.append(feedback)
377
+ if answer:
378
+ answer_handoffs.append(feedback)
310
379
  if escalation:
311
380
  escalation_handoffs.append(feedback)
312
381
 
382
+ # Apply handoffs to agents
313
383
  triage.handoffs = triage_handoffs
314
- flow.handoffs = flow_handoffs
315
- confirmation.handoffs = confirmation_handoffs
316
- knowledge.handoffs = knowledge_handoffs
317
- usage.handoffs = usage_handoffs
318
- interview.handoffs = interview_handoffs
319
- answer.handoffs = answer_handoffs
384
+ if flow:
385
+ flow.handoffs = flow_handoffs
386
+ if confirmation:
387
+ confirmation.handoffs = confirmation_handoffs
388
+ if knowledge:
389
+ knowledge.handoffs = knowledge_handoffs
390
+ if usage:
391
+ usage.handoffs = usage_handoffs
392
+ if interview:
393
+ interview.handoffs = interview_handoffs
394
+ if answer:
395
+ answer.handoffs = answer_handoffs
320
396
  if escalation:
321
397
  escalation.handoffs = escalation_handoffs
322
398
  if feedback:
@@ -7,13 +7,34 @@ from .openai_client import (
7
7
  AsyncClient,
8
8
  Provider,
9
9
  )
10
- from .tracing import configure_tracing
10
+ from .tracing import (
11
+ # MonkAI Trace (recommended)
12
+ configure_monkai_trace,
13
+ get_monkai_hooks,
14
+ set_monkai_user,
15
+ set_monkai_input,
16
+ run_with_monkai_tracking,
17
+ # Application Insights (Azure)
18
+ configure_application_insights,
19
+ # Legacy
20
+ configure_tracing,
21
+ )
11
22
 
12
23
  __all__ = [
24
+ # OpenAI Client
13
25
  "get_async_client",
14
26
  "get_provider",
15
27
  "AsyncClient",
16
28
  "Provider",
29
+ # MonkAI Trace
30
+ "configure_monkai_trace",
31
+ "get_monkai_hooks",
32
+ "set_monkai_user",
33
+ "set_monkai_input",
34
+ "run_with_monkai_tracking",
35
+ # Application Insights
36
+ "configure_application_insights",
37
+ # Legacy
17
38
  "configure_tracing",
18
39
  ]
19
40
 
@@ -2,20 +2,200 @@
2
2
  """
3
3
  Tracing configuration for AtendentePro.
4
4
 
5
- Provides optional Application Insights integration for telemetry.
5
+ Provides optional tracing integrations:
6
+ - MonkAI Trace (recommended): Full agent tracking with token segmentation
7
+ - Application Insights: Azure telemetry
8
+
9
+ MonkAI Trace: https://github.com/BeMonkAI/monkai-trace
6
10
  """
7
11
 
8
12
  from __future__ import annotations
9
13
 
10
14
  import logging
11
- from typing import Optional
15
+ import os
16
+ from typing import Optional, Any, TYPE_CHECKING
12
17
 
13
18
  from atendentepro.config import get_config
14
19
 
20
+ if TYPE_CHECKING:
21
+ from agents import Agent
22
+
15
23
  logger = logging.getLogger(__name__)
16
24
 
17
25
 
18
- def configure_tracing(connection_string: Optional[str] = None) -> bool:
26
+ # =============================================================================
27
+ # MONKAI TRACE INTEGRATION
28
+ # =============================================================================
29
+
30
+ _MONKAI_HOOKS: Optional[Any] = None
31
+
32
+
33
+ def configure_monkai_trace(
34
+ tracer_token: Optional[str] = None,
35
+ namespace: Optional[str] = None,
36
+ inactivity_timeout: int = 120,
37
+ batch_size: int = 1,
38
+ ) -> bool:
39
+ """
40
+ Configure MonkAI Trace for agent tracking.
41
+
42
+ MonkAI Trace provides comprehensive agent monitoring with:
43
+ - Automatic session management
44
+ - Token segmentation (input, output, process, memory)
45
+ - Multi-agent handoff tracking
46
+ - Web search and tool tracking
47
+
48
+ Args:
49
+ tracer_token: MonkAI tracer token (or env MONKAI_TRACER_TOKEN)
50
+ namespace: Namespace for grouping traces (default: "atendentepro")
51
+ inactivity_timeout: Session timeout in seconds (default: 120)
52
+ batch_size: Upload batch size, 1 for real-time (default: 1)
53
+
54
+ Returns:
55
+ True if MonkAI Trace was configured, False otherwise.
56
+
57
+ Example:
58
+ >>> from atendentepro.utils import configure_monkai_trace
59
+ >>> configure_monkai_trace(tracer_token="tk_your_token")
60
+ True
61
+
62
+ >>> # Or via environment variable
63
+ >>> # export MONKAI_TRACER_TOKEN="tk_your_token"
64
+ >>> configure_monkai_trace()
65
+ True
66
+ """
67
+ global _MONKAI_HOOKS
68
+
69
+ # Get token from parameter or environment
70
+ token = tracer_token or os.environ.get("MONKAI_TRACER_TOKEN")
71
+
72
+ if not token:
73
+ logger.debug("No MonkAI tracer token provided. MonkAI Trace disabled.")
74
+ return False
75
+
76
+ try:
77
+ from monkai_trace.integrations.openai_agents import MonkAIRunHooks
78
+
79
+ _MONKAI_HOOKS = MonkAIRunHooks(
80
+ tracer_token=token,
81
+ namespace=namespace or "atendentepro",
82
+ inactivity_timeout=inactivity_timeout,
83
+ batch_size=batch_size,
84
+ )
85
+
86
+ logger.info(f"MonkAI Trace configured successfully (namespace: {namespace or 'atendentepro'})")
87
+ return True
88
+
89
+ except ImportError:
90
+ logger.warning(
91
+ "MonkAI Trace not available. "
92
+ "Install 'monkai-trace' for agent tracking: pip install monkai-trace"
93
+ )
94
+ return False
95
+ except Exception as e:
96
+ logger.error(f"Failed to configure MonkAI Trace: {e}")
97
+ return False
98
+
99
+
100
+ def get_monkai_hooks() -> Optional[Any]:
101
+ """
102
+ Get the configured MonkAI Run Hooks.
103
+
104
+ Returns:
105
+ MonkAIRunHooks instance if configured, None otherwise.
106
+
107
+ Example:
108
+ >>> hooks = get_monkai_hooks()
109
+ >>> if hooks:
110
+ ... result = await Runner.run(agent, messages, hooks=hooks)
111
+ """
112
+ return _MONKAI_HOOKS
113
+
114
+
115
+ def set_monkai_user(user_id: str) -> None:
116
+ """
117
+ Set the user ID for MonkAI session tracking.
118
+
119
+ Useful for multi-user scenarios like WhatsApp bots.
120
+
121
+ Args:
122
+ user_id: Unique user identifier (phone, email, etc.)
123
+
124
+ Example:
125
+ >>> set_monkai_user("5511999999999") # WhatsApp
126
+ >>> set_monkai_user("user@email.com") # Email
127
+ """
128
+ if _MONKAI_HOOKS:
129
+ _MONKAI_HOOKS.set_user_id(user_id)
130
+
131
+
132
+ def set_monkai_input(user_input: str) -> None:
133
+ """
134
+ Set the user input for MonkAI tracking.
135
+
136
+ Call this before running the agent to capture the user message.
137
+
138
+ Args:
139
+ user_input: The user's message/query
140
+
141
+ Example:
142
+ >>> set_monkai_input("Como faço para cancelar minha assinatura?")
143
+ >>> result = await Runner.run(agent, messages, hooks=get_monkai_hooks())
144
+ """
145
+ if _MONKAI_HOOKS:
146
+ _MONKAI_HOOKS.set_user_input(user_input)
147
+
148
+
149
+ async def run_with_monkai_tracking(
150
+ agent: "Agent",
151
+ user_input: str,
152
+ user_id: Optional[str] = None,
153
+ ) -> Any:
154
+ """
155
+ Run an agent with MonkAI tracking enabled.
156
+
157
+ This is the recommended way to run agents with full tracking.
158
+ Captures internal tools (web_search, file_search) automatically.
159
+
160
+ Args:
161
+ agent: The agent to run
162
+ user_input: User's message/query
163
+ user_id: Optional user identifier for session management
164
+
165
+ Returns:
166
+ RunResult from the agent execution
167
+
168
+ Example:
169
+ >>> from atendentepro.utils import configure_monkai_trace, run_with_monkai_tracking
170
+ >>> configure_monkai_trace(tracer_token="tk_your_token")
171
+ >>> result = await run_with_monkai_tracking(network.triage, "Olá!")
172
+ """
173
+ if not _MONKAI_HOOKS:
174
+ # Fallback to normal execution without tracking
175
+ from agents import Runner
176
+ return await Runner.run(agent, user_input)
177
+
178
+ try:
179
+ from monkai_trace.integrations.openai_agents import MonkAIRunHooks
180
+
181
+ if user_id:
182
+ _MONKAI_HOOKS.set_user_id(user_id)
183
+
184
+ # Use run_with_tracking for full internal tools capture
185
+ return await MonkAIRunHooks.run_with_tracking(agent, user_input, _MONKAI_HOOKS)
186
+
187
+ except Exception as e:
188
+ logger.error(f"Error running with MonkAI tracking: {e}")
189
+ # Fallback to normal execution
190
+ from agents import Runner
191
+ return await Runner.run(agent, user_input)
192
+
193
+
194
+ # =============================================================================
195
+ # APPLICATION INSIGHTS INTEGRATION (Azure)
196
+ # =============================================================================
197
+
198
+ def configure_application_insights(connection_string: Optional[str] = None) -> bool:
19
199
  """
20
200
  Configure Application Insights tracing if connection string is available.
21
201
 
@@ -69,3 +249,15 @@ def configure_tracing(connection_string: Optional[str] = None) -> bool:
69
249
  logger.error(f"Failed to configure tracing: {e}")
70
250
  return False
71
251
 
252
+
253
+ # =============================================================================
254
+ # LEGACY ALIAS
255
+ # =============================================================================
256
+
257
+ def configure_tracing(connection_string: Optional[str] = None) -> bool:
258
+ """
259
+ Legacy alias for configure_application_insights.
260
+
261
+ Deprecated: Use configure_monkai_trace() or configure_application_insights().
262
+ """
263
+ return configure_application_insights(connection_string)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atendentepro
3
- Version: 0.5.5
3
+ Version: 0.5.7
4
4
  Summary: Sistema de Atendimento Inteligente com Múltiplos Agentes IA - Biblioteca independente e modular baseada no OpenAI Agents SDK
5
5
  Author-email: BeMonkAI <contato@monkai.com.br>
6
6
  Maintainer-email: BeMonkAI <contato@monkai.com.br>
@@ -79,6 +79,7 @@ Uma biblioteca Python modular para criar sistemas de atendimento automatizado us
79
79
  - [Escalation Agent](#-escalation-agent)
80
80
  - [Feedback Agent](#-feedback-agent)
81
81
  - [Fluxo de Handoffs](#-fluxo-de-handoffs)
82
+ - [Tracing e Monitoramento](#-tracing-e-monitoramento)
82
83
  - [Suporte](#-suporte)
83
84
 
84
85
  ---
@@ -525,26 +526,61 @@ Escalation► Triage, Feedback
525
526
  Feedback ► Triage, Escalation
526
527
  ```
527
528
 
528
- ### Configuração de Handoffs
529
+ ### Configuração de Agentes
530
+
531
+ Você pode escolher exatamente quais agentes incluir na sua rede:
529
532
 
530
533
  ```python
531
- # Todos os handoffs habilitados (padrão)
534
+ from pathlib import Path
535
+ from atendentepro import create_standard_network
536
+
537
+ # Todos os agentes habilitados (padrão)
532
538
  network = create_standard_network(
533
539
  templates_root=Path("./meu_cliente"),
534
540
  client="config",
535
- include_escalation=True, # Padrão: True
536
- include_feedback=True, # Padrão: True
537
541
  )
538
542
 
539
- # Sem Escalation ou Feedback
543
+ # Sem Knowledge Agent (para clientes sem base de conhecimento)
540
544
  network = create_standard_network(
541
545
  templates_root=Path("./meu_cliente"),
542
546
  client="config",
547
+ include_knowledge=False,
548
+ )
549
+
550
+ # Rede mínima (apenas fluxo principal)
551
+ network = create_standard_network(
552
+ templates_root=Path("./meu_cliente"),
553
+ client="config",
554
+ include_knowledge=False,
555
+ include_confirmation=False,
556
+ include_usage=False,
543
557
  include_escalation=False,
544
558
  include_feedback=False,
545
559
  )
560
+
561
+ # Apenas captura de leads (sem Knowledge nem Usage)
562
+ network = create_standard_network(
563
+ templates_root=Path("./meu_cliente"),
564
+ client="config",
565
+ include_knowledge=False,
566
+ include_usage=False,
567
+ )
546
568
  ```
547
569
 
570
+ ### Parâmetros Disponíveis
571
+
572
+ | Parâmetro | Padrão | Descrição |
573
+ |-----------|--------|-----------|
574
+ | `include_flow` | `True` | Agente de fluxo conversacional |
575
+ | `include_interview` | `True` | Agente de entrevista/coleta |
576
+ | `include_answer` | `True` | Agente de resposta final |
577
+ | `include_knowledge` | `True` | Agente de base de conhecimento |
578
+ | `include_confirmation` | `True` | Agente de confirmação |
579
+ | `include_usage` | `True` | Agente de instruções de uso |
580
+ | `include_onboarding` | `False` | Agente de boas-vindas |
581
+ | `include_escalation` | `True` | Agente de escalonamento humano |
582
+ | `include_feedback` | `True` | Agente de tickets/feedback |
583
+
548
584
  ---
549
585
 
550
586
  ## 🔧 Dependências
@@ -574,6 +610,83 @@ network = create_standard_network(
574
610
 
575
611
  ---
576
612
 
613
+ ## 📊 Tracing e Monitoramento
614
+
615
+ ### MonkAI Trace (Recomendado)
616
+
617
+ Integração com [MonkAI Trace](https://github.com/BeMonkAI/monkai-trace) para monitoramento completo de agentes:
618
+
619
+ ```bash
620
+ pip install monkai-trace
621
+ ```
622
+
623
+ ```python
624
+ from atendentepro import (
625
+ activate,
626
+ create_standard_network,
627
+ configure_monkai_trace,
628
+ run_with_monkai_tracking,
629
+ )
630
+
631
+ # 1. Ativar biblioteca
632
+ activate("ATP_seu-token")
633
+
634
+ # 2. Configurar MonkAI Trace
635
+ configure_monkai_trace(
636
+ tracer_token="tk_seu_token_monkai", # ou env MONKAI_TRACER_TOKEN
637
+ namespace="meu-projeto",
638
+ )
639
+
640
+ # 3. Criar rede
641
+ network = create_standard_network(...)
642
+
643
+ # 4. Executar com tracking
644
+ result = await run_with_monkai_tracking(
645
+ agent=network.triage,
646
+ user_input="Olá, preciso de ajuda",
647
+ user_id="user123", # Opcional: para sessões multi-usuário
648
+ )
649
+ ```
650
+
651
+ **Recursos do MonkAI Trace:**
652
+ - ✅ Tracking automático de sessões
653
+ - ✅ Segmentação de tokens (input, output, process, memory)
654
+ - ✅ Rastreamento de handoffs entre agentes
655
+ - ✅ Captura de ferramentas internas (web_search, RAG)
656
+ - ✅ Suporte multi-usuário (WhatsApp, chat)
657
+
658
+ ### Uso Avançado
659
+
660
+ ```python
661
+ from atendentepro import (
662
+ get_monkai_hooks,
663
+ set_monkai_user,
664
+ set_monkai_input,
665
+ )
666
+ from agents import Runner
667
+
668
+ # Para controle manual
669
+ hooks = get_monkai_hooks()
670
+ set_monkai_user("5511999999999") # WhatsApp
671
+ set_monkai_input("Como cancelar?")
672
+
673
+ result = await Runner.run(network.triage, messages, hooks=hooks)
674
+ ```
675
+
676
+ ### Application Insights (Azure)
677
+
678
+ Para Azure, use Application Insights:
679
+
680
+ ```python
681
+ from atendentepro import configure_application_insights
682
+
683
+ configure_application_insights(
684
+ connection_string="InstrumentationKey=..."
685
+ )
686
+ ```
687
+
688
+ ---
689
+
577
690
  ## 🤝 Suporte
578
691
 
579
692
  - 📧 **Email:** contato@monkai.com.br
@@ -1,7 +1,7 @@
1
1
  atendentepro/README.md,sha256=AMVMJlVOlXcwU_kRGBiIoSn8hASLHrhZwxV1jr1LJsU,43012
2
- atendentepro/__init__.py,sha256=r_9RwvfKcvcS6bk2a1sdQsQyf_CUW-tljE-vh3TeLyw,5150
2
+ atendentepro/__init__.py,sha256=A7ANs1G18HZEhl-C_OVVdOzM0KCRDo-sX1Veq4IYwDo,5572
3
3
  atendentepro/license.py,sha256=rlPtysXNqAzEQkP2VjUAVu_nMndhPgfKv1yN2ruUYVI,17570
4
- atendentepro/network.py,sha256=CHJVoggOE--LzVvR1XROtjeFqnwJctP2L4dHgCVCXXE,14419
4
+ atendentepro/network.py,sha256=s7h9if2oS_15BL8VoONjMlihEFCkJqdHxR5WFL81gl4,17310
5
5
  atendentepro/agents/__init__.py,sha256=OcPhG1Dp6xe49B5YIti4HVmaZDoDIrFLfRa8GmI4jpQ,1638
6
6
  atendentepro/agents/answer.py,sha256=dIZzGL_ddjC96JIiWSwDg33phwca8NpWFxO16FFYVoA,1905
7
7
  atendentepro/agents/confirmation.py,sha256=5Zg4z9A90CydYiEk8CEAKnnza71algFKF-N1WLwGDQI,2311
@@ -32,12 +32,12 @@ atendentepro/prompts/onboarding.py,sha256=78fSIh2ifsGeoav8DV41_jnyU157c0dtggJujc
32
32
  atendentepro/prompts/triage.py,sha256=bSdEVheGy03r5P6MQuv7NwhN2_wrt0mK80F9f_LskRU,1283
33
33
  atendentepro/templates/__init__.py,sha256=kSXiDXVIZKKsSn2GuHBcHsnXqVRcNWyBzRlKl9HYoCI,1137
34
34
  atendentepro/templates/manager.py,sha256=KdE4khWDMD2S607TDTMkvJ8lZzQ9D_TD_lBaXYSTBzI,17932
35
- atendentepro/utils/__init__.py,sha256=6EgS4DrW4fG17JdaHNKWMpzicigfFLVJO2VxPV73k9c,334
35
+ atendentepro/utils/__init__.py,sha256=WCJ6_btsLaI6xxHXvNHNue-nKrXWTKscNZGTToQiJ8A,833
36
36
  atendentepro/utils/openai_client.py,sha256=R0ns7SU36vTgploq14-QJMTke1pPxcAXlENDeoHU0L4,4552
37
- atendentepro/utils/tracing.py,sha256=HQ3l4IiNcesCJ6l5qcERWyeBQav0G1ea-H8Rei6eQpE,2319
38
- atendentepro-0.5.5.dist-info/licenses/LICENSE,sha256=TF6CdXxePoT9DXtPnCejiU5mUwWzrFzd1iyWJyoMauA,983
39
- atendentepro-0.5.5.dist-info/METADATA,sha256=OGF3rtTWuoH0Xr6bA8UH4Lsq_FUBg6g0xwsGiCA47PQ,17806
40
- atendentepro-0.5.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
- atendentepro-0.5.5.dist-info/entry_points.txt,sha256=OP0upzqJF3MLS6VX-M-5BfUwx5YLJO2sJ3YBAp4e6yI,89
42
- atendentepro-0.5.5.dist-info/top_level.txt,sha256=BFasD4SMmgDUmWKlTIZ1PeuukoRBhyiMIz8umKWVCcs,13
43
- atendentepro-0.5.5.dist-info/RECORD,,
37
+ atendentepro/utils/tracing.py,sha256=kpTPw1PF4rR1qq1RyBnAaPIQIJRka4RF8MfG_JrRJ7U,8486
38
+ atendentepro-0.5.7.dist-info/licenses/LICENSE,sha256=TF6CdXxePoT9DXtPnCejiU5mUwWzrFzd1iyWJyoMauA,983
39
+ atendentepro-0.5.7.dist-info/METADATA,sha256=sNb7PC8RcGrtRtciak-J_yiJedDxquF7N2mtl_4QwFo,20757
40
+ atendentepro-0.5.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
+ atendentepro-0.5.7.dist-info/entry_points.txt,sha256=OP0upzqJF3MLS6VX-M-5BfUwx5YLJO2sJ3YBAp4e6yI,89
42
+ atendentepro-0.5.7.dist-info/top_level.txt,sha256=BFasD4SMmgDUmWKlTIZ1PeuukoRBhyiMIz8umKWVCcs,13
43
+ atendentepro-0.5.7.dist-info/RECORD,,