NobGit
public anord read

Ledger

Why work hard when you can work easier?

Languages

Repository composition by tracked source files.

TypeScript
TypeScript 86% CSS 10% SQL 3% Shell 1% HTML 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/anord/ledger.git
ssh://[email protected]:2222/orgs/anord/ledger.git

Trace

apps/api/src/services/ai.ts

Trace helps you understand code history line by line. See who changed each line, when it changed, and which commit introduced it.

ai.ts on main
Author Date Commit Line Code
Alex Nord 3 months ago 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
1
import { env } from "../config/env.js";
Open commit View diff
1 import { env } from "../config/env.js";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
2
import { pool } from "../db/pool.js";
Open commit View diff
2 import { pool } from "../db/pool.js";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
3
import { searchPages } from "./search.js";
Open commit View diff
3 import { searchPages } from "./search.js";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
4
import { getPageBySlug } from "./pages.js";
Open commit View diff
4 import { getPageBySlug } from "./pages.js";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
5
import type { SessionUser } from "@ledger/shared";
Open commit View diff
5 import type { SessionUser } from "@ledger/shared";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
6
Open commit View diff
6
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
7
type ProviderConfig = {
Open commit View diff
7 type ProviderConfig = {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
8
  provider: string;
Open commit View diff
8 provider: string;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
9
  model: string;
Open commit View diff
9 model: string;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
10
  apiKey: string;
Open commit View diff
10 apiKey: string;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
11
  baseUrl: string | null;
Open commit View diff
11 baseUrl: string | null;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
12
};
Open commit View diff
12 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
13
Open commit View diff
13
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
14
export async function getAiSettingsRecord() {
Open commit View diff
14 export async function getAiSettingsRecord() {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
15
  const settings = await pool.query(`SELECT * FROM ai_settings ORDER BY created_at ASC LIMIT 1`);
Open commit View diff
15 const settings = await pool.query(`SELECT * FROM ai_settings ORDER BY created_at ASC LIMIT 1`);
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
16
  return settings.rows[0] ?? null;
Open commit View diff
16 return settings.rows[0] ?? null;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
17
}
Open commit View diff
17 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
18
Open commit View diff
18
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
19
export async function upsertAiSettings(input: {
Open commit View diff
19 export async function upsertAiSettings(input: {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
20
  provider: string;
Open commit View diff
20 provider: string;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
21
  model: string;
Open commit View diff
21 model: string;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
22
  apiKey: string | null;
Open commit View diff
22 apiKey: string | null;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
23
  isEnabled: boolean;
Open commit View diff
23 isEnabled: boolean;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
24
}) {
Open commit View diff
24 }) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
25
  const existing = await getAiSettingsRecord();
Open commit View diff
25 const existing = await getAiSettingsRecord();
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
26
  if (existing) {
Open commit View diff
26 if (existing) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
27
    const nextApiKey = input.apiKey === null ? existing.encrypted_api_key : input.apiKey;
Open commit View diff
27 const nextApiKey = input.apiKey === null ? existing.encrypted_api_key : input.apiKey;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
28
    const updated = await pool.query(
Open commit View diff
28 const updated = await pool.query(
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
29
      `
Open commit View diff
29 `
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
30
        UPDATE ai_settings
Open commit View diff
30 UPDATE ai_settings
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
31
        SET provider = $2, model = $3, encrypted_api_key = $4, is_enabled = $5, updated_at = now()
Open commit View diff
31 SET provider = $2, model = $3, encrypted_api_key = $4, is_enabled = $5, updated_at = now()
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
32
        WHERE id = $1
Open commit View diff
32 WHERE id = $1
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
33
        RETURNING *
Open commit View diff
33 RETURNING *
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
34
      `,
Open commit View diff
34 `,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
35
      [existing.id, input.provider, input.model, nextApiKey, input.isEnabled]
Open commit View diff
35 [existing.id, input.provider, input.model, nextApiKey, input.isEnabled]
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
36
    );
Open commit View diff
36 );
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
37
    return updated.rows[0];
Open commit View diff
37 return updated.rows[0];
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
38
  }
Open commit View diff
38 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
39
Open commit View diff
39
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
40
  const created = await pool.query(
Open commit View diff
40 const created = await pool.query(
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
41
    `
Open commit View diff
41 `
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
42
      INSERT INTO ai_settings (provider, model, encrypted_api_key, is_enabled)
Open commit View diff
42 INSERT INTO ai_settings (provider, model, encrypted_api_key, is_enabled)
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
43
      VALUES ($1, $2, $3, $4)
Open commit View diff
43 VALUES ($1, $2, $3, $4)
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
44
      RETURNING *
Open commit View diff
44 RETURNING *
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
45
    `,
Open commit View diff
45 `,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
46
    [input.provider, input.model, input.apiKey, input.isEnabled]
Open commit View diff
46 [input.provider, input.model, input.apiKey, input.isEnabled]
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
47
  );
Open commit View diff
47 );
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
48
  return created.rows[0];
Open commit View diff
48 return created.rows[0];
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
49
}
Open commit View diff
49 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
50
Open commit View diff
50
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
51
async function resolveProviderConfig(): Promise<ProviderConfig | null> {
Open commit View diff
51 async function resolveProviderConfig(): Promise<ProviderConfig | null> {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
52
  const persisted = await getAiSettingsRecord();
Open commit View diff
52 const persisted = await getAiSettingsRecord();
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
53
  const provider = String(persisted?.provider ?? env.AI_PROVIDER ?? "none");
Open commit View diff
53 const provider = String(persisted?.provider ?? env.AI_PROVIDER ?? "none");
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
54
  const model = String(persisted?.model ?? env.AI_MODEL ?? "");
Open commit View diff
54 const model = String(persisted?.model ?? env.AI_MODEL ?? "");
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
55
  const apiKey = String(persisted?.encrypted_api_key ?? env.AI_API_KEY ?? "");
Open commit View diff
55 const apiKey = String(persisted?.encrypted_api_key ?? env.AI_API_KEY ?? "");
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
56
  const isEnabled = Boolean(persisted?.is_enabled ?? provider !== "none");
Open commit View diff
56 const isEnabled = Boolean(persisted?.is_enabled ?? provider !== "none");
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
57
  const baseUrl = provider === "openai_compatible" ? "https://api.openai.com/v1" : null;
Open commit View diff
57 const baseUrl = provider === "openai_compatible" ? "https://api.openai.com/v1" : null;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
58
Open commit View diff
58
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
59
  if (!isEnabled || provider === "none" || !model || !apiKey) {
Open commit View diff
59 if (!isEnabled || provider === "none" || !model || !apiKey) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
60
    return null;
Open commit View diff
60 return null;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
61
  }
Open commit View diff
61 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
62
Open commit View diff
62
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
63
  return {
Open commit View diff
63 return {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
64
    provider,
Open commit View diff
64 provider,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
65
    model,
Open commit View diff
65 model,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
66
    apiKey,
Open commit View diff
66 apiKey,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
67
    baseUrl
Open commit View diff
67 baseUrl
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
68
  };
Open commit View diff
68 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
69
}
Open commit View diff
69 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
70
Open commit View diff
70
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
71
async function generateWithProvider(provider: ProviderConfig, prompt: string) {
Open commit View diff
71 async function generateWithProvider(provider: ProviderConfig, prompt: string) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
72
  if (provider.provider === "openai_compatible") {
Open commit View diff
72 if (provider.provider === "openai_compatible") {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
73
    const response = await fetch(`${provider.baseUrl}/chat/completions`, {
Open commit View diff
73 const response = await fetch(`${provider.baseUrl}/chat/completions`, {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
74
      method: "POST",
Open commit View diff
74 method: "POST",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
75
      headers: {
Open commit View diff
75 headers: {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
76
        Authorization: `Bearer ${provider.apiKey}`,
Open commit View diff
76 Authorization: `Bearer ${provider.apiKey}`,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
77
        "Content-Type": "application/json"
Open commit View diff
77 "Content-Type": "application/json"
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
78
      },
Open commit View diff
78 },
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
79
      body: JSON.stringify({
Open commit View diff
79 body: JSON.stringify({
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
80
        model: provider.model,
Open commit View diff
80 model: provider.model,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
81
        temperature: 0.2,
Open commit View diff
81 temperature: 0.2,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
82
        messages: [
Open commit View diff
82 messages: [
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
83
          {
Open commit View diff
83 {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
84
            role: "system",
Open commit View diff
84 role: "system",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
85
            content:
Open commit View diff
85 content:
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
86
              "Answer using only the provided knowledge base excerpts. If the context is insufficient, say exactly: The knowledge base does not contain enough information to answer that."
Open commit View diff
86 "Answer using only the provided knowledge base excerpts. If the context is insufficient, say exactly: The knowledge base does not contain enough information to answer that."
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
87
          },
Open commit View diff
87 },
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
88
          {
Open commit View diff
88 {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
89
            role: "user",
Open commit View diff
89 role: "user",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
90
            content: prompt
Open commit View diff
90 content: prompt
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
91
          }
Open commit View diff
91 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
92
        ]
Open commit View diff
92 ]
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
93
      })
Open commit View diff
93 })
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
94
    });
Open commit View diff
94 });
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
95
Open commit View diff
95
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
96
    if (!response.ok) {
Open commit View diff
96 if (!response.ok) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
97
      throw new Error(`AI provider request failed with status ${response.status}`);
Open commit View diff
97 throw new Error(`AI provider request failed with status ${response.status}`);
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
98
    }
Open commit View diff
98 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
99
Open commit View diff
99
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
100
    const body = (await response.json()) as {
Open commit View diff
100 const body = (await response.json()) as {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
101
      choices?: Array<{ message?: { content?: string } }>;
Open commit View diff
101 choices?: Array<{ message?: { content?: string } }>;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
102
    };
Open commit View diff
102 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
103
Open commit View diff
103
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
104
    return body.choices?.[0]?.message?.content?.trim() ?? "";
Open commit View diff
104 return body.choices?.[0]?.message?.content?.trim() ?? "";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
105
  }
Open commit View diff
105 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
106
Open commit View diff
106
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
107
  if (provider.provider === "anthropic_compatible") {
Open commit View diff
107 if (provider.provider === "anthropic_compatible") {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
108
    const response = await fetch("https://api.anthropic.com/v1/messages", {
Open commit View diff
108 const response = await fetch("https://api.anthropic.com/v1/messages", {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
109
      method: "POST",
Open commit View diff
109 method: "POST",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
110
      headers: {
Open commit View diff
110 headers: {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
111
        "x-api-key": provider.apiKey,
Open commit View diff
111 "x-api-key": provider.apiKey,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
112
        "anthropic-version": "2023-06-01",
Open commit View diff
112 "anthropic-version": "2023-06-01",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
113
        "Content-Type": "application/json"
Open commit View diff
113 "Content-Type": "application/json"
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
114
      },
Open commit View diff
114 },
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
115
      body: JSON.stringify({
Open commit View diff
115 body: JSON.stringify({
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
116
        model: provider.model,
Open commit View diff
116 model: provider.model,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
117
        max_tokens: 500,
Open commit View diff
117 max_tokens: 500,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
118
        messages: [
Open commit View diff
118 messages: [
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
119
          {
Open commit View diff
119 {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
120
            role: "user",
Open commit View diff
120 role: "user",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
121
            content: prompt
Open commit View diff
121 content: prompt
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
122
          }
Open commit View diff
122 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
123
        ],
Open commit View diff
123 ],
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
124
        system:
Open commit View diff
124 system:
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
125
          "Answer using only the provided knowledge base excerpts. If the context is insufficient, say exactly: The knowledge base does not contain enough information to answer that."
Open commit View diff
125 "Answer using only the provided knowledge base excerpts. If the context is insufficient, say exactly: The knowledge base does not contain enough information to answer that."
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
126
      })
Open commit View diff
126 })
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
127
    });
Open commit View diff
127 });
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
128
Open commit View diff
128
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
129
    if (!response.ok) {
Open commit View diff
129 if (!response.ok) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
130
      throw new Error(`AI provider request failed with status ${response.status}`);
Open commit View diff
130 throw new Error(`AI provider request failed with status ${response.status}`);
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
131
    }
Open commit View diff
131 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
132
Open commit View diff
132
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
133
    const body = (await response.json()) as {
Open commit View diff
133 const body = (await response.json()) as {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
134
      content?: Array<{ text?: string }>;
Open commit View diff
134 content?: Array<{ text?: string }>;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
135
    };
Open commit View diff
135 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
136
Open commit View diff
136
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
137
    return body.content?.map((part) => part.text ?? "").join("").trim() ?? "";
Open commit View diff
137 return body.content?.map((part) => part.text ?? "").join("").trim() ?? "";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
138
  }
Open commit View diff
138 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
139
Open commit View diff
139
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
140
  return "";
Open commit View diff
140 return "";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
141
}
Open commit View diff
141 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
142
Open commit View diff
142
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
143
export async function answerQuestion(question: string, user: SessionUser | null) {
Open commit View diff
143 export async function answerQuestion(question: string, user: SessionUser | null) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
144
  const pages = await searchPages(question, user);
Open commit View diff
144 const pages = await searchPages(question, user);
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
145
  if (pages.length === 0) {
Open commit View diff
145 if (pages.length === 0) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
146
    return {
Open commit View diff
146 return {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
147
      answer: "The knowledge base does not contain enough information to answer that.",
Open commit View diff
147 answer: "The knowledge base does not contain enough information to answer that.",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
148
      citations: [],
Open commit View diff
148 citations: [],
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
149
      disabled: false
Open commit View diff
149 disabled: false
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
150
    };
Open commit View diff
150 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
151
  }
Open commit View diff
151 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
152
Open commit View diff
152
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
153
  const provider = await resolveProviderConfig();
Open commit View diff
153 const provider = await resolveProviderConfig();
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
154
  if (!provider) {
Open commit View diff
154 if (!provider) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
155
    return {
Open commit View diff
155 return {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
156
      answer: "",
Open commit View diff
156 answer: "",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
157
      citations: [],
Open commit View diff
157 citations: [],
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
158
      disabled: true
Open commit View diff
158 disabled: true
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
159
    };
Open commit View diff
159 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
160
  }
Open commit View diff
160 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
161
Open commit View diff
161
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
162
  const citations = [];
Open commit View diff
162 const citations = [];
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
163
  const contextBlocks: string[] = [];
Open commit View diff
163 const contextBlocks: string[] = [];
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
164
  for (const page of pages.slice(0, 4)) {
Open commit View diff
164 for (const page of pages.slice(0, 4)) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
165
    const detail = await getPageBySlug(page.slug, user);
Open commit View diff
165 const detail = await getPageBySlug(page.slug, user);
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
166
    if (!detail) {
Open commit View diff
166 if (!detail) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
167
      continue;
Open commit View diff
167 continue;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
168
    }
Open commit View diff
168 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
169
Open commit View diff
169
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
170
    citations.push({
Open commit View diff
170 citations.push({
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
171
      title: detail.title,
Open commit View diff
171 title: detail.title,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
172
      slug: detail.slug
Open commit View diff
172 slug: detail.slug
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
173
    });
Open commit View diff
173 });
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
174
    contextBlocks.push(`Title: ${detail.title}\nSlug: ${detail.slug}\nContent:\n${detail.bodyMarkdown.slice(0, 3000)}`);
Open commit View diff
174 contextBlocks.push(`Title: ${detail.title}\nSlug: ${detail.slug}\nContent:\n${detail.bodyMarkdown.slice(0, 3000)}`);
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
175
  }
Open commit View diff
175 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
176
Open commit View diff
176
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
177
  if (contextBlocks.length === 0) {
Open commit View diff
177 if (contextBlocks.length === 0) {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
178
    return {
Open commit View diff
178 return {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
179
      answer: "The knowledge base does not contain enough information to answer that.",
Open commit View diff
179 answer: "The knowledge base does not contain enough information to answer that.",
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
180
      citations: [],
Open commit View diff
180 citations: [],
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
181
      disabled: false
Open commit View diff
181 disabled: false
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
182
    };
Open commit View diff
182 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
183
  }
Open commit View diff
183 }
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
184
Open commit View diff
184
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
185
  const prompt = `Question:\n${question}\n\nKnowledge base excerpts:\n\n${contextBlocks.join("\n\n---\n\n")}\n\nRespond with a concise answer grounded in the excerpts only.`;
Open commit View diff
185 const prompt = `Question:\n${question}\n\nKnowledge base excerpts:\n\n${contextBlocks.join("\n\n---\n\n")}\n\nRespond with a concise answer grounded in the excerpts only.`;
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
186
  const answer = await generateWithProvider(provider, prompt);
Open commit View diff
186 const answer = await generateWithProvider(provider, prompt);
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
187
  const normalizedAnswer =
Open commit View diff
187 const normalizedAnswer =
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
188
    answer || "The knowledge base does not contain enough information to answer that.";
Open commit View diff
188 answer || "The knowledge base does not contain enough information to answer that.";
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
189
Open commit View diff
189
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
190
  await pool.query(
Open commit View diff
190 await pool.query(
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
191
    `
Open commit View diff
191 `
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
192
      INSERT INTO ai_answer_logs (user_id, question, answer, citations)
Open commit View diff
192 INSERT INTO ai_answer_logs (user_id, question, answer, citations)
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
193
      VALUES ($1, $2, $3, $4)
Open commit View diff
193 VALUES ($1, $2, $3, $4)
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
194
    `,
Open commit View diff
194 `,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
195
    [user?.id ?? null, question, normalizedAnswer, JSON.stringify(citations)]
Open commit View diff
195 [user?.id ?? null, question, normalizedAnswer, JSON.stringify(citations)]
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
196
  );
Open commit View diff
196 );
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
197
Open commit View diff
197
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
198
  return {
Open commit View diff
198 return {
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
199
    answer: normalizedAnswer,
Open commit View diff
199 answer: normalizedAnswer,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
200
    citations,
Open commit View diff
200 citations,
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
201
    disabled: false
Open commit View diff
201 disabled: false
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
202
  };
Open commit View diff
202 };
same change 5600eb6

Build enterprise imports webhooks and AI admin workflows

Full commit hash
5600eb6c876ab31ee652ee6abe12884b31088496
Author
Alex Nord <[email protected]>
Date
3 months ago
Selected line
203
}
Open commit View diff
203 }