neuroagent 1.3.0
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.
- package/LICENSE +21 -0
- package/README.md +273 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.js +215 -0
- package/neuroagent/__init__.py +29 -0
- package/neuroagent/agents/__init__.py +3 -0
- package/neuroagent/agents/agent.py +253 -0
- package/neuroagent/cli/__init__.py +3 -0
- package/neuroagent/cli/neuroagent_cli.py +182 -0
- package/neuroagent/examples/__init__.py +1 -0
- package/neuroagent/examples/dev_agent.py +31 -0
- package/neuroagent/examples/multi_agent_team.py +45 -0
- package/neuroagent/examples/website_agent.py +27 -0
- package/neuroagent/frontend/__init__.py +1 -0
- package/neuroagent/frontend/widget.js +409 -0
- package/neuroagent/llm/__init__.py +5 -0
- package/neuroagent/llm/base.py +46 -0
- package/neuroagent/llm/local_model_provider.py +76 -0
- package/neuroagent/llm/openai_provider.py +58 -0
- package/neuroagent/memory/__init__.py +5 -0
- package/neuroagent/memory/long_memory.py +52 -0
- package/neuroagent/memory/short_memory.py +39 -0
- package/neuroagent/memory/vector_memory.py +57 -0
- package/neuroagent/planner/__init__.py +3 -0
- package/neuroagent/planner/planner.py +90 -0
- package/neuroagent/server/__init__.py +16 -0
- package/neuroagent/server/api_server.py +191 -0
- package/neuroagent/server/websocket_server.py +108 -0
- package/neuroagent/team/__init__.py +3 -0
- package/neuroagent/team/team.py +134 -0
- package/neuroagent/tools/__init__.py +19 -0
- package/neuroagent/tools/base.py +45 -0
- package/neuroagent/tools/code_executor.py +69 -0
- package/neuroagent/tools/file_manager.py +62 -0
- package/neuroagent/tools/http_client.py +57 -0
- package/neuroagent/tools/web_search.py +48 -0
- package/neuroagent/utils/__init__.py +3 -0
- package/neuroagent/utils/helpers.py +31 -0
- package/package.json +56 -0
- package/requirements.txt +15 -0
- package/setup.py +61 -0
- package/src/index.d.ts +55 -0
- package/src/index.js +215 -0
- package/web_example/index.html +249 -0
- package/web_example/neuroagent.js +301 -0
- package/web_example/script.js +114 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 NeuroAgent Team
|
|
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.
|
package/README.md
ADDED
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# NeuroAgent
|
|
2
|
+
|
|
3
|
+
Framework moderno, modular e simples para criar agentes de IA inteligentes com poucas linhas de código.
|
|
4
|
+
|
|
5
|
+
## Recursos
|
|
6
|
+
|
|
7
|
+
- **Criação Fácil de Agentes**: Crie agentes de IA com apenas algumas linhas de código
|
|
8
|
+
- **Equipes Multi-Agentes**: Múltiplos agentes podem trabalhar juntos em tarefas complexas
|
|
9
|
+
- **Sistema de Ferramentas**: Ferramentas integradas para busca na web, execução de código, gerenciamento de arquivos e requisições HTTP
|
|
10
|
+
- **Sistema de Memória**: Memória de curto prazo, longo prazo e vetorial para contexto
|
|
11
|
+
- **Planejamento**: Decomposição automática de tarefas e planejamento
|
|
12
|
+
- **Múltiplos Provedores de LLM**: Suporte para OpenAI, Anthropic e modelos locais
|
|
13
|
+
- **Servidor FastAPI**: API REST para gerenciamento de agentes
|
|
14
|
+
- **Suporte WebSocket**: Comunicação em tempo real
|
|
15
|
+
- **Widget JavaScript**: Integração fácil com sites
|
|
16
|
+
|
|
17
|
+
## Instalação
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install neuroagent
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Uso Rápido
|
|
24
|
+
|
|
25
|
+
### JavaScript/TypeScript
|
|
26
|
+
|
|
27
|
+
```javascript
|
|
28
|
+
const { NeuroAgentClient, NeuroAgentWidget } = require('neuroagent');
|
|
29
|
+
|
|
30
|
+
// Ou com ES modules
|
|
31
|
+
import { NeuroAgentClient, NeuroAgentWidget } from 'neuroagent';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Usando o Widget
|
|
35
|
+
|
|
36
|
+
```javascript
|
|
37
|
+
const widget = new NeuroAgentWidget({
|
|
38
|
+
apiUrl: 'http://localhost:8000',
|
|
39
|
+
agent: 'SupportAgent',
|
|
40
|
+
title: 'Assistente de IA',
|
|
41
|
+
position: 'bottom-right'
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Usando o Cliente
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
const client = new NeuroAgentClient({
|
|
49
|
+
apiUrl: 'http://localhost:8000',
|
|
50
|
+
agent: 'MyAgent'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Chat com agente
|
|
54
|
+
const response = await client.chat('Olá, como você está?');
|
|
55
|
+
console.log(response);
|
|
56
|
+
|
|
57
|
+
// Executar tarefa do agente
|
|
58
|
+
const result = await client.run('Criar um app todo');
|
|
59
|
+
console.log(result);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Usando o Widget (CDN)
|
|
63
|
+
|
|
64
|
+
Adicione isso ao seu HTML:
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<script src="https://cdn.neuroagent.ai/neuroagent.min.js"></script>
|
|
68
|
+
<script>
|
|
69
|
+
NeuroAgent.init({
|
|
70
|
+
apiUrl: "http://localhost:8000",
|
|
71
|
+
agent: "SupportAgent",
|
|
72
|
+
title: "Assistente de IA"
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Python (Backend)
|
|
78
|
+
|
|
79
|
+
O pacote também inclui o framework Python completo:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
pip install -r requirements.txt
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Criando Agentes
|
|
86
|
+
|
|
87
|
+
```python
|
|
88
|
+
from neuroagent import Agent
|
|
89
|
+
|
|
90
|
+
agent = Agent(
|
|
91
|
+
name="MeuAgente",
|
|
92
|
+
goal="Ajudar usuários com suas perguntas"
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
result = await agent.run("O que é NeuroAgent?")
|
|
96
|
+
print(result)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Agente com Ferramentas
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
agent = Agent(
|
|
103
|
+
name="DevAgent",
|
|
104
|
+
goal="Criar aplicações e escrever código"
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
agent.add_tool("web_search")
|
|
108
|
+
agent.add_tool("code_executor")
|
|
109
|
+
agent.add_tool("file_manager")
|
|
110
|
+
|
|
111
|
+
result = await agent.run("Criar um app web Python")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Ferramentas Personalizadas
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
from neuroagent.tools import tool
|
|
118
|
+
|
|
119
|
+
@tool(name="my_tool", description="Descrição da minha ferramenta")
|
|
120
|
+
def minha_ferramenta(param: str):
|
|
121
|
+
return f"Resultado: {param}"
|
|
122
|
+
|
|
123
|
+
agent.register_tool(minha_ferramenta)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Sistema de Memória
|
|
127
|
+
|
|
128
|
+
O NeuroAgent suporta três tipos de memória:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
agent = Agent(
|
|
132
|
+
name="MeuAgente",
|
|
133
|
+
goal="Meu objetivo",
|
|
134
|
+
enable_short_memory=True, # Histórico da conversa
|
|
135
|
+
enable_long_memory=True, # Armazenamento persistente
|
|
136
|
+
enable_vector_memory=True # Busca semântica
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
agent.save_memory("Info importante", memory_type="short")
|
|
140
|
+
agent.save_memory("Preferência do usuário", memory_type="long")
|
|
141
|
+
agent.save_memory("Contexto", memory_type="vector")
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Equipes Multi-Agentes
|
|
145
|
+
|
|
146
|
+
```python
|
|
147
|
+
from neuroagent import Agent, Team
|
|
148
|
+
|
|
149
|
+
researcher = Agent(name="Researcher", goal="Pesquisar tópicos")
|
|
150
|
+
developer = Agent(name="Developer", goal="Escrever código")
|
|
151
|
+
deployer = Agent(name="Deployer", goal="Implantar aplicações")
|
|
152
|
+
|
|
153
|
+
team = Team(name="SaaSTeam", goal="Criar apps SaaS")
|
|
154
|
+
team.add_agent(researcher)
|
|
155
|
+
team.add_agent(developer)
|
|
156
|
+
team.add_agent(deployer)
|
|
157
|
+
|
|
158
|
+
result = await team.run("Criar um app de gerenciamento de tarefas")
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Servidor API
|
|
162
|
+
|
|
163
|
+
Inicie o servidor API:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
neuroagent start-server
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Ou programaticamente:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
import uvicorn
|
|
173
|
+
from neuroagent.server.api_server import app
|
|
174
|
+
|
|
175
|
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Endpoints da API
|
|
179
|
+
|
|
180
|
+
- `GET /agents` - Listar todos os agentes
|
|
181
|
+
- `POST /agents` - Criar um agente
|
|
182
|
+
- `POST /agent/run` - Executar um agente com uma tarefa
|
|
183
|
+
- `POST /agent/chat` - Conversar com um agente
|
|
184
|
+
- `GET /teams` - Listar todas as equipes
|
|
185
|
+
- `POST /teams` - Criar uma equipe
|
|
186
|
+
- `POST /team/run` - Executar uma equipe
|
|
187
|
+
|
|
188
|
+
### Exemplo de Uso da API
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
curl -X POST http://localhost:8000/agent/run \
|
|
192
|
+
-H "Content-Type: application/json" \
|
|
193
|
+
-d '{
|
|
194
|
+
"agent": "MyAgent",
|
|
195
|
+
"message": "Olá!"
|
|
196
|
+
}'
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Integração com Website
|
|
200
|
+
|
|
201
|
+
Adicione o widget ao seu site:
|
|
202
|
+
|
|
203
|
+
```html
|
|
204
|
+
<script src="https://cdn.neuroagent.ai/neuroagent.min.js"></script>
|
|
205
|
+
<script>
|
|
206
|
+
NeuroAgent.init({
|
|
207
|
+
apiUrl: "http://localhost:8000",
|
|
208
|
+
agent: "SupportAgent",
|
|
209
|
+
title: "Assistente de IA",
|
|
210
|
+
position: "bottom-right"
|
|
211
|
+
});
|
|
212
|
+
</script>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Comandos da CLI
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Iniciar um novo projeto
|
|
219
|
+
neuroagent init meu-projeto
|
|
220
|
+
|
|
221
|
+
# Criar um agente
|
|
222
|
+
neuroagent create-agent MeuAgente --goal "Ajudar usuários"
|
|
223
|
+
|
|
224
|
+
# Iniciar o servidor
|
|
225
|
+
neuroagent start-server --port 8000
|
|
226
|
+
|
|
227
|
+
# Listar ferramentas disponíveis
|
|
228
|
+
neuroagent list-agents
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Configuração
|
|
232
|
+
|
|
233
|
+
Crie um arquivo `.env`:
|
|
234
|
+
|
|
235
|
+
```env
|
|
236
|
+
OPENAI_API_KEY=sua-api-key-aqui
|
|
237
|
+
ANTHROPIC_API_KEY=sua-anthropic-key
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Exemplos
|
|
241
|
+
|
|
242
|
+
Veja o diretório `examples/` para mais exemplos:
|
|
243
|
+
|
|
244
|
+
- `website_agent.py` - Exemplo de chatbot para site
|
|
245
|
+
- `dev_agent.py` - Exemplo de assistente para desenvolvedores
|
|
246
|
+
- `multi_agent_team.py` - Colaboração multi-agente
|
|
247
|
+
|
|
248
|
+
## Arquitetura
|
|
249
|
+
|
|
250
|
+
```
|
|
251
|
+
neuroagent/
|
|
252
|
+
├── agents/ # Implementação do agente
|
|
253
|
+
├── memory/ # Sistemas de memória (short, long, vector)
|
|
254
|
+
├── tools/ # Ferramentas integradas
|
|
255
|
+
├── planner/ # Planejamento de tarefas
|
|
256
|
+
├── llm/ # Provedores de LLM
|
|
257
|
+
├── team/ # Equipes multi-agentes
|
|
258
|
+
├── server/ # Servidores API e WebSocket
|
|
259
|
+
├── cli/ # Interface de linha de comando
|
|
260
|
+
├── frontend/ # Widget JavaScript
|
|
261
|
+
└── utils/ # Utilitários
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Opções de Posição do Widget
|
|
265
|
+
|
|
266
|
+
- `bottom-right` (padrão)
|
|
267
|
+
- `bottom-left`
|
|
268
|
+
- `top-right`
|
|
269
|
+
- `top-left`
|
|
270
|
+
|
|
271
|
+
## Licença
|
|
272
|
+
|
|
273
|
+
MIT License
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface NeuroAgentConfig {
|
|
2
|
+
apiUrl?: string;
|
|
3
|
+
agent?: string;
|
|
4
|
+
apiKey?: string;
|
|
5
|
+
theme?: 'light' | 'dark';
|
|
6
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
7
|
+
title?: string;
|
|
8
|
+
welcomeMessage?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ChatResponse {
|
|
12
|
+
response: string;
|
|
13
|
+
agent: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AgentList {
|
|
17
|
+
agents: string[];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AgentRequest {
|
|
21
|
+
name: string;
|
|
22
|
+
goal: string;
|
|
23
|
+
model?: string;
|
|
24
|
+
apiKey?: string;
|
|
25
|
+
enablePlanning?: boolean;
|
|
26
|
+
tools?: string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare class NeuroAgentClient {
|
|
30
|
+
constructor(config: NeuroAgentConfig);
|
|
31
|
+
chat(message: string): Promise<ChatResponse>;
|
|
32
|
+
run(task: string): Promise<ChatResponse>;
|
|
33
|
+
createAgent(config: AgentRequest): Promise<any>;
|
|
34
|
+
listAgents(): Promise<AgentList>;
|
|
35
|
+
onWebSocket(event: 'open' | 'message' | 'error' | 'close', callback: (data?: any) => void): WebSocket;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export declare class NeuroAgentWidget {
|
|
39
|
+
constructor(config: NeuroAgentConfig);
|
|
40
|
+
open(): void;
|
|
41
|
+
close(): void;
|
|
42
|
+
toggle(): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface NeuroAgentInit {
|
|
46
|
+
init(config: NeuroAgentConfig): NeuroAgentWidget;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare const NeuroAgent: {
|
|
50
|
+
init(config: NeuroAgentConfig): NeuroAgentWidget;
|
|
51
|
+
Client: typeof NeuroAgentClient;
|
|
52
|
+
Widget: typeof NeuroAgentWidget;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default NeuroAgent;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NeuroAgent - Modern AI Agent Framework
|
|
3
|
+
* JavaScript/TypeScript Client
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const API_URL = 'http://localhost:8000';
|
|
7
|
+
|
|
8
|
+
class NeuroAgentClient {
|
|
9
|
+
constructor(config = {}) {
|
|
10
|
+
this.apiUrl = config.apiUrl || API_URL;
|
|
11
|
+
this.agent = config.agent || 'default';
|
|
12
|
+
this.apiKey = config.apiKey || null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async request(endpoint, data) {
|
|
16
|
+
const headers = {
|
|
17
|
+
'Content-Type': 'application/json'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
if (this.apiKey) {
|
|
21
|
+
headers['Authorization'] = `Bearer ${this.apiKey}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const response = await fetch(`${this.apiUrl}${endpoint}`, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
headers,
|
|
27
|
+
body: JSON.stringify({
|
|
28
|
+
agent: this.agent,
|
|
29
|
+
...data
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
return response.json();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async chat(message) {
|
|
37
|
+
return this.request('/agent/chat', { message });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async run(task) {
|
|
41
|
+
return this.request('/agent/run', { message: task });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async createAgent(config) {
|
|
45
|
+
const response = await fetch(`${this.apiUrl}/agents`, {
|
|
46
|
+
method: 'POST',
|
|
47
|
+
headers: { 'Content-Type': 'application/json' },
|
|
48
|
+
body: JSON.stringify(config)
|
|
49
|
+
});
|
|
50
|
+
return response.json();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
async listAgents() {
|
|
54
|
+
const response = await fetch(`${this.apiUrl}/agents`);
|
|
55
|
+
return response.json();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
onWebSocket(event, callback) {
|
|
59
|
+
const ws = new WebSocket(`${this.apiUrl.replace('http', 'ws')}/ws/${this.agent}`);
|
|
60
|
+
|
|
61
|
+
ws.onopen = () => {
|
|
62
|
+
if (event === 'open') callback();
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
ws.onmessage = (e) => {
|
|
66
|
+
const data = JSON.parse(e.data);
|
|
67
|
+
if (event === 'message') callback(data);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
ws.onerror = (error) => {
|
|
71
|
+
if (event === 'error') callback(error);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
ws.onclose = () => {
|
|
75
|
+
if (event === 'close') callback();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return ws;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class NeuroAgentWidget {
|
|
83
|
+
constructor(config) {
|
|
84
|
+
this.client = new NeuroAgentClient(config);
|
|
85
|
+
this.config = {
|
|
86
|
+
theme: config.theme || 'dark',
|
|
87
|
+
position: config.position || 'bottom-right',
|
|
88
|
+
title: config.title || 'AI Assistant',
|
|
89
|
+
welcomeMessage: config.welcomeMessage || 'Hello! How can I help you?',
|
|
90
|
+
...config
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
this.isOpen = false;
|
|
94
|
+
this.init();
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
init() {
|
|
98
|
+
this.createStyles();
|
|
99
|
+
this.createWidget();
|
|
100
|
+
this.createChat();
|
|
101
|
+
this.bindEvents();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
createStyles() {
|
|
105
|
+
if (document.getElementById('neuroagent-styles')) return;
|
|
106
|
+
|
|
107
|
+
const styles = document.createElement('style');
|
|
108
|
+
styles.id = 'neuroagent-styles';
|
|
109
|
+
styles.textContent = `
|
|
110
|
+
.na-widget { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; position: fixed; z-index: 999999; }
|
|
111
|
+
.na-widget-btn { width: 60px; height: 60px; border-radius: 50%; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: none; cursor: pointer; box-shadow: 0 4px 15px rgba(102,126,234,0.4); display: flex; align-items: center; justify-content: center; transition: transform 0.3s; }
|
|
112
|
+
.na-widget-btn:hover { transform: scale(1.1); }
|
|
113
|
+
.na-widget-btn svg { width: 30px; height: 30px; fill: white; }
|
|
114
|
+
.na-chat { position: fixed; width: 380px; height: 500px; background: white; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); display: none; flex-direction: column; overflow: hidden; }
|
|
115
|
+
.na-chat.open { display: flex; }
|
|
116
|
+
.na-chat-header { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; padding: 16px; display: flex; align-items: center; justify-content: space-between; }
|
|
117
|
+
.na-chat-title { font-weight: 600; font-size: 16px; }
|
|
118
|
+
.na-chat-close { background: none; border: none; color: white; cursor: pointer; font-size: 20px; }
|
|
119
|
+
.na-messages { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
|
|
120
|
+
.na-msg { max-width: 80%; padding: 12px 16px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
|
|
121
|
+
.na-msg.user { align-self: flex-end; background: #667eea; color: white; border-bottom-right-radius: 4px; }
|
|
122
|
+
.na-msg.assistant { align-self: flex-start; background: #f0f0f0; color: #333; border-bottom-left-radius: 4px; }
|
|
123
|
+
.na-msg.thinking { align-self: flex-start; background: #f0f0f0; color: #666; font-style: italic; }
|
|
124
|
+
.na-input-area { padding: 16px; border-top: 1px solid #eee; display: flex; gap: 8px; }
|
|
125
|
+
.na-input-area input { flex: 1; padding: 12px 16px; border: 1px solid #ddd; border-radius: 24px; outline: none; font-size: 14px; }
|
|
126
|
+
.na-input-area input:focus { border-color: #667eea; }
|
|
127
|
+
.na-input-area button { background: #667eea; color: white; border: none; padding: 12px 20px; border-radius: 24px; cursor: pointer; font-size: 14px; font-weight: 500; }
|
|
128
|
+
.na-input-area button:disabled { background: #ccc; cursor: not-allowed; }
|
|
129
|
+
.na-pos-bottom-right { bottom: 20px; right: 20px; }
|
|
130
|
+
.na-pos-bottom-left { bottom: 20px; left: 20px; }
|
|
131
|
+
.na-pos-top-right { top: 20px; right: 20px; }
|
|
132
|
+
.na-pos-top-left { top: 20px; left: 20px; }
|
|
133
|
+
.na-chat.na-pos-bottom-right, .na-chat.na-pos-bottom-left { bottom: 90px; }
|
|
134
|
+
.na-chat.na-pos-top-right, .na-chat.na-pos-top-left { top: 90px; }
|
|
135
|
+
.na-chat.na-pos-bottom-right, .na-chat.na-pos-top-right { right: 20px; }
|
|
136
|
+
.na-chat.na-pos-bottom-left, .na-chat.na-pos-top-left { left: 20px; }
|
|
137
|
+
`;
|
|
138
|
+
document.head.appendChild(styles);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
createWidget() {
|
|
142
|
+
this.widget = document.createElement('div');
|
|
143
|
+
this.widget.className = `na-widget na-pos-${this.config.position}`;
|
|
144
|
+
this.widget.innerHTML = `
|
|
145
|
+
<button class="na-widget-btn" title="${this.config.title}">
|
|
146
|
+
<svg viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm0 14H6l-2 2V4h16v12z"/></svg>
|
|
147
|
+
</button>
|
|
148
|
+
`;
|
|
149
|
+
document.body.appendChild(this.widget);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
createChat() {
|
|
153
|
+
this.chat = document.createElement('div');
|
|
154
|
+
this.chat.className = `na-chat na-pos-${this.config.position}`;
|
|
155
|
+
this.chat.innerHTML = `
|
|
156
|
+
<div class="na-chat-header">
|
|
157
|
+
<span class="na-chat-title">${this.config.title}</span>
|
|
158
|
+
<button class="na-chat-close">×</button>
|
|
159
|
+
</div>
|
|
160
|
+
<div class="na-messages"></div>
|
|
161
|
+
<div class="na-input-area">
|
|
162
|
+
<input type="text" placeholder="Type a message..." />
|
|
163
|
+
<button>Send</button>
|
|
164
|
+
</div>
|
|
165
|
+
`;
|
|
166
|
+
document.body.appendChild(this.chat);
|
|
167
|
+
this.messagesEl = this.chat.querySelector('.na-messages');
|
|
168
|
+
this.inputEl = this.chat.querySelector('input');
|
|
169
|
+
this.sendBtn = this.chat.querySelector('button');
|
|
170
|
+
this.addMessage(this.config.welcomeMessage, 'assistant');
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
bindEvents() {
|
|
174
|
+
this.widget.querySelector('.na-widget-btn').addEventListener('click', () => this.toggle());
|
|
175
|
+
this.chat.querySelector('.na-chat-close').addEventListener('click', () => this.close());
|
|
176
|
+
this.sendBtn.addEventListener('click', () => this.send());
|
|
177
|
+
this.inputEl.addEventListener('keypress', (e) => { if (e.key === 'Enter') this.send(); });
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
toggle() { this.isOpen ? this.close() : this.open(); }
|
|
181
|
+
open() { this.isOpen = true; this.chat.classList.add('open'); this.inputEl.focus(); }
|
|
182
|
+
close() { this.isOpen = false; this.chat.classList.remove('open'); }
|
|
183
|
+
|
|
184
|
+
addMessage(content, type = 'assistant') {
|
|
185
|
+
const msg = document.createElement('div');
|
|
186
|
+
msg.className = `na-msg ${type}`;
|
|
187
|
+
msg.textContent = content;
|
|
188
|
+
this.messagesEl.appendChild(msg);
|
|
189
|
+
this.messagesEl.scrollTop = this.messagesEl.scrollHeight;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async send() {
|
|
193
|
+
const msg = this.inputEl.value.trim();
|
|
194
|
+
if (!msg) return;
|
|
195
|
+
|
|
196
|
+
this.inputEl.value = '';
|
|
197
|
+
this.addMessage(msg, 'user');
|
|
198
|
+
this.sendBtn.disabled = true;
|
|
199
|
+
this.addMessage('Thinking...', 'thinking');
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
const response = await this.client.chat(msg);
|
|
203
|
+
this.messagesEl.lastElementChild?.remove();
|
|
204
|
+
this.addMessage(response.response || 'No response', 'assistant');
|
|
205
|
+
} catch (error) {
|
|
206
|
+
this.messagesEl.lastElementChild?.remove();
|
|
207
|
+
this.addMessage('Error connecting to server', 'assistant');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
this.sendBtn.disabled = false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
module.exports = { NeuroAgentClient, NeuroAgentWidget };
|
|
215
|
+
module.exports.default = { NeuroAgentClient, NeuroAgentWidget };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"""
|
|
2
|
+
NeuroAgent - Modern AI Agent Framework
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
__version__ = "0.2.0"
|
|
6
|
+
__author__ = "NeuroAgent Team"
|
|
7
|
+
|
|
8
|
+
from neuroagent.agents.agent import Agent
|
|
9
|
+
from neuroagent.team.team import Team
|
|
10
|
+
from neuroagent.llm.base import LLMProvider
|
|
11
|
+
from neuroagent.llm.openai_provider import OpenAIProvider
|
|
12
|
+
from neuroagent.llm.local_model_provider import LocalModelProvider
|
|
13
|
+
from neuroagent.tools.base import tool, Tool
|
|
14
|
+
from neuroagent.memory.short_memory import ShortMemory
|
|
15
|
+
from neuroagent.memory.long_memory import LongMemory
|
|
16
|
+
from neuroagent.memory.vector_memory import VectorMemory
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"Agent",
|
|
20
|
+
"Team",
|
|
21
|
+
"LLMProvider",
|
|
22
|
+
"OpenAIProvider",
|
|
23
|
+
"LocalModelProvider",
|
|
24
|
+
"tool",
|
|
25
|
+
"Tool",
|
|
26
|
+
"ShortMemory",
|
|
27
|
+
"LongMemory",
|
|
28
|
+
"VectorMemory",
|
|
29
|
+
]
|