Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ DEFAULT_MODEL=openai-responses
RUNNER_KEY=R2D2C3PO

# Conversation History (Generic)
CONVERSATION_HISTORY_MAX_MESSAGES=60
CONVERSATION_HISTORY_TTL=2629800

# Conversation Cache Global switch
CONVERSATION_CACHE_ENABLED=true

# Optional provider-specific overrides
OPENAI_CONVERSATION_CACHE_ENABLED=true
GEMINI_CONVERSATION_CACHE_ENABLED=true
# ...

# Ollama Configuration
OLLAMA_BASE_URL=http://localhost:11434
Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ API for interacting with LEIA instances.

## Usage

### Environment variables

Use `.env.example` as reference. For conversation cache behavior in Redis, you can control it with one switch:

- Global: `CONVERSATION_CACHE_ENABLED=true|false`
- TTL de conversaciones: `CONVERSATION_HISTORY_TTL=2629800` (seconds; default 2629800 = 1 month)
- Provider overrides:
- `OPENAI_CONVERSATION_CACHE_ENABLED=true|false`
- `GEMINI_CONVERSATION_CACHE_ENABLED=true|false`
- `OLLAMA_CONVERSATION_CACHE_ENABLED=true|false`

Priority order:

1. Provider-specific variable
2. Global variable
3. Default value (`true`)

### Start the server

```bash
Expand Down
12 changes: 12 additions & 0 deletions controllers/evaluationController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const modelManager = require('../models/modelManager');
const sessionService = require('../services/sessionService');

module.exports.evaluateSolution = async function evaluateSolution(req, res) {
let conversationClearable = false;

try {
const { sessionId, result } = req.body;

Expand All @@ -21,6 +23,8 @@ module.exports.evaluateSolution = async function evaluateSolution(req, res) {
return res.status(404).send({ error: `LEIA metadata for session ID: ${sessionId} not found` });
}

conversationClereable = true;

// Obtener el modelo
const model = modelManager.getModel(sessionData.modelName);

Expand All @@ -34,5 +38,13 @@ module.exports.evaluateSolution = async function evaluateSolution(req, res) {
} catch (error) {
console.error(`Error evaluating solution for session ${req.body.sessionId}:`, error);
res.status(500).send({ error: 'Internal error evaluating solution' });
} finally {
if (conversationClereable) {
try {
await sessionService.clearConversation(req.body.sessionId);
} catch (cleanupError) {
console.error(`Error clearing conversation cache for session ${req.body.sessionId}:`, cleanupError);
}
}
}
};
201 changes: 0 additions & 201 deletions models/conversationStore.js

This file was deleted.

Loading
Loading