convesation-layer-agent establecido

This commit is contained in:
2025-06-05 00:34:57 -06:00
parent bb9d47feab
commit fffbe6c313
3 changed files with 17 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ dotenv.config();
const PORT = Number(process.env.PORT) || 8001; const PORT = Number(process.env.PORT) || 8001;
const API_KEY = process.env.GEMINI_API_KEY || ''; const API_KEY = process.env.GEMINI_API_KEY || '';
console.log(`Using Gemini API key: ${API_KEY}`);
const genAI = API_KEY ? new GoogleGenerativeAI(API_KEY) : null; const genAI = API_KEY ? new GoogleGenerativeAI(API_KEY) : null;
const model = genAI ? genAI.getGenerativeModel({ model: 'gemini-pro' }) : null; const model = genAI ? genAI.getGenerativeModel({ model: 'gemini-pro' }) : null;
@@ -38,6 +39,19 @@ app.post('/', async (req, res) => {
} }
}); });
app.get('/', (req, res) => {
res.send(`
<h1>Conversation Layer Agent</h1>
<p>This service answers questions about the repository.</p>
<p>Send a POST request to / with a JSON body containing {"message": "your question"}</p>
<p>Example: {"message": "What is this repository about?"}</p>
<p>It will respond with a JSON object containing {"reply": "the answer"}</p>
<p>Repository info: ${repoInfo}</p>
`);
}
);
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`conversation-layer-agent listening on ${PORT}`); console.log(`conversation-layer-agent listening on ${PORT}`);
}); });

View File

@@ -4,7 +4,7 @@ import { WhatsAppMessage } from './types';
export type Handler = string | ((msg: WhatsAppMessage | string) => Promise<string>); export type Handler = string | ((msg: WhatsAppMessage | string) => Promise<string>);
export const chatHandlers: Record<string, Handler> = { export const chatHandlers: Record<string, Handler> = {
'50498554225@c.us': helloWorldAgent, '50498554225@c.us': 'http://conversation-layer-agent:8001',
'repo-helper@c.us': 'http://conversation-layer-agent:8001', 'repo-helper@c.us': 'http://conversation-layer-agent:8001',
// Add other mappings like: // Add other mappings like:
// '50496210031@c.us': 'http://llm-agent:8000' // '50496210031@c.us': 'http://llm-agent:8000'