grkmemory 1.0.0__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.
- grkmemory-1.0.0/LICENSE +21 -0
- grkmemory-1.0.0/PKG-INFO +205 -0
- grkmemory-1.0.0/README.md +164 -0
- grkmemory-1.0.0/grkmemory/__init__.py +83 -0
- grkmemory-1.0.0/grkmemory/auth/__init__.py +14 -0
- grkmemory-1.0.0/grkmemory/auth/auth.py +324 -0
- grkmemory-1.0.0/grkmemory/auth/cli.py +230 -0
- grkmemory-1.0.0/grkmemory/auth/token_manager.py +351 -0
- grkmemory-1.0.0/grkmemory/core/__init__.py +10 -0
- grkmemory-1.0.0/grkmemory/core/agent.py +232 -0
- grkmemory-1.0.0/grkmemory/core/config.py +92 -0
- grkmemory-1.0.0/grkmemory/core/grkmemory.py +278 -0
- grkmemory-1.0.0/grkmemory/graph/__init__.py +5 -0
- grkmemory-1.0.0/grkmemory/graph/semantic_graph.py +274 -0
- grkmemory-1.0.0/grkmemory/memory/__init__.py +5 -0
- grkmemory-1.0.0/grkmemory/memory/repository.py +413 -0
- grkmemory-1.0.0/grkmemory/py.typed +2 -0
- grkmemory-1.0.0/grkmemory/utils/__init__.py +6 -0
- grkmemory-1.0.0/grkmemory/utils/embeddings.py +118 -0
- grkmemory-1.0.0/grkmemory/utils/text.py +168 -0
- grkmemory-1.0.0/grkmemory.egg-info/PKG-INFO +205 -0
- grkmemory-1.0.0/grkmemory.egg-info/SOURCES.txt +27 -0
- grkmemory-1.0.0/grkmemory.egg-info/dependency_links.txt +1 -0
- grkmemory-1.0.0/grkmemory.egg-info/entry_points.txt +2 -0
- grkmemory-1.0.0/grkmemory.egg-info/requires.txt +16 -0
- grkmemory-1.0.0/grkmemory.egg-info/top_level.txt +1 -0
- grkmemory-1.0.0/pyproject.toml +94 -0
- grkmemory-1.0.0/setup.cfg +4 -0
- grkmemory-1.0.0/setup.py +11 -0
grkmemory-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Arthur Vaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
grkmemory-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: grkmemory
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: GRKMemory (Graph Retrieve Knowledge Memory) - A semantic graph-based memory system for AI agents developed by MonkAI team
|
|
5
|
+
Author-email: Arthur Vaz <contato@monkai.com.br>
|
|
6
|
+
Maintainer-email: Arthur Vaz <contato@monkai.com.br>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/BeMonkAI/GRKMemory
|
|
9
|
+
Project-URL: Documentation, https://github.com/BeMonkAI/GRKMemory#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/BeMonkAI/GRKMemory
|
|
11
|
+
Project-URL: Issues, https://github.com/BeMonkAI/GRKMemory/issues
|
|
12
|
+
Keywords: grkmemory,monkai,ai,agents,memory,semantic-graph,knowledge-retrieval,openai,llm,chatgpt,conversational-ai,machine-learning
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Operating System :: OS Independent
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: openai>=1.0.0
|
|
28
|
+
Requires-Dist: openai-agents>=0.6.0
|
|
29
|
+
Requires-Dist: pydantic>=2.0.0
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
35
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
36
|
+
Provides-Extra: embeddings
|
|
37
|
+
Requires-Dist: tiktoken>=0.5.0; extra == "embeddings"
|
|
38
|
+
Provides-Extra: all
|
|
39
|
+
Requires-Dist: grkmemory[dev,embeddings]; extra == "all"
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# 🧠 GRKMemory - Graph Retrieve Knowledge Memory
|
|
43
|
+
|
|
44
|
+
> **GRKMemory** = **G**raph **R**etrieve **K**nowledge **Memory**
|
|
45
|
+
|
|
46
|
+
[](https://badge.fury.io/py/grkmemory)
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
[](https://opensource.org/licenses/MIT)
|
|
49
|
+
|
|
50
|
+
**GRKMemory** é um sistema de memória semântica baseado em grafos para agentes de IA, desenvolvido pelo time **MonkAI**. Recuperação inteligente de conhecimento com economia de 95% em tokens.
|
|
51
|
+
|
|
52
|
+
## 🚀 Instalação
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install grkmemory
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Para token counting:
|
|
59
|
+
```bash
|
|
60
|
+
pip install grkmemory[embeddings]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 🎯 Quick Start
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from grkmemory import GRKMemory
|
|
67
|
+
|
|
68
|
+
# Inicializar (usa OPENAI_API_KEY do ambiente)
|
|
69
|
+
grk = GRKMemory()
|
|
70
|
+
|
|
71
|
+
# Buscar memórias relevantes
|
|
72
|
+
results = grk.search("O que discutimos sobre IA?")
|
|
73
|
+
|
|
74
|
+
# Chat com contexto de memória automático
|
|
75
|
+
response = grk.chat("Me conte sobre nossas discussões anteriores")
|
|
76
|
+
|
|
77
|
+
# Salvar uma conversa
|
|
78
|
+
grk.save_conversation([
|
|
79
|
+
{"role": "user", "content": "Vamos falar sobre Python"},
|
|
80
|
+
{"role": "assistant", "content": "Claro! O que você quer saber?"}
|
|
81
|
+
])
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## ⚙️ Configuração
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from grkmemory import GRKMemory, MemoryConfig
|
|
88
|
+
|
|
89
|
+
config = MemoryConfig(
|
|
90
|
+
model="gpt-4o",
|
|
91
|
+
memory_file="minhas_memorias.json",
|
|
92
|
+
enable_embeddings=True,
|
|
93
|
+
background_memory_method="graph", # 'graph', 'embedding', 'tags', 'entities'
|
|
94
|
+
background_memory_limit=5,
|
|
95
|
+
background_memory_threshold=0.3
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
grk = GRKMemory(config=config)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## 🔐 Autenticação por Token
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from grkmemory import GRKMemory, GRKAuth, AuthenticatedGRK
|
|
105
|
+
|
|
106
|
+
# Criar API key
|
|
107
|
+
auth = GRKAuth()
|
|
108
|
+
api_key = auth.create_api_key("Minha App", permissions=["read", "write"])
|
|
109
|
+
|
|
110
|
+
# Usar GRKMemory protegido
|
|
111
|
+
grk = GRKMemory()
|
|
112
|
+
secure = AuthenticatedGRK(grk, api_key)
|
|
113
|
+
secure.chat("Olá!")
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### CLI para Tokens
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# Criar token
|
|
120
|
+
grkmemory-token create --name "Meu App" --expires 30
|
|
121
|
+
|
|
122
|
+
# Listar tokens
|
|
123
|
+
grkmemory-token list
|
|
124
|
+
|
|
125
|
+
# Revogar token
|
|
126
|
+
grkmemory-token revoke tok_abc123
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## 📊 Métodos de Busca
|
|
130
|
+
|
|
131
|
+
| Método | Descrição |
|
|
132
|
+
|--------|-----------|
|
|
133
|
+
| `graph` | Grafo semântico (recomendado) |
|
|
134
|
+
| `embedding` | Similaridade vetorial |
|
|
135
|
+
| `tags` | Busca por tags |
|
|
136
|
+
| `entities` | Busca por entidades |
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
# Busca por grafo semântico
|
|
140
|
+
results = grk.search("IA", method="graph")
|
|
141
|
+
|
|
142
|
+
# Busca por embedding
|
|
143
|
+
results = grk.search("machine learning", method="embedding")
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## 📈 Estatísticas
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
# Estatísticas gerais
|
|
150
|
+
stats = grk.get_stats()
|
|
151
|
+
print(f"Total de memórias: {stats['total_memories']}")
|
|
152
|
+
|
|
153
|
+
# Estatísticas do grafo
|
|
154
|
+
graph_stats = grk.get_graph_stats()
|
|
155
|
+
print(f"Nós: {graph_stats['total_nodes']}")
|
|
156
|
+
print(f"Arestas: {graph_stats['total_edges']}")
|
|
157
|
+
|
|
158
|
+
# Top memórias
|
|
159
|
+
top = grk.get_top_memories(limit=5, by="density")
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## 📁 Estrutura do Projeto
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
GRKMemory/
|
|
166
|
+
├── grkmemory/ # 📦 Pacote principal
|
|
167
|
+
│ ├── core/ # Classes principais (GRKMemory, Config, Agent)
|
|
168
|
+
│ ├── memory/ # Repositório de memória
|
|
169
|
+
│ ├── graph/ # Grafo semântico (GRK)
|
|
170
|
+
│ ├── auth/ # Autenticação por token
|
|
171
|
+
│ └── utils/ # Utilitários (embeddings, text)
|
|
172
|
+
├── examples/ # 💡 Exemplos de uso
|
|
173
|
+
├── demos/ # 🎮 Demos legados
|
|
174
|
+
├── papers/ # 📄 Documentação técnica
|
|
175
|
+
├── pyproject.toml # Configuração PyPI
|
|
176
|
+
└── README.md
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 📚 Exemplos
|
|
180
|
+
|
|
181
|
+
Veja a pasta `examples/` para exemplos completos:
|
|
182
|
+
|
|
183
|
+
- `01_basic_usage.py` - Uso básico
|
|
184
|
+
- `02_custom_config.py` - Configuração personalizada
|
|
185
|
+
- `03_chatbot_with_memory.py` - Chatbot com memória
|
|
186
|
+
- `04_graph_analysis.py` - Análise do grafo
|
|
187
|
+
- `05_batch_processing.py` - Processamento em lote
|
|
188
|
+
- `06_authentication.py` - Autenticação por token
|
|
189
|
+
|
|
190
|
+
## 🔬 Performance
|
|
191
|
+
|
|
192
|
+
| Métrica | Context Window | GRKMemory |
|
|
193
|
+
|---------|----------------|-----------|
|
|
194
|
+
| Tokens/query | ~50.000 | ~2.500 |
|
|
195
|
+
| Economia | - | **95%** |
|
|
196
|
+
| Precisão | Variável | **95%** |
|
|
197
|
+
| Velocidade | Lenta | **10x mais rápido** |
|
|
198
|
+
|
|
199
|
+
## 📄 Licença
|
|
200
|
+
|
|
201
|
+
MIT License - veja [LICENSE](LICENSE)
|
|
202
|
+
|
|
203
|
+
## 👨💻 Autor
|
|
204
|
+
|
|
205
|
+
**Arthur Vaz** - [MonkAI](https://www.monkai.com.br)
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# 🧠 GRKMemory - Graph Retrieve Knowledge Memory
|
|
2
|
+
|
|
3
|
+
> **GRKMemory** = **G**raph **R**etrieve **K**nowledge **Memory**
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/py/grkmemory)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
**GRKMemory** é um sistema de memória semântica baseado em grafos para agentes de IA, desenvolvido pelo time **MonkAI**. Recuperação inteligente de conhecimento com economia de 95% em tokens.
|
|
10
|
+
|
|
11
|
+
## 🚀 Instalação
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install grkmemory
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Para token counting:
|
|
18
|
+
```bash
|
|
19
|
+
pip install grkmemory[embeddings]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 🎯 Quick Start
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from grkmemory import GRKMemory
|
|
26
|
+
|
|
27
|
+
# Inicializar (usa OPENAI_API_KEY do ambiente)
|
|
28
|
+
grk = GRKMemory()
|
|
29
|
+
|
|
30
|
+
# Buscar memórias relevantes
|
|
31
|
+
results = grk.search("O que discutimos sobre IA?")
|
|
32
|
+
|
|
33
|
+
# Chat com contexto de memória automático
|
|
34
|
+
response = grk.chat("Me conte sobre nossas discussões anteriores")
|
|
35
|
+
|
|
36
|
+
# Salvar uma conversa
|
|
37
|
+
grk.save_conversation([
|
|
38
|
+
{"role": "user", "content": "Vamos falar sobre Python"},
|
|
39
|
+
{"role": "assistant", "content": "Claro! O que você quer saber?"}
|
|
40
|
+
])
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## ⚙️ Configuração
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from grkmemory import GRKMemory, MemoryConfig
|
|
47
|
+
|
|
48
|
+
config = MemoryConfig(
|
|
49
|
+
model="gpt-4o",
|
|
50
|
+
memory_file="minhas_memorias.json",
|
|
51
|
+
enable_embeddings=True,
|
|
52
|
+
background_memory_method="graph", # 'graph', 'embedding', 'tags', 'entities'
|
|
53
|
+
background_memory_limit=5,
|
|
54
|
+
background_memory_threshold=0.3
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
grk = GRKMemory(config=config)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 🔐 Autenticação por Token
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from grkmemory import GRKMemory, GRKAuth, AuthenticatedGRK
|
|
64
|
+
|
|
65
|
+
# Criar API key
|
|
66
|
+
auth = GRKAuth()
|
|
67
|
+
api_key = auth.create_api_key("Minha App", permissions=["read", "write"])
|
|
68
|
+
|
|
69
|
+
# Usar GRKMemory protegido
|
|
70
|
+
grk = GRKMemory()
|
|
71
|
+
secure = AuthenticatedGRK(grk, api_key)
|
|
72
|
+
secure.chat("Olá!")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### CLI para Tokens
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Criar token
|
|
79
|
+
grkmemory-token create --name "Meu App" --expires 30
|
|
80
|
+
|
|
81
|
+
# Listar tokens
|
|
82
|
+
grkmemory-token list
|
|
83
|
+
|
|
84
|
+
# Revogar token
|
|
85
|
+
grkmemory-token revoke tok_abc123
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 📊 Métodos de Busca
|
|
89
|
+
|
|
90
|
+
| Método | Descrição |
|
|
91
|
+
|--------|-----------|
|
|
92
|
+
| `graph` | Grafo semântico (recomendado) |
|
|
93
|
+
| `embedding` | Similaridade vetorial |
|
|
94
|
+
| `tags` | Busca por tags |
|
|
95
|
+
| `entities` | Busca por entidades |
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
# Busca por grafo semântico
|
|
99
|
+
results = grk.search("IA", method="graph")
|
|
100
|
+
|
|
101
|
+
# Busca por embedding
|
|
102
|
+
results = grk.search("machine learning", method="embedding")
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## 📈 Estatísticas
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
# Estatísticas gerais
|
|
109
|
+
stats = grk.get_stats()
|
|
110
|
+
print(f"Total de memórias: {stats['total_memories']}")
|
|
111
|
+
|
|
112
|
+
# Estatísticas do grafo
|
|
113
|
+
graph_stats = grk.get_graph_stats()
|
|
114
|
+
print(f"Nós: {graph_stats['total_nodes']}")
|
|
115
|
+
print(f"Arestas: {graph_stats['total_edges']}")
|
|
116
|
+
|
|
117
|
+
# Top memórias
|
|
118
|
+
top = grk.get_top_memories(limit=5, by="density")
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 📁 Estrutura do Projeto
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
GRKMemory/
|
|
125
|
+
├── grkmemory/ # 📦 Pacote principal
|
|
126
|
+
│ ├── core/ # Classes principais (GRKMemory, Config, Agent)
|
|
127
|
+
│ ├── memory/ # Repositório de memória
|
|
128
|
+
│ ├── graph/ # Grafo semântico (GRK)
|
|
129
|
+
│ ├── auth/ # Autenticação por token
|
|
130
|
+
│ └── utils/ # Utilitários (embeddings, text)
|
|
131
|
+
├── examples/ # 💡 Exemplos de uso
|
|
132
|
+
├── demos/ # 🎮 Demos legados
|
|
133
|
+
├── papers/ # 📄 Documentação técnica
|
|
134
|
+
├── pyproject.toml # Configuração PyPI
|
|
135
|
+
└── README.md
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## 📚 Exemplos
|
|
139
|
+
|
|
140
|
+
Veja a pasta `examples/` para exemplos completos:
|
|
141
|
+
|
|
142
|
+
- `01_basic_usage.py` - Uso básico
|
|
143
|
+
- `02_custom_config.py` - Configuração personalizada
|
|
144
|
+
- `03_chatbot_with_memory.py` - Chatbot com memória
|
|
145
|
+
- `04_graph_analysis.py` - Análise do grafo
|
|
146
|
+
- `05_batch_processing.py` - Processamento em lote
|
|
147
|
+
- `06_authentication.py` - Autenticação por token
|
|
148
|
+
|
|
149
|
+
## 🔬 Performance
|
|
150
|
+
|
|
151
|
+
| Métrica | Context Window | GRKMemory |
|
|
152
|
+
|---------|----------------|-----------|
|
|
153
|
+
| Tokens/query | ~50.000 | ~2.500 |
|
|
154
|
+
| Economia | - | **95%** |
|
|
155
|
+
| Precisão | Variável | **95%** |
|
|
156
|
+
| Velocidade | Lenta | **10x mais rápido** |
|
|
157
|
+
|
|
158
|
+
## 📄 Licença
|
|
159
|
+
|
|
160
|
+
MIT License - veja [LICENSE](LICENSE)
|
|
161
|
+
|
|
162
|
+
## 👨💻 Autor
|
|
163
|
+
|
|
164
|
+
**Arthur Vaz** - [MonkAI](https://www.monkai.com.br)
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"""
|
|
2
|
+
GRKMemory - Graph Retrieve Knowledge Memory
|
|
3
|
+
============================================
|
|
4
|
+
|
|
5
|
+
GRKMemory = Graph Retrieve Knowledge Memory
|
|
6
|
+
|
|
7
|
+
A semantic graph-based memory system for AI agents that enables
|
|
8
|
+
intelligent knowledge retrieval and structured conversation analysis.
|
|
9
|
+
|
|
10
|
+
Developed by MonkAI team (https://www.monkai.com.br)
|
|
11
|
+
|
|
12
|
+
Example usage:
|
|
13
|
+
from grkmemory import GRKMemory, MemoryConfig
|
|
14
|
+
|
|
15
|
+
# Initialize with default config
|
|
16
|
+
grk = GRKMemory()
|
|
17
|
+
|
|
18
|
+
# Or with custom configuration
|
|
19
|
+
config = MemoryConfig(
|
|
20
|
+
memory_file="my_memories.json",
|
|
21
|
+
model="gpt-4o",
|
|
22
|
+
enable_embeddings=True
|
|
23
|
+
)
|
|
24
|
+
grk = GRKMemory(config=config)
|
|
25
|
+
|
|
26
|
+
# Search memories
|
|
27
|
+
results = grk.search("What did we discuss about AI?")
|
|
28
|
+
|
|
29
|
+
# Save a conversation
|
|
30
|
+
grk.save_conversation(messages)
|
|
31
|
+
|
|
32
|
+
Authentication Example:
|
|
33
|
+
from grkmemory import GRKMemory, GRKAuth, AuthenticatedGRK
|
|
34
|
+
|
|
35
|
+
# Create an API key
|
|
36
|
+
auth = GRKAuth()
|
|
37
|
+
api_key = auth.create_api_key("My App", permissions=["read", "write"])
|
|
38
|
+
print(f"Your API key: {api_key}")
|
|
39
|
+
|
|
40
|
+
# Use authenticated GRKMemory
|
|
41
|
+
grk = GRKMemory()
|
|
42
|
+
secure_grk = AuthenticatedGRK(grk, api_key)
|
|
43
|
+
secure_grk.chat("Hello!")
|
|
44
|
+
|
|
45
|
+
Author: Arthur Vaz
|
|
46
|
+
License: MIT
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
__version__ = "1.0.0"
|
|
50
|
+
__author__ = "Arthur Vaz"
|
|
51
|
+
|
|
52
|
+
from .core.grkmemory import GRKMemory
|
|
53
|
+
from .core.config import MemoryConfig
|
|
54
|
+
from .memory.repository import MemoryRepository
|
|
55
|
+
from .graph.semantic_graph import SemanticGraph
|
|
56
|
+
from .core.agent import KnowledgeAgent
|
|
57
|
+
from .auth.token_manager import TokenManager, Token
|
|
58
|
+
from .auth.auth import GRKAuth, AuthenticatedGRK, require_auth
|
|
59
|
+
|
|
60
|
+
# Aliases for backwards compatibility
|
|
61
|
+
MonkAI = GRKMemory
|
|
62
|
+
MonkAIAuth = GRKAuth
|
|
63
|
+
AuthenticatedMonkAI = AuthenticatedGRK
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
# Core
|
|
67
|
+
"GRKMemory",
|
|
68
|
+
"MonkAI", # alias
|
|
69
|
+
"MemoryConfig",
|
|
70
|
+
"MemoryRepository",
|
|
71
|
+
"SemanticGraph",
|
|
72
|
+
"KnowledgeAgent",
|
|
73
|
+
# Auth
|
|
74
|
+
"TokenManager",
|
|
75
|
+
"Token",
|
|
76
|
+
"GRKAuth",
|
|
77
|
+
"MonkAIAuth", # alias
|
|
78
|
+
"AuthenticatedGRK",
|
|
79
|
+
"AuthenticatedMonkAI", # alias
|
|
80
|
+
"require_auth",
|
|
81
|
+
# Meta
|
|
82
|
+
"__version__",
|
|
83
|
+
]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Authentication module for GRKMemory.
|
|
3
|
+
|
|
4
|
+
Provides token-based authentication for API access.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .token_manager import TokenManager, Token
|
|
8
|
+
from .auth import GRKAuth, AuthenticatedGRK, require_auth
|
|
9
|
+
|
|
10
|
+
# Alias for backwards compatibility
|
|
11
|
+
MonkAIAuth = GRKAuth
|
|
12
|
+
AuthenticatedMonkAI = AuthenticatedGRK
|
|
13
|
+
|
|
14
|
+
__all__ = ["TokenManager", "Token", "GRKAuth", "MonkAIAuth", "AuthenticatedGRK", "AuthenticatedMonkAI", "require_auth"]
|