atendentepro 0.6.3__tar.gz → 0.6.5__tar.gz
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-0.6.3 → atendentepro-0.6.5}/CHANGELOG.md +34 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/PKG-INFO +421 -35
- {atendentepro-0.6.3 → atendentepro-0.6.5}/README.md +420 -34
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/__init__.py +10 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/models/__init__.py +14 -1
- atendentepro-0.6.5/atendentepro/models/context.py +182 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/network.py +143 -50
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/templates/__init__.py +8 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/templates/manager.py +138 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/pyproject.toml +1 -1
- atendentepro-0.6.3/atendentepro/models/context.py +0 -21
- {atendentepro-0.6.3 → atendentepro-0.6.5}/LICENSE +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/MANIFEST.in +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/README.md +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/__init__.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/answer.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/confirmation.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/escalation.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/feedback.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/flow.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/interview.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/knowledge.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/onboarding.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/triage.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/agents/usage.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/config/__init__.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/config/settings.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/guardrails/__init__.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/guardrails/manager.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/license.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/models/outputs.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/__init__.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/answer.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/confirmation.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/escalation.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/feedback.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/flow.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/interview.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/knowledge.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/onboarding.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/prompts/triage.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/utils/__init__.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/utils/openai_client.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro/utils/tracing.py +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/atendentepro.egg-info/SOURCES.txt +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/requirements.txt +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/setup.cfg +0 -0
- {atendentepro-0.6.3 → atendentepro-0.6.5}/setup.py +0 -0
|
@@ -5,6 +5,36 @@ All notable changes to AtendentePro will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.6.5] - 2025-01-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Scripts de teste de licença**: Novos scripts em `scripts/` para testar o comportamento da biblioteca sem credencial
|
|
12
|
+
- `scripts/test_without_license.py`: Script para verificar se a biblioteca bloqueia corretamente o uso sem licença
|
|
13
|
+
- `scripts/TESTE_SEM_CREDENCIAL.md`: Documentação do teste de licença
|
|
14
|
+
|
|
15
|
+
### Documentation
|
|
16
|
+
- Documentação sobre verificação de licença e comportamento sem credencial
|
|
17
|
+
|
|
18
|
+
## [0.6.4] - 2025-01-14
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- **Filtros de Acesso (Role/User)**: Novo sistema de controle de acesso baseado em roles e usuários
|
|
22
|
+
- `UserContext`: Contexto do usuário com user_id, role e metadata
|
|
23
|
+
- `AccessFilter`: Filtros whitelist/blacklist para roles e users
|
|
24
|
+
- `FilteredPromptSection`: Seções de prompt condicionais por role/user
|
|
25
|
+
- `FilteredTool`: Tools com filtro de acesso
|
|
26
|
+
- **Novos parâmetros em `create_standard_network`**:
|
|
27
|
+
- `user_context`: Contexto do usuário para filtragem
|
|
28
|
+
- `agent_filters`: Filtros de agente por role/user
|
|
29
|
+
- `conditional_prompts`: Prompts condicionais por role/user
|
|
30
|
+
- `filtered_tools`: Tools filtradas por role/user
|
|
31
|
+
- **Configuração via YAML** (`access_config.yaml`): Suporte a configuração de filtros via arquivo
|
|
32
|
+
- **Exemplos completos**: Pasta `docs/examples/access_filters/` com casos de uso
|
|
33
|
+
|
|
34
|
+
### Documentation
|
|
35
|
+
- README atualizado com seção completa de Filtros de Acesso
|
|
36
|
+
- Exemplos de código e YAML para diferentes cenários
|
|
37
|
+
|
|
8
38
|
## [0.6.3] - 2025-01-12
|
|
9
39
|
|
|
10
40
|
### Changed
|
|
@@ -13,6 +43,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
13
43
|
- **CI mais rápido**: Cache de pip adicionado e matriz reduzida para Python 3.9 e 3.12
|
|
14
44
|
- Instalação base reduzida de ~300MB para ~50MB
|
|
15
45
|
|
|
46
|
+
### Added
|
|
47
|
+
- **Exemplos de Single Reply Mode**: Pasta `docs/examples/single_reply/` com exemplos completos
|
|
48
|
+
- Documentação expandida no README com casos de uso práticos (FAQ Bot, Bot de Leads)
|
|
49
|
+
|
|
16
50
|
### Fixed
|
|
17
51
|
- Warnings de instalação eliminados com pinagem de versões
|
|
18
52
|
- Tempo de deploy reduzido de ~40min para ~8-10min
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: atendentepro
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.5
|
|
4
4
|
Summary: Framework de orquestração de agentes IA com tom e estilo customizáveis. Integra documentos (RAG), APIs e bancos de dados em uma plataforma inteligente multi-agente.
|
|
5
5
|
Author-email: BeMonkAI <contato@monkai.com.br>
|
|
6
6
|
Maintainer-email: BeMonkAI <contato@monkai.com.br>
|
|
@@ -95,6 +95,8 @@ Plataforma que unifica múltiplos agentes especializados para resolver demandas
|
|
|
95
95
|
- [Fluxo de Handoffs](#-fluxo-de-handoffs)
|
|
96
96
|
- [Estilo de Comunicação](#-estilo-de-comunicação-agentstyle)
|
|
97
97
|
- [Single Reply Mode](#-single-reply-mode)
|
|
98
|
+
- [Filtros de Acesso](#-filtros-de-acesso-roleuser)
|
|
99
|
+
- [Múltiplos Agentes](#-múltiplos-agentes-multi-interview--knowledge)
|
|
98
100
|
- [Tracing e Monitoramento](#-tracing-e-monitoramento)
|
|
99
101
|
- [Suporte](#-suporte)
|
|
100
102
|
|
|
@@ -712,82 +714,466 @@ agents:
|
|
|
712
714
|
|
|
713
715
|
O **Single Reply Mode** permite configurar agentes para responderem apenas uma vez e automaticamente transferirem de volta para o Triage. Isso evita que a conversa fique "presa" em um agente específico.
|
|
714
716
|
|
|
717
|
+
📂 **Exemplos completos**: [docs/examples/single_reply/](docs/examples/single_reply/)
|
|
718
|
+
|
|
715
719
|
### Quando Usar
|
|
716
720
|
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
721
|
+
| Cenário | Recomendação |
|
|
722
|
+
|---------|--------------|
|
|
723
|
+
| **Chatbots de alto volume** | ✅ Ativar para respostas rápidas |
|
|
724
|
+
| **FAQ simples** | ✅ Knowledge com single_reply |
|
|
725
|
+
| **Coleta de dados** | ❌ Interview precisa múltiplas interações |
|
|
726
|
+
| **Onboarding** | ❌ Precisa guiar o usuário em etapas |
|
|
727
|
+
| **Confirmações** | ✅ Confirma e volta ao Triage |
|
|
720
728
|
|
|
721
|
-
### Via Código
|
|
729
|
+
### Exemplo 1: FAQ Bot (Via Código)
|
|
730
|
+
|
|
731
|
+
Chatbot otimizado para perguntas frequentes:
|
|
722
732
|
|
|
723
733
|
```python
|
|
724
734
|
from pathlib import Path
|
|
725
735
|
from atendentepro import create_standard_network
|
|
726
736
|
|
|
727
|
-
#
|
|
737
|
+
# FAQ Bot: Knowledge e Answer respondem uma vez
|
|
728
738
|
network = create_standard_network(
|
|
729
739
|
templates_root=Path("./meu_cliente"),
|
|
730
740
|
client="config",
|
|
731
|
-
global_single_reply=
|
|
741
|
+
global_single_reply=False,
|
|
742
|
+
single_reply_agents={
|
|
743
|
+
"knowledge": True, # FAQ: responde e volta
|
|
744
|
+
"answer": True, # Perguntas gerais: responde e volta
|
|
745
|
+
"flow": True, # Menu: apresenta e volta
|
|
746
|
+
},
|
|
732
747
|
)
|
|
748
|
+
```
|
|
749
|
+
|
|
750
|
+
### Exemplo 2: Bot de Leads (Via Código)
|
|
733
751
|
|
|
734
|
-
|
|
752
|
+
Bot que coleta dados mas responde dúvidas rapidamente:
|
|
753
|
+
|
|
754
|
+
```python
|
|
735
755
|
network = create_standard_network(
|
|
736
756
|
templates_root=Path("./meu_cliente"),
|
|
737
757
|
client="config",
|
|
738
758
|
global_single_reply=False,
|
|
739
759
|
single_reply_agents={
|
|
740
|
-
|
|
741
|
-
"
|
|
742
|
-
|
|
743
|
-
#
|
|
760
|
+
# Interview PRECISA de múltiplas interações para coletar dados
|
|
761
|
+
"interview": False,
|
|
762
|
+
|
|
763
|
+
# Outros agentes podem ser rápidos
|
|
764
|
+
"knowledge": True, # Tira dúvidas sobre produto
|
|
765
|
+
"answer": True, # Responde perguntas
|
|
766
|
+
"confirmation": True, # Confirma cadastro
|
|
744
767
|
},
|
|
745
768
|
)
|
|
746
769
|
```
|
|
747
770
|
|
|
771
|
+
### Exemplo 3: Ativar para TODOS os agentes
|
|
772
|
+
|
|
773
|
+
```python
|
|
774
|
+
network = create_standard_network(
|
|
775
|
+
templates_root=Path("./meu_cliente"),
|
|
776
|
+
client="config",
|
|
777
|
+
global_single_reply=True, # Todos respondem uma vez
|
|
778
|
+
)
|
|
779
|
+
```
|
|
780
|
+
|
|
748
781
|
### Via YAML (single_reply_config.yaml)
|
|
749
782
|
|
|
750
783
|
Crie o arquivo `single_reply_config.yaml` na pasta do cliente:
|
|
751
784
|
|
|
752
785
|
```yaml
|
|
753
|
-
# Global:
|
|
786
|
+
# Global: se true, TODOS os agentes respondem apenas uma vez
|
|
787
|
+
global: false
|
|
788
|
+
|
|
789
|
+
# Configuração por agente (sobrescreve global)
|
|
790
|
+
agents:
|
|
791
|
+
# Agentes de consulta: respondem uma vez
|
|
792
|
+
knowledge: true # FAQ: responde e volta
|
|
793
|
+
answer: true # Perguntas: responde e volta
|
|
794
|
+
confirmation: true # Confirma e volta
|
|
795
|
+
usage: true # Explica uso e volta
|
|
796
|
+
|
|
797
|
+
# Agentes de coleta: múltiplas interações
|
|
798
|
+
interview: false # Precisa coletar dados
|
|
799
|
+
onboarding: false # Precisa guiar usuário
|
|
800
|
+
|
|
801
|
+
# Opcionais
|
|
802
|
+
flow: true # Menu: apresenta e volta
|
|
803
|
+
escalation: true # Registra e volta
|
|
804
|
+
feedback: true # Coleta feedback e volta
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
### Fluxo Visual
|
|
808
|
+
|
|
809
|
+
**Com single_reply=True:**
|
|
810
|
+
|
|
811
|
+
```
|
|
812
|
+
[Usuário: "Qual o preço?"]
|
|
813
|
+
↓
|
|
814
|
+
[Triage] → detecta consulta
|
|
815
|
+
↓
|
|
816
|
+
[Knowledge] → responde: "R$ 99,90"
|
|
817
|
+
↓
|
|
818
|
+
[Triage] ← retorno AUTOMÁTICO
|
|
819
|
+
↓
|
|
820
|
+
[Usuário: "E a entrega?"]
|
|
821
|
+
↓
|
|
822
|
+
[Triage] → nova análise (ciclo reinicia)
|
|
823
|
+
```
|
|
824
|
+
|
|
825
|
+
**Com single_reply=False (padrão):**
|
|
826
|
+
|
|
827
|
+
```
|
|
828
|
+
[Usuário: "Qual o preço?"]
|
|
829
|
+
↓
|
|
830
|
+
[Triage] → detecta consulta
|
|
831
|
+
↓
|
|
832
|
+
[Knowledge] → responde: "R$ 99,90"
|
|
833
|
+
↓
|
|
834
|
+
[Usuário: "E a entrega?"]
|
|
835
|
+
↓
|
|
836
|
+
[Knowledge] → continua no mesmo agente
|
|
837
|
+
↓
|
|
838
|
+
[Usuário: "Quero falar com humano"]
|
|
839
|
+
↓
|
|
840
|
+
[Knowledge] → handoff para Escalation
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
### Configuração Recomendada
|
|
844
|
+
|
|
845
|
+
Para a maioria dos casos de uso:
|
|
846
|
+
|
|
847
|
+
```yaml
|
|
754
848
|
global: false
|
|
755
849
|
|
|
756
|
-
# Configuração por agente
|
|
757
850
|
agents:
|
|
758
|
-
#
|
|
759
|
-
|
|
760
|
-
confirmation: true
|
|
761
|
-
answer: true
|
|
851
|
+
knowledge: true # FAQ
|
|
852
|
+
answer: true # Perguntas gerais
|
|
853
|
+
confirmation: true # Confirmações
|
|
762
854
|
|
|
763
|
-
#
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
855
|
+
interview: false # Coleta de dados
|
|
856
|
+
onboarding: false # Guia de usuário
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
---
|
|
860
|
+
|
|
861
|
+
## 🔐 Filtros de Acesso (Role/User)
|
|
862
|
+
|
|
863
|
+
O sistema de **Filtros de Acesso** permite controlar quais agentes, prompts e tools estão disponíveis para cada usuário ou role (função).
|
|
864
|
+
|
|
865
|
+
📂 **Exemplos completos**: [docs/examples/access_filters/](docs/examples/access_filters/)
|
|
866
|
+
|
|
867
|
+
### Quando Usar
|
|
868
|
+
|
|
869
|
+
| Cenário | Solução |
|
|
870
|
+
|---------|---------|
|
|
871
|
+
| **Multi-tenant** | Diferentes clientes veem diferentes agentes |
|
|
872
|
+
| **Níveis de acesso** | Admin vê mais opções que cliente |
|
|
873
|
+
| **Segurança** | Dados sensíveis só para roles específicas |
|
|
874
|
+
| **Personalização** | Diferentes instruções por departamento |
|
|
875
|
+
|
|
876
|
+
### Níveis de Filtragem
|
|
877
|
+
|
|
878
|
+
1. **Agentes**: Habilitar/desabilitar agentes inteiros
|
|
879
|
+
2. **Prompts**: Adicionar seções condicionais aos prompts
|
|
880
|
+
3. **Tools**: Habilitar/desabilitar tools específicas
|
|
881
|
+
|
|
882
|
+
### Exemplo 1: Filtros de Agente (Via Código)
|
|
883
|
+
|
|
884
|
+
```python
|
|
885
|
+
from pathlib import Path
|
|
886
|
+
from atendentepro import (
|
|
887
|
+
create_standard_network,
|
|
888
|
+
UserContext,
|
|
889
|
+
AccessFilter,
|
|
890
|
+
)
|
|
891
|
+
|
|
892
|
+
# Usuário com role de vendedor
|
|
893
|
+
user = UserContext(user_id="vendedor_123", role="vendedor")
|
|
894
|
+
|
|
895
|
+
# Filtros de agente
|
|
896
|
+
agent_filters = {
|
|
897
|
+
# Feedback só para admin
|
|
898
|
+
"feedback": AccessFilter(allowed_roles=["admin"]),
|
|
899
|
+
# Escalation para todos exceto clientes
|
|
900
|
+
"escalation": AccessFilter(denied_roles=["cliente"]),
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
network = create_standard_network(
|
|
904
|
+
templates_root=Path("./meu_cliente"),
|
|
905
|
+
client="config",
|
|
906
|
+
user_context=user,
|
|
907
|
+
agent_filters=agent_filters,
|
|
908
|
+
)
|
|
909
|
+
```
|
|
910
|
+
|
|
911
|
+
### Exemplo 2: Prompts Condicionais
|
|
912
|
+
|
|
913
|
+
Adicione instruções específicas baseadas na role:
|
|
914
|
+
|
|
915
|
+
```python
|
|
916
|
+
from atendentepro import FilteredPromptSection
|
|
917
|
+
|
|
918
|
+
conditional_prompts = {
|
|
919
|
+
"knowledge": [
|
|
920
|
+
# Seção para vendedores
|
|
921
|
+
FilteredPromptSection(
|
|
922
|
+
content="\\n## Descontos\\nVocê pode oferecer até 15% de desconto.",
|
|
923
|
+
filter=AccessFilter(allowed_roles=["vendedor"]),
|
|
924
|
+
),
|
|
925
|
+
# Seção para admin
|
|
926
|
+
FilteredPromptSection(
|
|
927
|
+
content="\\n## Admin\\nVocê tem acesso total ao sistema.",
|
|
928
|
+
filter=AccessFilter(allowed_roles=["admin"]),
|
|
929
|
+
),
|
|
930
|
+
],
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
network = create_standard_network(
|
|
934
|
+
templates_root=Path("./meu_cliente"),
|
|
935
|
+
client="config",
|
|
936
|
+
user_context=user,
|
|
937
|
+
conditional_prompts=conditional_prompts,
|
|
938
|
+
)
|
|
939
|
+
```
|
|
940
|
+
|
|
941
|
+
### Exemplo 3: Tools Filtradas
|
|
942
|
+
|
|
943
|
+
```python
|
|
944
|
+
from atendentepro import FilteredTool
|
|
945
|
+
from agents import function_tool
|
|
946
|
+
|
|
947
|
+
@function_tool
|
|
948
|
+
def deletar_cliente(cliente_id: str) -> str:
|
|
949
|
+
"""Remove um cliente do sistema."""
|
|
950
|
+
return f"Cliente {cliente_id} removido"
|
|
951
|
+
|
|
952
|
+
filtered_tools = {
|
|
953
|
+
"knowledge": [
|
|
954
|
+
FilteredTool(
|
|
955
|
+
tool=deletar_cliente,
|
|
956
|
+
filter=AccessFilter(allowed_roles=["admin"]), # Só admin
|
|
957
|
+
),
|
|
958
|
+
],
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
network = create_standard_network(
|
|
962
|
+
templates_root=Path("./meu_cliente"),
|
|
963
|
+
client="config",
|
|
964
|
+
user_context=user,
|
|
965
|
+
filtered_tools=filtered_tools,
|
|
966
|
+
)
|
|
967
|
+
```
|
|
968
|
+
|
|
969
|
+
### Via YAML (access_config.yaml)
|
|
970
|
+
|
|
971
|
+
```yaml
|
|
972
|
+
# Filtros de agente
|
|
973
|
+
agent_filters:
|
|
974
|
+
feedback:
|
|
975
|
+
allowed_roles: ["admin"]
|
|
976
|
+
escalation:
|
|
977
|
+
denied_roles: ["cliente"]
|
|
978
|
+
|
|
979
|
+
# Prompts condicionais
|
|
980
|
+
conditional_prompts:
|
|
981
|
+
knowledge:
|
|
982
|
+
- content: |
|
|
983
|
+
## Capacidades de Vendedor
|
|
984
|
+
Você pode oferecer até 15% de desconto.
|
|
985
|
+
filter:
|
|
986
|
+
allowed_roles: ["vendedor"]
|
|
987
|
+
|
|
988
|
+
# Acesso a tools
|
|
989
|
+
tool_access:
|
|
990
|
+
deletar_cliente:
|
|
991
|
+
allowed_roles: ["admin"]
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
### Tipos de Filtro
|
|
995
|
+
|
|
996
|
+
| Tipo | Descrição | Exemplo |
|
|
997
|
+
|------|-----------|---------|
|
|
998
|
+
| `allowed_roles` | Whitelist de roles | `["admin", "gerente"]` |
|
|
999
|
+
| `denied_roles` | Blacklist de roles | `["cliente"]` |
|
|
1000
|
+
| `allowed_users` | Whitelist de usuários | `["user_vip_1"]` |
|
|
1001
|
+
| `denied_users` | Blacklist de usuários | `["user_bloqueado"]` |
|
|
1002
|
+
|
|
1003
|
+
### Prioridade de Avaliação
|
|
1004
|
+
|
|
1005
|
+
1. `denied_users` - Se usuário está negado, **bloqueia**
|
|
1006
|
+
2. `allowed_users` - Se lista existe e usuário está nela, **permite**
|
|
1007
|
+
3. `denied_roles` - Se role está negada, **bloqueia**
|
|
1008
|
+
4. `allowed_roles` - Se lista existe e role não está nela, **bloqueia**
|
|
1009
|
+
5. **Permite por padrão** - Se nenhum filtro matched
|
|
1010
|
+
|
|
1011
|
+
### Fluxo Visual
|
|
1012
|
+
|
|
1013
|
+
```
|
|
1014
|
+
┌────────────────────────────────────────────────┐
|
|
1015
|
+
│ Requisição: role="vendedor" │
|
|
1016
|
+
└────────────────────────────────────────────────┘
|
|
1017
|
+
│
|
|
1018
|
+
▼
|
|
1019
|
+
┌────────────────────────────────────────────────┐
|
|
1020
|
+
│ FILTRO DE AGENTES │
|
|
1021
|
+
│ Knowledge: ✅ (vendedor allowed) │
|
|
1022
|
+
│ Escalation: ✅ (vendedor not denied) │
|
|
1023
|
+
│ Feedback: ❌ (only admin) │
|
|
1024
|
+
└────────────────────────────────────────────────┘
|
|
1025
|
+
│
|
|
1026
|
+
▼
|
|
1027
|
+
┌────────────────────────────────────────────────┐
|
|
1028
|
+
│ FILTRO DE PROMPTS │
|
|
1029
|
+
│ Knowledge recebe: "## Descontos..." │
|
|
1030
|
+
│ (seção condicional para vendedor) │
|
|
1031
|
+
└────────────────────────────────────────────────┘
|
|
1032
|
+
│
|
|
1033
|
+
▼
|
|
1034
|
+
┌────────────────────────────────────────────────┐
|
|
1035
|
+
│ FILTRO DE TOOLS │
|
|
1036
|
+
│ consultar_comissao: ✅ │
|
|
1037
|
+
│ deletar_cliente: ❌ (only admin) │
|
|
1038
|
+
└────────────────────────────────────────────────┘
|
|
767
1039
|
```
|
|
768
1040
|
|
|
769
|
-
|
|
1041
|
+
---
|
|
1042
|
+
|
|
1043
|
+
## 🔀 Múltiplos Agentes (Multi Interview + Knowledge)
|
|
1044
|
+
|
|
1045
|
+
O AtendentePro suporta criar **múltiplas instâncias** de Interview e Knowledge agents, cada um especializado em um domínio diferente.
|
|
1046
|
+
|
|
1047
|
+
📂 **Exemplo completo**: [docs/examples/multi_agents/](docs/examples/multi_agents/)
|
|
1048
|
+
|
|
1049
|
+
### Caso de Uso
|
|
770
1050
|
|
|
771
|
-
|
|
1051
|
+
Empresa que atende diferentes tipos de clientes:
|
|
1052
|
+
- **Pessoa Física (PF)**: Produtos de consumo
|
|
1053
|
+
- **Pessoa Jurídica (PJ)**: Soluções empresariais
|
|
772
1054
|
|
|
1055
|
+
### Arquitetura
|
|
1056
|
+
|
|
1057
|
+
```
|
|
1058
|
+
┌─────────────────┐
|
|
1059
|
+
│ Triage │
|
|
1060
|
+
│ (entry point) │
|
|
1061
|
+
└────────┬────────┘
|
|
1062
|
+
│
|
|
1063
|
+
┌──────────────┼──────────────┐
|
|
1064
|
+
│ │ │
|
|
1065
|
+
▼ ▼ ▼
|
|
1066
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
1067
|
+
│ Interview │ │ Interview │ │ Flow │
|
|
1068
|
+
│ PF │ │ PJ │ │ (comum) │
|
|
1069
|
+
└──────┬──────┘ └──────┬──────┘ └─────────────┘
|
|
1070
|
+
│ │
|
|
1071
|
+
▼ ▼
|
|
1072
|
+
┌─────────────┐ ┌─────────────┐
|
|
1073
|
+
│ Knowledge │ │ Knowledge │
|
|
1074
|
+
│ PF │ │ PJ │
|
|
1075
|
+
└─────────────┘ └─────────────┘
|
|
773
1076
|
```
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
1077
|
+
|
|
1078
|
+
### Implementação
|
|
1079
|
+
|
|
1080
|
+
```python
|
|
1081
|
+
from atendentepro import (
|
|
1082
|
+
create_custom_network,
|
|
1083
|
+
create_triage_agent,
|
|
1084
|
+
create_interview_agent,
|
|
1085
|
+
create_knowledge_agent,
|
|
1086
|
+
)
|
|
1087
|
+
|
|
1088
|
+
# 1. Criar agentes especializados
|
|
1089
|
+
interview_pf = create_interview_agent(
|
|
1090
|
+
interview_questions="CPF, data de nascimento, renda mensal",
|
|
1091
|
+
name="interview_pf", # Nome único!
|
|
1092
|
+
)
|
|
1093
|
+
|
|
1094
|
+
interview_pj = create_interview_agent(
|
|
1095
|
+
interview_questions="CNPJ, razão social, faturamento",
|
|
1096
|
+
name="interview_pj", # Nome único!
|
|
1097
|
+
)
|
|
1098
|
+
|
|
1099
|
+
knowledge_pf = create_knowledge_agent(
|
|
1100
|
+
knowledge_about="Produtos para consumidor final",
|
|
1101
|
+
name="knowledge_pf",
|
|
1102
|
+
single_reply=True,
|
|
1103
|
+
)
|
|
1104
|
+
|
|
1105
|
+
knowledge_pj = create_knowledge_agent(
|
|
1106
|
+
knowledge_about="Soluções empresariais B2B",
|
|
1107
|
+
name="knowledge_pj",
|
|
1108
|
+
single_reply=True,
|
|
1109
|
+
)
|
|
1110
|
+
|
|
1111
|
+
# 2. Criar Triage
|
|
1112
|
+
triage = create_triage_agent(
|
|
1113
|
+
keywords_text="PF: CPF, pessoal, minha conta | PJ: CNPJ, empresa, MEI",
|
|
1114
|
+
name="triage_agent",
|
|
1115
|
+
)
|
|
1116
|
+
|
|
1117
|
+
# 3. Configurar handoffs
|
|
1118
|
+
triage.handoffs = [interview_pf, interview_pj, knowledge_pf, knowledge_pj]
|
|
1119
|
+
interview_pf.handoffs = [knowledge_pf, triage]
|
|
1120
|
+
interview_pj.handoffs = [knowledge_pj, triage]
|
|
1121
|
+
knowledge_pf.handoffs = [triage]
|
|
1122
|
+
knowledge_pj.handoffs = [triage]
|
|
1123
|
+
|
|
1124
|
+
# 4. Criar network customizada
|
|
1125
|
+
network = create_custom_network(
|
|
1126
|
+
triage=triage,
|
|
1127
|
+
custom_agents={
|
|
1128
|
+
"interview_pf": interview_pf,
|
|
1129
|
+
"interview_pj": interview_pj,
|
|
1130
|
+
"knowledge_pf": knowledge_pf,
|
|
1131
|
+
"knowledge_pj": knowledge_pj,
|
|
1132
|
+
},
|
|
1133
|
+
)
|
|
779
1134
|
```
|
|
780
1135
|
|
|
781
|
-
|
|
1136
|
+
### Cenários de Roteamento
|
|
1137
|
+
|
|
1138
|
+
| Mensagem do Usuário | Rota |
|
|
1139
|
+
|---------------------|------|
|
|
1140
|
+
| "Quero abrir conta para mim" | Triage → Interview PF → Knowledge PF |
|
|
1141
|
+
| "Preciso de maquininha para minha loja" | Triage → Interview PJ → Knowledge PJ |
|
|
1142
|
+
| "Quanto custa o cartão gold?" | Triage → Knowledge PF (direto) |
|
|
1143
|
+
| "Capital de giro para empresa" | Triage → Knowledge PJ (direto) |
|
|
1144
|
+
|
|
1145
|
+
### Padrão: 1 Interview → 2 Knowledge
|
|
1146
|
+
|
|
1147
|
+
Outro padrão comum é ter um único Interview que pode direcionar para múltiplos Knowledge:
|
|
782
1148
|
|
|
783
1149
|
```
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
1150
|
+
┌───────────────┐
|
|
1151
|
+
│ Interview │
|
|
1152
|
+
│ (coleta dados)│
|
|
1153
|
+
└───────┬───────┘
|
|
1154
|
+
│
|
|
1155
|
+
┌───────┴───────┐
|
|
1156
|
+
▼ ▼
|
|
1157
|
+
┌───────────────┐ ┌───────────────┐
|
|
1158
|
+
│ Knowledge │ │ Knowledge │
|
|
1159
|
+
│ Produtos │ │Troubleshooting│
|
|
1160
|
+
└───────────────┘ └───────────────┘
|
|
1161
|
+
```
|
|
1162
|
+
|
|
1163
|
+
```python
|
|
1164
|
+
# Um interview que direciona para múltiplos knowledge
|
|
1165
|
+
interview.handoffs = [knowledge_produtos, knowledge_troubleshooting, triage]
|
|
789
1166
|
```
|
|
790
1167
|
|
|
1168
|
+
📂 **Exemplo completo**: [example_one_interview_two_knowledge.py](docs/examples/multi_agents/example_one_interview_two_knowledge.py)
|
|
1169
|
+
|
|
1170
|
+
### Dicas
|
|
1171
|
+
|
|
1172
|
+
1. **Nomes únicos**: Cada agente precisa de um `name` distinto
|
|
1173
|
+
2. **Handoffs claros**: Configure quais agentes cada um pode chamar
|
|
1174
|
+
3. **Keywords no Triage**: Inclua palavras-chave para direcionar corretamente
|
|
1175
|
+
4. **single_reply**: Use em Knowledge para evitar loops
|
|
1176
|
+
|
|
791
1177
|
---
|
|
792
1178
|
|
|
793
1179
|
## 📊 Tracing e Monitoramento
|