@eventcatalog/core 2.60.0 → 2.61.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.
Files changed (33) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +1 -1
  4. package/dist/analytics/log-build.js +3 -3
  5. package/dist/{chunk-WASYSRBV.js → chunk-3CAAQQUB.js} +1 -1
  6. package/dist/{chunk-QMWI6M2I.js → chunk-I2B6B3XZ.js} +1 -1
  7. package/dist/{chunk-6FRDYEMA.js → chunk-OEWPHKD6.js} +1 -1
  8. package/dist/constants.cjs +1 -1
  9. package/dist/constants.js +1 -1
  10. package/dist/eventcatalog.cjs +2 -2
  11. package/dist/eventcatalog.js +4 -4
  12. package/eventcatalog/astro.config.mjs +1 -0
  13. package/eventcatalog/src/enterprise/eventcatalog-chat/components/Chat.tsx +19 -9
  14. package/eventcatalog/src/enterprise/eventcatalog-chat/components/ChatMessage.tsx +227 -69
  15. package/eventcatalog/src/enterprise/eventcatalog-chat/components/hooks/ChatProvider.tsx +4 -3
  16. package/eventcatalog/src/enterprise/eventcatalog-chat/components/windows/ChatWindow.server.tsx +46 -176
  17. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/api/chat.ts +59 -0
  18. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/chat/index.astro +0 -37
  19. package/eventcatalog/src/enterprise/eventcatalog-chat/providers/ai-provider.ts +83 -4
  20. package/eventcatalog/src/middleware-auth.ts +13 -2
  21. package/eventcatalog/src/pages/chat/feature.astro +24 -16
  22. package/eventcatalog/src/pages/docs/[type]/[id]/[version].mdx.ts +22 -11
  23. package/eventcatalog/src/pages/docs/llm/llms-full.txt.ts +3 -3
  24. package/eventcatalog/src/utils/feature.ts +2 -1
  25. package/eventcatalog/src/utils/url-builder.ts +9 -0
  26. package/package.json +7 -10
  27. package/eventcatalog/src/enterprise/eventcatalog-chat/EventCatalogVectorStore.ts +0 -66
  28. package/eventcatalog/src/enterprise/eventcatalog-chat/components/windows/ChatWindow.client.tsx +0 -540
  29. package/eventcatalog/src/enterprise/eventcatalog-chat/components/workers/document-importer.ts +0 -38
  30. package/eventcatalog/src/enterprise/eventcatalog-chat/components/workers/engine.ts +0 -7
  31. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/api/ai/chat.ts +0 -54
  32. package/eventcatalog/src/enterprise/eventcatalog-chat/pages/api/ai/resources.ts +0 -42
  33. package/eventcatalog/src/enterprise/eventcatalog-chat/utils/ai.ts +0 -112
