express-genix 4.2.0 → 4.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/index.js CHANGED
@@ -204,6 +204,7 @@ async function main() {
204
204
  hasGraphQL: features.includes('graphql'),
205
205
  hasMCP: features.includes('mcp'),
206
206
  hasAI: features.includes('ai'),
207
+ aiProvider: answers.aiProvider || 'openai',
207
208
  jwtSecret: generateSecret(),
208
209
  jwtRefreshSecret: generateSecret(),
209
210
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-genix",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "Production-grade CLI to generate Express apps with JWT, RBAC, GraphQL, TypeScript, Prisma, MongoDB, PostgreSQL, file uploads, email, background jobs, and more",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -45,7 +45,6 @@ const calculatorTool = tool(
45
45
  * @param {Object} options
46
46
  * @param {Array} options.tools - Additional @langchain/core tools to register
47
47
  * @param {string} options.systemPrompt - System instruction for the agent
48
- * @param {string} options.provider - AI provider (openai, anthropic, ollama)
49
48
  * @param {string} options.model - Model name override
50
49
  */
51
50
  const createAgent = (options = {}) => {
@@ -1,54 +1,47 @@
1
+ <% if (aiProvider === 'openai') { %>
1
2
  const { ChatOpenAI } = require('@langchain/openai');
3
+ <% } else if (aiProvider === 'anthropic') { %>
2
4
  const { ChatAnthropic } = require('@langchain/anthropic');
3
- const { ChatOllama } = require('@langchain/ollama');
5
+ <% } else if (aiProvider === 'gemini') { %>
4
6
  const { ChatGoogleGenerativeAI } = require('@langchain/google-genai');
7
+ <% } else if (aiProvider === 'ollama') { %>
8
+ const { ChatOllama } = require('@langchain/ollama');
9
+ <% } %>
5
10
 
6
11
  /**
7
12
  * Create a LangChain chat model based on the configured provider.
8
- * Supports OpenAI, Anthropic, Google Gemini, and Ollama (local).
9
13
  */
10
14
  const getModel = (options = {}) => {
11
- const provider = (options.provider || process.env.AI_PROVIDER || 'openai').toLowerCase();
12
15
  const temperature = options.temperature ?? parseFloat(process.env.AI_TEMPERATURE || '0.7');
13
16
  const maxTokens = options.maxTokens ?? parseInt(process.env.AI_MAX_TOKENS || '2048', 10);
14
-
15
- switch (provider) {
16
- case 'openai':
17
- return new ChatOpenAI({
18
- modelName: options.model || process.env.AI_MODEL || 'gpt-4o-mini',
19
- temperature,
20
- maxTokens,
21
- openAIApiKey: process.env.OPENAI_API_KEY,
22
- });
23
-
24
- case 'anthropic':
25
- return new ChatAnthropic({
26
- modelName: options.model || process.env.AI_MODEL || 'claude-sonnet-4-20250514',
27
- temperature,
28
- maxTokens,
29
- anthropicApiKey: process.env.ANTHROPIC_API_KEY,
30
- });
31
-
32
- case 'gemini':
33
- return new ChatGoogleGenerativeAI({
34
- model: options.model || process.env.AI_MODEL || 'gemini-2.0-flash',
35
- temperature,
36
- maxOutputTokens: maxTokens,
37
- apiKey: process.env.GOOGLE_API_KEY,
38
- });
39
-
40
- case 'ollama':
41
- return new ChatOllama({
42
- model: options.model || process.env.AI_MODEL || 'llama3',
43
- temperature,
44
- baseUrl: process.env.OLLAMA_BASE_URL || 'http://localhost:11434',
45
- });
46
-
47
- default:
48
- throw new Error(
49
- `Unsupported AI provider: "${provider}". Supported: openai, anthropic, gemini, ollama`
50
- );
51
- }
17
+ <% if (aiProvider === 'openai') { %>
18
+ return new ChatOpenAI({
19
+ modelName: options.model || process.env.AI_MODEL || 'gpt-4o-mini',
20
+ temperature,
21
+ maxTokens,
22
+ openAIApiKey: process.env.OPENAI_API_KEY,
23
+ });
24
+ <% } else if (aiProvider === 'anthropic') { %>
25
+ return new ChatAnthropic({
26
+ modelName: options.model || process.env.AI_MODEL || 'claude-sonnet-4-20250514',
27
+ temperature,
28
+ maxTokens,
29
+ anthropicApiKey: process.env.ANTHROPIC_API_KEY,
30
+ });
31
+ <% } else if (aiProvider === 'gemini') { %>
32
+ return new ChatGoogleGenerativeAI({
33
+ model: options.model || process.env.AI_MODEL || 'gemini-2.0-flash',
34
+ temperature,
35
+ maxOutputTokens: maxTokens,
36
+ apiKey: process.env.GOOGLE_API_KEY,
37
+ });
38
+ <% } else if (aiProvider === 'ollama') { %>
39
+ return new ChatOllama({
40
+ model: options.model || process.env.AI_MODEL || 'llama3',
41
+ temperature,
42
+ baseUrl: process.env.OLLAMA_BASE_URL || 'http://localhost:11434',
43
+ });
44
+ <% } %>
52
45
  };
53
46
 
54
47
  module.exports = { getModel };
@@ -7,7 +7,7 @@ const { success, error } = require('../utils/response');
7
7
  */
8
8
  const chatHandler = async (req, res, next) => {
9
9
  try {
10
- const { message, systemPrompt, history, provider, model, temperature, maxTokens } = req.body;
10
+ const { message, systemPrompt, history, model, temperature, maxTokens } = req.body;
11
11
 
12
12
  if (!message) {
13
13
  return res.status(400).json(error('Message is required'));
@@ -16,7 +16,6 @@ const chatHandler = async (req, res, next) => {
16
16
  const result = await aiService.chat(message, {
17
17
  systemPrompt,
18
18
  history,
19
- provider,
20
19
  model,
21
20
  temperature,
22
21
  maxTokens,
@@ -33,7 +32,7 @@ const chatHandler = async (req, res, next) => {
33
32
  */
34
33
  const streamHandler = async (req, res, next) => {
35
34
  try {
36
- const { message, systemPrompt, history, provider, model, temperature, maxTokens } = req.body;
35
+ const { message, systemPrompt, history, model, temperature, maxTokens } = req.body;
37
36
 
38
37
  if (!message) {
39
38
  return res.status(400).json(error('Message is required'));
@@ -46,7 +45,6 @@ const streamHandler = async (req, res, next) => {
46
45
  const generator = aiService.stream(message, {
47
46
  systemPrompt,
48
47
  history,
49
- provider,
50
48
  model,
51
49
  temperature,
52
50
  maxTokens,
@@ -68,13 +66,13 @@ const streamHandler = async (req, res, next) => {
68
66
  */
69
67
  const chainHandler = async (req, res, next) => {
70
68
  try {
71
- const { template, variables, provider, model } = req.body;
69
+ const { template, variables, model } = req.body;
72
70
 
73
71
  if (!template) {
74
72
  return res.status(400).json(error('Template is required'));
75
73
  }
76
74
 
77
- const result = await aiService.chain(template, variables || {}, { provider, model });
75
+ const result = await aiService.chain(template, variables || {}, { model });
78
76
  res.json(success({ content: result }));
79
77
  } catch (err) {
80
78
  next(err);
@@ -86,13 +84,13 @@ const chainHandler = async (req, res, next) => {
86
84
  */
87
85
  const agentHandler = async (req, res, next) => {
88
86
  try {
89
- const { message, systemPrompt, provider, model } = req.body;
87
+ const { message, systemPrompt, model } = req.body;
90
88
 
91
89
  if (!message) {
92
90
  return res.status(400).json(error('Message is required'));
93
91
  }
94
92
 
95
- const result = await runAgent(message, { systemPrompt, provider, model });
93
+ const result = await runAgent(message, { systemPrompt, model });
96
94
  res.json(success(result));
97
95
  } catch (err) {
98
96
  next(err);
@@ -50,11 +50,11 @@
50
50
  "bullmq": "^5.12.0"<% } %><% if (hasMCP) { %>,
51
51
  "@modelcontextprotocol/sdk": "^1.12.0"<% } %><% if (hasAI) { %>,
52
52
  "@langchain/core": "^0.3.0",
53
- "@langchain/openai": "^0.5.0",
54
- "@langchain/anthropic": "^0.3.0",
55
- "@langchain/google-genai": "^0.2.0",
56
- "@langchain/ollama": "^0.1.0",
57
- "@langchain/langgraph": "^0.2.0"<% } %><% if (logger === 'winston') { %>,
53
+ <% if (aiProvider === 'openai') { %> "@langchain/openai": "^0.5.0",
54
+ <% } else if (aiProvider === 'anthropic') { %> "@langchain/anthropic": "^0.3.0",
55
+ <% } else if (aiProvider === 'gemini') { %> "@langchain/google-genai": "^0.2.0",
56
+ <% } else if (aiProvider === 'ollama') { %> "@langchain/ollama": "^0.1.0",
57
+ <% } %> "@langchain/langgraph": "^0.2.0"<% } %><% if (logger === 'winston') { %>,
58
58
  "winston": "^3.15.0"<% } %><% if (logger === 'pino') { %>,
59
59
  "pino": "^9.5.0",
60
60
  "pino-pretty": "^13.0.0"<% } %>
@@ -27,7 +27,7 @@ const chat = async (message, options = {}) => {
27
27
  const response = await model.invoke(messages);
28
28
 
29
29
  logger.info('AI chat completed', {
30
- provider: options.provider || process.env.AI_PROVIDER || 'openai',
30
+ provider: process.env.AI_PROVIDER,
31
31
  });
32
32
 
33
33
  return {