atendentepro 0.3.0__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/README.md +890 -0
- atendentepro/__init__.py +215 -0
- atendentepro/agents/__init__.py +45 -0
- atendentepro/agents/answer.py +62 -0
- atendentepro/agents/confirmation.py +69 -0
- atendentepro/agents/flow.py +64 -0
- atendentepro/agents/interview.py +68 -0
- atendentepro/agents/knowledge.py +296 -0
- atendentepro/agents/onboarding.py +65 -0
- atendentepro/agents/triage.py +57 -0
- atendentepro/agents/usage.py +56 -0
- atendentepro/config/__init__.py +19 -0
- atendentepro/config/settings.py +134 -0
- atendentepro/guardrails/__init__.py +21 -0
- atendentepro/guardrails/manager.py +419 -0
- atendentepro/license.py +502 -0
- atendentepro/models/__init__.py +21 -0
- atendentepro/models/context.py +21 -0
- atendentepro/models/outputs.py +118 -0
- atendentepro/network.py +325 -0
- atendentepro/prompts/__init__.py +35 -0
- atendentepro/prompts/answer.py +114 -0
- atendentepro/prompts/confirmation.py +124 -0
- atendentepro/prompts/flow.py +112 -0
- atendentepro/prompts/interview.py +123 -0
- atendentepro/prompts/knowledge.py +135 -0
- atendentepro/prompts/onboarding.py +146 -0
- atendentepro/prompts/triage.py +42 -0
- atendentepro/templates/__init__.py +51 -0
- atendentepro/templates/manager.py +530 -0
- atendentepro/utils/__init__.py +19 -0
- atendentepro/utils/openai_client.py +154 -0
- atendentepro/utils/tracing.py +71 -0
- atendentepro-0.3.0.dist-info/METADATA +306 -0
- atendentepro-0.3.0.dist-info/RECORD +39 -0
- atendentepro-0.3.0.dist-info/WHEEL +5 -0
- atendentepro-0.3.0.dist-info/entry_points.txt +2 -0
- atendentepro-0.3.0.dist-info/licenses/LICENSE +25 -0
- atendentepro-0.3.0.dist-info/top_level.txt +1 -0
atendentepro/__init__.py
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
AtendentePro - Sistema de Atendimento Inteligente com Múltiplos Agentes IA
|
|
4
|
+
|
|
5
|
+
Uma biblioteca Python modular para criar sistemas de atendimento automatizado
|
|
6
|
+
usando múltiplos agentes de IA especializados.
|
|
7
|
+
|
|
8
|
+
⚠️ ATIVAÇÃO NECESSÁRIA:
|
|
9
|
+
|
|
10
|
+
Esta biblioteca requer um token de licença para funcionar.
|
|
11
|
+
|
|
12
|
+
Opção 1 - Ativar programaticamente:
|
|
13
|
+
|
|
14
|
+
from atendentepro import activate
|
|
15
|
+
activate("seu-token-de-acesso")
|
|
16
|
+
|
|
17
|
+
Opção 2 - Variável de ambiente:
|
|
18
|
+
|
|
19
|
+
export ATENDENTEPRO_LICENSE_KEY="seu-token-de-acesso"
|
|
20
|
+
|
|
21
|
+
Exemplo de uso básico:
|
|
22
|
+
|
|
23
|
+
from atendentepro import activate, create_standard_network, configure
|
|
24
|
+
from pathlib import Path
|
|
25
|
+
|
|
26
|
+
# 1. Ativar a biblioteca
|
|
27
|
+
activate("seu-token-de-acesso")
|
|
28
|
+
|
|
29
|
+
# 2. Configurar a biblioteca
|
|
30
|
+
configure(provider="openai", openai_api_key="sua-chave")
|
|
31
|
+
|
|
32
|
+
# 3. Criar rede de agentes
|
|
33
|
+
network = create_standard_network(
|
|
34
|
+
templates_root=Path("./client_templates"),
|
|
35
|
+
client="standard"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# 4. Usar o agente de triagem como ponto de entrada
|
|
39
|
+
triage_agent = network.triage
|
|
40
|
+
|
|
41
|
+
Para obter um token de licença, entre em contato: contato@bemonkai.com
|
|
42
|
+
Para mais informações, consulte a documentação.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
__version__ = "0.3.0"
|
|
46
|
+
__author__ = "BeMonkAI"
|
|
47
|
+
__email__ = "contato@bemonkai.com"
|
|
48
|
+
__license__ = "Proprietary"
|
|
49
|
+
|
|
50
|
+
# License (deve ser importado primeiro)
|
|
51
|
+
from atendentepro.license import (
|
|
52
|
+
activate,
|
|
53
|
+
deactivate,
|
|
54
|
+
is_activated,
|
|
55
|
+
get_license_info,
|
|
56
|
+
require_activation,
|
|
57
|
+
has_feature,
|
|
58
|
+
generate_license_token,
|
|
59
|
+
LicenseInfo,
|
|
60
|
+
LicenseError,
|
|
61
|
+
LicenseNotActivatedError,
|
|
62
|
+
LicenseExpiredError,
|
|
63
|
+
InvalidTokenError,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# Configuration
|
|
67
|
+
from atendentepro.config import (
|
|
68
|
+
AtendentProConfig,
|
|
69
|
+
get_config,
|
|
70
|
+
configure,
|
|
71
|
+
RECOMMENDED_PROMPT_PREFIX,
|
|
72
|
+
DEFAULT_MODEL,
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
# Models
|
|
76
|
+
from atendentepro.models import (
|
|
77
|
+
ContextNote,
|
|
78
|
+
FlowTopic,
|
|
79
|
+
FlowOutput,
|
|
80
|
+
InterviewOutput,
|
|
81
|
+
KnowledgeToolResult,
|
|
82
|
+
GuardrailValidationOutput,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Agents
|
|
86
|
+
from atendentepro.agents import (
|
|
87
|
+
create_triage_agent,
|
|
88
|
+
create_flow_agent,
|
|
89
|
+
create_interview_agent,
|
|
90
|
+
create_answer_agent,
|
|
91
|
+
create_knowledge_agent,
|
|
92
|
+
create_confirmation_agent,
|
|
93
|
+
create_usage_agent,
|
|
94
|
+
create_onboarding_agent,
|
|
95
|
+
TriageAgent,
|
|
96
|
+
FlowAgent,
|
|
97
|
+
InterviewAgent,
|
|
98
|
+
AnswerAgent,
|
|
99
|
+
KnowledgeAgent,
|
|
100
|
+
ConfirmationAgent,
|
|
101
|
+
UsageAgent,
|
|
102
|
+
OnboardingAgent,
|
|
103
|
+
go_to_rag,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Network
|
|
107
|
+
from atendentepro.network import (
|
|
108
|
+
AgentNetwork,
|
|
109
|
+
create_standard_network,
|
|
110
|
+
create_custom_network,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
# Templates
|
|
114
|
+
from atendentepro.templates import (
|
|
115
|
+
TemplateManager,
|
|
116
|
+
ClientTemplate,
|
|
117
|
+
configure_client,
|
|
118
|
+
get_template_folder,
|
|
119
|
+
load_flow_config,
|
|
120
|
+
load_interview_config,
|
|
121
|
+
load_triage_config,
|
|
122
|
+
load_knowledge_config,
|
|
123
|
+
load_confirmation_config,
|
|
124
|
+
load_onboarding_config,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# Guardrails
|
|
128
|
+
from atendentepro.guardrails import (
|
|
129
|
+
GuardrailManager,
|
|
130
|
+
get_guardrails_for_agent,
|
|
131
|
+
get_out_of_scope_message,
|
|
132
|
+
set_guardrails_client,
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
# Utils
|
|
136
|
+
from atendentepro.utils import (
|
|
137
|
+
get_async_client,
|
|
138
|
+
get_provider,
|
|
139
|
+
configure_tracing,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
__all__ = [
|
|
143
|
+
# Version
|
|
144
|
+
"__version__",
|
|
145
|
+
"__author__",
|
|
146
|
+
# License
|
|
147
|
+
"activate",
|
|
148
|
+
"deactivate",
|
|
149
|
+
"is_activated",
|
|
150
|
+
"get_license_info",
|
|
151
|
+
"require_activation",
|
|
152
|
+
"has_feature",
|
|
153
|
+
"generate_license_token",
|
|
154
|
+
"LicenseInfo",
|
|
155
|
+
"LicenseError",
|
|
156
|
+
"LicenseNotActivatedError",
|
|
157
|
+
"LicenseExpiredError",
|
|
158
|
+
"InvalidTokenError",
|
|
159
|
+
# Configuration
|
|
160
|
+
"AtendentProConfig",
|
|
161
|
+
"get_config",
|
|
162
|
+
"configure",
|
|
163
|
+
"RECOMMENDED_PROMPT_PREFIX",
|
|
164
|
+
"DEFAULT_MODEL",
|
|
165
|
+
# Models
|
|
166
|
+
"ContextNote",
|
|
167
|
+
"FlowTopic",
|
|
168
|
+
"FlowOutput",
|
|
169
|
+
"InterviewOutput",
|
|
170
|
+
"KnowledgeToolResult",
|
|
171
|
+
"GuardrailValidationOutput",
|
|
172
|
+
# Agents
|
|
173
|
+
"create_triage_agent",
|
|
174
|
+
"create_flow_agent",
|
|
175
|
+
"create_interview_agent",
|
|
176
|
+
"create_answer_agent",
|
|
177
|
+
"create_knowledge_agent",
|
|
178
|
+
"create_confirmation_agent",
|
|
179
|
+
"create_usage_agent",
|
|
180
|
+
"create_onboarding_agent",
|
|
181
|
+
"TriageAgent",
|
|
182
|
+
"FlowAgent",
|
|
183
|
+
"InterviewAgent",
|
|
184
|
+
"AnswerAgent",
|
|
185
|
+
"KnowledgeAgent",
|
|
186
|
+
"ConfirmationAgent",
|
|
187
|
+
"UsageAgent",
|
|
188
|
+
"OnboardingAgent",
|
|
189
|
+
"go_to_rag",
|
|
190
|
+
# Network
|
|
191
|
+
"AgentNetwork",
|
|
192
|
+
"create_standard_network",
|
|
193
|
+
"create_custom_network",
|
|
194
|
+
# Templates
|
|
195
|
+
"TemplateManager",
|
|
196
|
+
"ClientTemplate",
|
|
197
|
+
"configure_client",
|
|
198
|
+
"get_template_folder",
|
|
199
|
+
"load_flow_config",
|
|
200
|
+
"load_interview_config",
|
|
201
|
+
"load_triage_config",
|
|
202
|
+
"load_knowledge_config",
|
|
203
|
+
"load_confirmation_config",
|
|
204
|
+
"load_onboarding_config",
|
|
205
|
+
# Guardrails
|
|
206
|
+
"GuardrailManager",
|
|
207
|
+
"get_guardrails_for_agent",
|
|
208
|
+
"get_out_of_scope_message",
|
|
209
|
+
"set_guardrails_client",
|
|
210
|
+
# Utils
|
|
211
|
+
"get_async_client",
|
|
212
|
+
"get_provider",
|
|
213
|
+
"configure_tracing",
|
|
214
|
+
]
|
|
215
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""
|
|
3
|
+
Agents module for AtendentePro library.
|
|
4
|
+
|
|
5
|
+
This module provides factory functions for creating agents with customizable
|
|
6
|
+
configurations. Templates can be loaded from external directories.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from .triage import create_triage_agent, TriageAgent
|
|
10
|
+
from .flow import create_flow_agent, FlowAgent
|
|
11
|
+
from .interview import create_interview_agent, InterviewAgent
|
|
12
|
+
from .answer import create_answer_agent, AnswerAgent
|
|
13
|
+
from .knowledge import create_knowledge_agent, KnowledgeAgent, go_to_rag
|
|
14
|
+
from .confirmation import create_confirmation_agent, ConfirmationAgent
|
|
15
|
+
from .usage import create_usage_agent, UsageAgent
|
|
16
|
+
from .onboarding import create_onboarding_agent, OnboardingAgent
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
# Triage
|
|
20
|
+
"create_triage_agent",
|
|
21
|
+
"TriageAgent",
|
|
22
|
+
# Flow
|
|
23
|
+
"create_flow_agent",
|
|
24
|
+
"FlowAgent",
|
|
25
|
+
# Interview
|
|
26
|
+
"create_interview_agent",
|
|
27
|
+
"InterviewAgent",
|
|
28
|
+
# Answer
|
|
29
|
+
"create_answer_agent",
|
|
30
|
+
"AnswerAgent",
|
|
31
|
+
# Knowledge
|
|
32
|
+
"create_knowledge_agent",
|
|
33
|
+
"KnowledgeAgent",
|
|
34
|
+
"go_to_rag",
|
|
35
|
+
# Confirmation
|
|
36
|
+
"create_confirmation_agent",
|
|
37
|
+
"ConfirmationAgent",
|
|
38
|
+
# Usage
|
|
39
|
+
"create_usage_agent",
|
|
40
|
+
"UsageAgent",
|
|
41
|
+
# Onboarding
|
|
42
|
+
"create_onboarding_agent",
|
|
43
|
+
"OnboardingAgent",
|
|
44
|
+
]
|
|
45
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Answer Agent for AtendentePro."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional, TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from agents import Agent
|
|
9
|
+
|
|
10
|
+
from atendentepro.config import RECOMMENDED_PROMPT_PREFIX
|
|
11
|
+
from atendentepro.models import ContextNote
|
|
12
|
+
from atendentepro.prompts import get_answer_prompt
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from atendentepro.guardrails import GuardrailCallable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Type alias for the Answer Agent
|
|
19
|
+
AnswerAgent = Agent[ContextNote]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def create_answer_agent(
|
|
23
|
+
answer_template: str = "",
|
|
24
|
+
handoffs: Optional[List] = None,
|
|
25
|
+
guardrails: Optional[List["GuardrailCallable"]] = None,
|
|
26
|
+
name: str = "Answer Agent",
|
|
27
|
+
custom_instructions: Optional[str] = None,
|
|
28
|
+
) -> AnswerAgent:
|
|
29
|
+
"""
|
|
30
|
+
Create an Answer Agent instance.
|
|
31
|
+
|
|
32
|
+
The answer agent synthesizes final responses using collected data
|
|
33
|
+
and the configured answer template.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
answer_template: Template for answer formatting.
|
|
37
|
+
handoffs: List of agents to hand off to.
|
|
38
|
+
guardrails: List of input guardrails.
|
|
39
|
+
name: Agent name.
|
|
40
|
+
custom_instructions: Optional custom instructions to override default.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
Configured Answer Agent instance.
|
|
44
|
+
"""
|
|
45
|
+
if custom_instructions:
|
|
46
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {custom_instructions}"
|
|
47
|
+
else:
|
|
48
|
+
prompt = get_answer_prompt(answer_template=answer_template)
|
|
49
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {prompt}"
|
|
50
|
+
|
|
51
|
+
return Agent[ContextNote](
|
|
52
|
+
name=name,
|
|
53
|
+
handoff_description=(
|
|
54
|
+
"Agente responsável por sintetizar a resposta técnica final usando os dados coletados. "
|
|
55
|
+
"Após concluir a orientação, deve acionar o handoff para o Triage Agent a fim de encerrar o caso. "
|
|
56
|
+
"Se identificar lacunas de informação, orienta o que falta e aciona o handoff para o Interview Agent."
|
|
57
|
+
),
|
|
58
|
+
instructions=instructions,
|
|
59
|
+
handoffs=handoffs or [],
|
|
60
|
+
input_guardrails=guardrails or [],
|
|
61
|
+
)
|
|
62
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Confirmation Agent for AtendentePro."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional, TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from agents import Agent
|
|
9
|
+
|
|
10
|
+
from atendentepro.config import RECOMMENDED_PROMPT_PREFIX
|
|
11
|
+
from atendentepro.models import ContextNote
|
|
12
|
+
from atendentepro.prompts import get_confirmation_prompt
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from atendentepro.guardrails import GuardrailCallable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Type alias for the Confirmation Agent
|
|
19
|
+
ConfirmationAgent = Agent[ContextNote]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def create_confirmation_agent(
|
|
23
|
+
confirmation_about: str = "",
|
|
24
|
+
confirmation_template: str = "",
|
|
25
|
+
confirmation_format: str = "",
|
|
26
|
+
handoffs: Optional[List] = None,
|
|
27
|
+
guardrails: Optional[List["GuardrailCallable"]] = None,
|
|
28
|
+
name: str = "Confirmation Agent",
|
|
29
|
+
custom_instructions: Optional[str] = None,
|
|
30
|
+
) -> ConfirmationAgent:
|
|
31
|
+
"""
|
|
32
|
+
Create a Confirmation Agent instance.
|
|
33
|
+
|
|
34
|
+
The confirmation agent validates hypotheses and provides yes/no answers
|
|
35
|
+
with explanations based on configured rules.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
confirmation_about: Scope description for confirmation.
|
|
39
|
+
confirmation_template: Template for confirmation logic.
|
|
40
|
+
confirmation_format: Response format template.
|
|
41
|
+
handoffs: List of agents to hand off to.
|
|
42
|
+
guardrails: List of input guardrails.
|
|
43
|
+
name: Agent name.
|
|
44
|
+
custom_instructions: Optional custom instructions to override default.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Configured Confirmation Agent instance.
|
|
48
|
+
"""
|
|
49
|
+
if custom_instructions:
|
|
50
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {custom_instructions}"
|
|
51
|
+
else:
|
|
52
|
+
prompt = get_confirmation_prompt(
|
|
53
|
+
confirmation_about=confirmation_about,
|
|
54
|
+
confirmation_template=confirmation_template,
|
|
55
|
+
confirmation_format=confirmation_format,
|
|
56
|
+
)
|
|
57
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {prompt}"
|
|
58
|
+
|
|
59
|
+
return Agent[ContextNote](
|
|
60
|
+
name=name,
|
|
61
|
+
handoff_description=(
|
|
62
|
+
"Agente especializado em confirmar ou negar hipóteses específicas do usuário, "
|
|
63
|
+
"explicando o motivo da decisão com base nas regras e políticas conhecidas do produto ou processo."
|
|
64
|
+
),
|
|
65
|
+
instructions=instructions,
|
|
66
|
+
handoffs=handoffs or [],
|
|
67
|
+
input_guardrails=guardrails or [],
|
|
68
|
+
)
|
|
69
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Flow Agent for AtendentePro."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional, TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from agents import Agent
|
|
9
|
+
|
|
10
|
+
from atendentepro.config import RECOMMENDED_PROMPT_PREFIX
|
|
11
|
+
from atendentepro.models import ContextNote
|
|
12
|
+
from atendentepro.prompts import get_flow_prompt
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from atendentepro.guardrails import GuardrailCallable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Type alias for the Flow Agent
|
|
19
|
+
FlowAgent = Agent[ContextNote]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def create_flow_agent(
|
|
23
|
+
flow_template: str = "",
|
|
24
|
+
flow_keywords: str = "",
|
|
25
|
+
handoffs: Optional[List] = None,
|
|
26
|
+
guardrails: Optional[List["GuardrailCallable"]] = None,
|
|
27
|
+
name: str = "Flow Agent",
|
|
28
|
+
custom_instructions: Optional[str] = None,
|
|
29
|
+
) -> FlowAgent:
|
|
30
|
+
"""
|
|
31
|
+
Create a Flow Agent instance.
|
|
32
|
+
|
|
33
|
+
The flow agent identifies topics and routes users to the interview agent.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
flow_template: Template with available topics.
|
|
37
|
+
flow_keywords: Keywords for topic identification.
|
|
38
|
+
handoffs: List of agents to hand off to.
|
|
39
|
+
guardrails: List of input guardrails.
|
|
40
|
+
name: Agent name.
|
|
41
|
+
custom_instructions: Optional custom instructions to override default.
|
|
42
|
+
|
|
43
|
+
Returns:
|
|
44
|
+
Configured Flow Agent instance.
|
|
45
|
+
"""
|
|
46
|
+
if custom_instructions:
|
|
47
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {custom_instructions}"
|
|
48
|
+
else:
|
|
49
|
+
prompt = get_flow_prompt(flow_template=flow_template, flow_keywords=flow_keywords)
|
|
50
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {prompt}"
|
|
51
|
+
|
|
52
|
+
return Agent[ContextNote](
|
|
53
|
+
name=name,
|
|
54
|
+
handoff_description="""
|
|
55
|
+
Um agente de fluxo inteligente que:
|
|
56
|
+
1. Se o usuário já especificou um tópico específico, vai direto para o interview_agent
|
|
57
|
+
2. Se não especificou, apresenta a lista de tópicos para o usuário escolher
|
|
58
|
+
3. Só transfere para triage se a resposta não for clara o suficiente
|
|
59
|
+
""",
|
|
60
|
+
instructions=instructions,
|
|
61
|
+
handoffs=handoffs or [],
|
|
62
|
+
input_guardrails=guardrails or [],
|
|
63
|
+
)
|
|
64
|
+
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""Interview Agent for AtendentePro."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from typing import List, Optional, TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from agents import Agent
|
|
9
|
+
|
|
10
|
+
from atendentepro.config import RECOMMENDED_PROMPT_PREFIX
|
|
11
|
+
from atendentepro.models import ContextNote
|
|
12
|
+
from atendentepro.prompts import get_interview_prompt
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from atendentepro.guardrails import GuardrailCallable
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# Type alias for the Interview Agent
|
|
19
|
+
InterviewAgent = Agent[ContextNote]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def create_interview_agent(
|
|
23
|
+
interview_template: str = "",
|
|
24
|
+
interview_questions: str = "",
|
|
25
|
+
handoffs: Optional[List] = None,
|
|
26
|
+
tools: Optional[List] = None,
|
|
27
|
+
guardrails: Optional[List["GuardrailCallable"]] = None,
|
|
28
|
+
name: str = "Interview Agent",
|
|
29
|
+
custom_instructions: Optional[str] = None,
|
|
30
|
+
) -> InterviewAgent:
|
|
31
|
+
"""
|
|
32
|
+
Create an Interview Agent instance.
|
|
33
|
+
|
|
34
|
+
The interview agent collects information from users through structured
|
|
35
|
+
questions based on the identified topic.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
interview_template: Template with topic routing info.
|
|
39
|
+
interview_questions: Configured interview questions.
|
|
40
|
+
handoffs: List of agents to hand off to.
|
|
41
|
+
tools: List of tools available to the agent.
|
|
42
|
+
guardrails: List of input guardrails.
|
|
43
|
+
name: Agent name.
|
|
44
|
+
custom_instructions: Optional custom instructions to override default.
|
|
45
|
+
|
|
46
|
+
Returns:
|
|
47
|
+
Configured Interview Agent instance.
|
|
48
|
+
"""
|
|
49
|
+
if custom_instructions:
|
|
50
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {custom_instructions}"
|
|
51
|
+
else:
|
|
52
|
+
prompt = get_interview_prompt(
|
|
53
|
+
interview_template=interview_template,
|
|
54
|
+
interview_questions=interview_questions,
|
|
55
|
+
)
|
|
56
|
+
instructions = f"{RECOMMENDED_PROMPT_PREFIX} {prompt}"
|
|
57
|
+
|
|
58
|
+
return Agent[ContextNote](
|
|
59
|
+
name=name,
|
|
60
|
+
handoff_description="""
|
|
61
|
+
Um agente de entrevista que pode entrevistar o usuário para obter informações relevantes.
|
|
62
|
+
""",
|
|
63
|
+
instructions=instructions,
|
|
64
|
+
handoffs=handoffs or [],
|
|
65
|
+
tools=tools or [],
|
|
66
|
+
input_guardrails=guardrails or [],
|
|
67
|
+
)
|
|
68
|
+
|