@@ -1,112 +0,0 @@
1
- import { type CoreMessage, type Message } from 'ai';
2
- import { EventCatalogVectorStore, type Resource } from '@enterprise/eventcatalog-chat/EventCatalogVectorStore';
3
- import fs from 'fs';
4
- import path from 'path';
5
- import config from '@config';
6
- import { getProvider } from '@enterprise/eventcatalog-chat/providers';
7
-
8
- const AI_EMBEDDINGS_PATH = path.join(process.env.PROJECT_DIR || process.cwd(), 'public/ai');
9
- const documents = JSON.parse(fs.readFileSync(path.join(AI_EMBEDDINGS_PATH, 'documents.json'), 'utf8'));
10
- const embeddings = JSON.parse(fs.readFileSync(path.join(AI_EMBEDDINGS_PATH, 'embeddings.json'), 'utf8'));
11
-
12
- export const getResources = async (question: string) => {
13
- const vectorStore = await EventCatalogVectorStore.create(documents, embeddings);
14
- const resources = await vectorStore.getEventCatalogResources(question);
15
- return resources;
16
- };
17
-
18
- export async function askQuestion(
19
- question: string = 'Tell me more about the Payment domain',
20
- historicMessages: Message[] = [],
21
- systemPromptOverride?: string
22
- ) {
23
- const resources = await getResources(question);
24
-
25
- const baseSystemPrompt = `You are an expert in event-driven architecture and domain-driven design, specializing in documentation for EventCatalog.
26
-
27
- You assist developers, architects, and business stakeholders who need information about their event-driven system catalog. You help with questions about:
28
- - Events (asynchronous messages that notify about something that has happened)
29
- - Commands (requests to perform an action)
30
- - Queries (requests for information)
31
- - Services (bounded contexts or applications that produce/consume events)
32
- - Domains (business capabilities or functional areas)
33
-
34
- Your primary goal is to help users understand their event-driven system through accurate documentation interpretation.
35
-
36
- IMPORTANT RULES:
37
- 1. Resources will be provided to you in <resource> tags. ONLY use these resources to answer questions.
38
- 2. NEVER include ANY <resource> tags in your responses. This is a strict requirement.
39
- 3. ALWAYS refer to resources by their name/ID/title attributes only.
40
- 4. If asked about specific resource types (e.g., "What domains do we have?"), simply list their names without elaboration.
41
- 5. NEVER invent or make up resources that aren't provided to you.
42
- 6. When you return code examples, make sure you always return them in markdown code blocks.
43
-
44
- RESPONSE FORMAT EXAMPLES:
45
- ✓ CORRECT: "The SubscriptionService produces the UserSubscribed event."
46
- ✗ INCORRECT: "<resource id="SubscriptionService">...</resource> produces events."
47
-
48
- When responding:
49
- 1. Use only information from the provided resources.
50
- 2. Explain connections between resources when relevant.
51
- 3. Use appropriate technical terminology.
52
- 4. Use clear formatting with headings and bullet points when helpful.
53
- 5. State clearly when information is missing rather than making assumptions.
54
- 6. Don't provide code examples unless specifically requested.
55
-
56
- Your primary goal is to help users understand their event-driven system through accurate documentation interpretation.
57
-
58
- If you have additional context, use it to answer the question.`;
59
-
60
- const resourceStrings = resources.map((resource: Resource) => {
61
- const attributes = Object.entries(resource)
62
- .filter(([key, value]) => key !== 'markdown' && key !== 'loc' && value !== undefined && value !== null)
63
- .map(([key, value]) => {
64
- // value can be an object, so we need to convert it to a string
65
- const valueString = typeof value === 'object' ? JSON.stringify(value) : String(value);
66
- return `${key}="${valueString.replace(/"/g, '&quot;')}"`; // Escape quotes in values
67
- })
68
- .join(' ');
69
- return `<resource ${attributes} />`;
70
- });
71
-
72
- const resourceContext = `==========
73
- ${resourceStrings.join('\n')}
74
- ==========`;
75
-
76
- let systemPrompt = systemPromptOverride ? systemPromptOverride : baseSystemPrompt;
77
- systemPrompt += `\n\n${resourceContext}`;
78
-
79
- // add 1 more rule
80
- systemPrompt += `\n\n1. When you return code examples, make sure you always return them in markdown code blocks.`;
81
- const messages = [
82
- {
83
- role: 'system',
84
- content: systemPrompt, // Fixed: Was qaPrompt
85
- },
86
- ...historicMessages,
87
- {
88
- role: 'user',
89
- content: question,
90
- },
91
- ] as CoreMessage[];
92
-
93
- const modelId = config?.chat?.model;
94
-
95
- // setup the model and provider
96
- const aiProvider = getProvider(config?.chat?.provider || 'openai', {
97
- modelId,
98
- temperature: config?.chat?.temperature,
99
- topP: config?.chat?.topP,
100
- topK: config?.chat?.topK,
101
- frequencyPenalty: config?.chat?.frequencyPenalty,
102
- presencePenalty: config?.chat?.presencePenalty,
103
- });
104
-
105
- const { isValidModel, listOfModels } = await aiProvider.validateModel(modelId);
106
-
107
- if (!isValidModel) {
108
- throw new Error(`Invalid model: "${modelId}", please use a valid model from the following list: ${listOfModels.join(', ')}`);
109
- }
110
-
111
- return await aiProvider.streamText(messages);
112
- }