File size: 1,050 Bytes
6ce9b06
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
```typescript
import { runTools } from "./tools.js";
import { memoryAppend, memoryGet } from "./memory.js";
import { llmChat } from "../services/ollama.js";

export async function rosalindaRespond(input: {
  projectId: string;
  userText: string;
}) {
  const { projectId, userText } = input;

  const history = memoryGet(projectId);
  memoryAppend(projectId, { role: "user", content: userText });

  const toolResult = await runTools({ projectId, userText });

  const system = `
Tu es Rosalinda, l'IA privée du propriétaire.
Règles:
- Tu proposes des actions concrètes.
- Tu peux créer des projets, lancer des jobs, manipuler des fichiers via les tools.
- Tu réponds en français, clair, professionnel.
`;

  const messages = [
    { role: "system", content: system },
    ...history.slice(-12),
    ...(toolResult ? [{ role: "assistant", content: `Résultat outil: ${toolResult}` }] : [])
  ];

  const reply = await llmChat(messages);

  memoryAppend(projectId, { role: "assistant", content: reply });

  return { reply, toolResult };
}
```