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
Binary file added .DS_Store
Binary file not shown.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ chatwithdelta is the typescript version of the cli tool, based on the ui provide

```bash
# First time only
npm install
bun install
```

```bash
export EMAIL_TARGET="your_email"
export SYSTEM_NAME="Delta"
export UIUC_API_KEY="your_uiuc_api_key"
export UIUC_COURSE_NAME="Delta-Documentation"
npm run start
export MODEL_URL="pre_hosted_uiuc.chat_llm_url"
bun run start
```

If you don't have an API key you can get one by creating an account at https://uiuc.chat and selecting the API tab were you can get your key.
1,060 changes: 1,060 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions chatwithDelta/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copy this file to .env and fill in the values
# Used by the CLI app (Ink) inside chatwithDelta

# Required
[email protected]
SYSTEM_NAME=Delta
UIUC_COURSE_NAME=Delta-Documentation
UIUC_API_KEY=uc_XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
MODEL_URL=https://llm.your_url/v1/

# OpenAI-compatible auth (used for pre-hosted model calls)
# If your MODEL_URL is OpenAI-compatible, set this key
OPENAI_API_KEY=sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

# Notes:
# - The app loads env from chatwithDelta/.env when running via `bun dev|start|build`.
# - MODEL_URL should point to an OpenAI-compatible endpoint base.
# Examples:
# https://api.openai.com/v1
# https://llm.uiuc.edu/v1
# - UIUC_API_KEY is required for the UIUC docs search endpoint.
34 changes: 24 additions & 10 deletions chatwithDelta/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,51 @@
"bin": "dist/index.js",
"type": "module",
"engines": {
"node": ">=16"
"node": ">=16",
"bun": ">=1.0.0"
},
"scripts": {
"dev": "ts-node-dev -r tsconfig-paths/register --respawn --no-pretty --exit-child src/index.tsx",
"build": "tsc && chmod +x dist/index.js",
"start": "npm run build && node dist/index.js",
"pretest": "npm run build"
"build": "bun build --target bun index.tsx --outdir dist",
"start": "bun run src/index.tsx",
"dev": "bun --watch src/index.tsx",
"pretest": "bun run build"
},
"dependencies": {
"@langchain/community": "^0.3.47",
"@langchain/core": "^0.3.61",
"@langchain/langgraph": "^0.3.5",
"@react-email/render": "^1.1.2",
"@types/better-sqlite3": "^7.6.13",
"better-sqlite3": "^11.10.0",
"ink": "^4.0.0",
"ink-select-input": "^6.2.0",
"ink-text-input": "^5.0.0",
"langchain": "^0.3.29",
"marked": "^15.0.12",
"marked-terminal": "^7.3.0",
"meow": "^9.0.0",
"nodemailer": "^6.10.1",
"openai": "^3.2.1",
"react": "^18.0.0",
"react-dom": "^18.2.0",
"zod": "^3.21.4"
"react-devtools-core": "^4.0.0",
"zod": "^4.0.0"
},
"peerDependencies": {
"react": ">=18",
"react-dom": ">=18"
},
"devDependencies": {
"@types/ink": "^0.5.2",
"@types/ink-select-input": "^3.0.5",
"@types/marked-terminal": "^6.1.1",
"@types/node": "^18.15.11",
"@types/nodemailer": "^6.4.17",
"@types/react": "^18.0.31",
"@types/react": "^18.3.23",
"bun-types": "^1.2.18",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0",
"ink-testing-library": "^3.0.0",
"ts-node-dev": "^2.0.0",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.0.3"
}
}
}
25 changes: 25 additions & 0 deletions chatwithDelta/src/config/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { z } from 'zod';

const envSchema = z.object({
EMAIL_TARGET: z.string().email(),
SYSTEM_NAME: z.string(),
UIUC_API_KEY: z.string(),
UIUC_COURSE_NAME: z.string(),
});

// Log current environment variables
console.log('Current environment variables:');
console.log('EMAIL_TARGET:', process.env['EMAIL_TARGET']);
console.log('SYSTEM_NAME:', process.env['SYSTEM_NAME']);
console.log('UIUC_COURSE_NAME:', process.env['UIUC_COURSE_NAME']);
console.log('UIUC_API_KEY:', process.env['UIUC_API_KEY'] ? '***' : 'not set');

// Only set defaults if environment variables are not already set
if (!process.env['SYSTEM_NAME']) process.env['SYSTEM_NAME'] = 'Delta';
if (!process.env['UIUC_COURSE_NAME']) process.env['UIUC_COURSE_NAME'] = 'Delta-Documentation';
if (!process.env['EMAIL_TARGET']) process.env['EMAIL_TARGET'] = '[email protected]';

/**
* Parsed environment variables.
*/
export const env = envSchema.parse(process.env);
19 changes: 15 additions & 4 deletions chatwithDelta/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,25 @@ const envSchema = z.object({
SYSTEM_NAME: z.string(),
UIUC_API_KEY: z.string(),
UIUC_COURSE_NAME: z.string(),
MODEL_URL: z.string(),
});

// Default value if not set by env variable
process.env['SYSTEM_NAME'] = 'Delta';
process.env['UIUC_COURSE_NAME'] = 'Delta-Documentation';
process.env['EMAIL_TARGET'] = '[email protected]';
// Set default environment variables if not already set
if (!process.env['UIUC_COURSE_NAME']) process.env['UIUC_COURSE_NAME'] = 'Delta-Documentation';
if (!process.env['SYSTEM_NAME']) process.env['SYSTEM_NAME'] = 'Delta';
if (!process.env['EMAIL_TARGET']) process.env['EMAIL_TARGET'] = '[email protected]';


// Log current environment variables
console.log('Current environment variables:');
console.log('EMAIL_TARGET:', process.env['EMAIL_TARGET']);
console.log('SYSTEM_NAME:', process.env['SYSTEM_NAME']);
console.log('UIUC_COURSE_NAME:', process.env['UIUC_COURSE_NAME']);
console.log('UIUC_API_KEY:', process.env['UIUC_API_KEY'] ? '***' : 'not set');
console.log('MODEL_URL:', process.env['MODEL_URL'] ? '***' : 'not set');

/**
* Parsed environment variables.
*/

export const env = envSchema.parse(process.env);
43 changes: 43 additions & 0 deletions chatwithDelta/src/types/marked-terminal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
declare module 'marked-terminal' {
interface TerminalRendererOptions {
code?: string;
blockquote?: string;
html?: string;
heading?: string;
firstHeading?: string;
hr?: string;
listitem?: string;
table?: string;
strong?: string;
em?: string;
codespan?: string;
del?: string;
link?: string;
href?: string;
}

class TerminalRenderer {
constructor(options?: TerminalRendererOptions);
code(code: string, language?: string): string;
blockquote(quote: string): string;
html(html: string): string;
heading(text: string, level: number): string;
hr(): string;
list(body: string, ordered: boolean): string;
listitem(text: string): string;
paragraph(text: string): string;
table(header: string, body: string): string;
tablerow(content: string): string;
tablecell(content: string, flags: { header: boolean; align?: string }): string;
strong(text: string): string;
em(text: string): string;
codespan(text: string): string;
br(): string;
del(text: string): string;
link(href: string, title: string, text: string): string;
image(href: string, title: string, text: string): string;
text(text: string): string;
}

export = TerminalRenderer;
}
4 changes: 4 additions & 0 deletions chatwithDelta/src/types/ui.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type ChatMessageT = {
role: "user" | "assistant" | "system";
content: string;
}
Loading