Skip to content
Merged
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

A lightweight chat interface for LLMs. Designed as a minimalist alternative to Open WebUI or LibreChat.

**[Try the Demo](https://feather-demo.vercel.app)** (simulated responses)

![app home screen](assets/feather-home.png)

## Quick Start
Expand Down
2 changes: 2 additions & 0 deletions client/.env.demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_DEMO_MODE=true
VITE_API_URL=http://localhost:3001
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"build:demo": "tsc && vite build --mode demo",
"preview": "vite preview"
},
"dependencies": {
Expand Down
26 changes: 26 additions & 0 deletions client/src/components/DemoBanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
export function DemoBanner() {
const isDemoMode = import.meta.env.VITE_DEMO_MODE === 'true';

if (!isDemoMode) return null;

return (
<div className="bg-yellow-50 dark:bg-yellow-900/20 border-b border-yellow-200 dark:border-yellow-800 px-4 py-3">
<div className="max-w-4xl mx-auto flex items-center justify-between gap-4 text-sm">
<div className="flex items-center gap-2">
<span className="text-yellow-800 dark:text-yellow-200">
⚡ <strong>Demo Mode</strong> - This is a showcase with simulated
responses.
</span>
</div>
<a
href="https://github.com/hunterphillips/feather"
target="_blank"
rel="noopener noreferrer"
className="flex items-center gap-1 px-3 py-1 bg-yellow-600 hover:bg-yellow-700 text-white rounded-md font-medium whitespace-nowrap transition-colors"
>
Get the Real Version →
</a>
</div>
</div>
);
}
87 changes: 46 additions & 41 deletions client/src/components/chat/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ModelSelector } from './ModelSelector';
import { Sidebar } from '../Sidebar';
import { Toast, useToast } from '../ui/toast';
import { useChatSession } from '../../hooks/useChatSession';
import { DemoBanner } from '../DemoBanner';

export function ChatView() {
const [sidebarOpen, setSidebarOpen] = useState(true);
Expand Down Expand Up @@ -70,57 +71,61 @@ export function ChatView() {
};

return (
<div className="flex h-screen bg-background text-foreground">
{/* Sidebar */}
<Sidebar
isOpen={sidebarOpen}
onToggle={() => setSidebarOpen(!sidebarOpen)}
onNewChat={onNewChat}
onSelectChat={onSelectChat}
currentChatId={id || null}
/>
<div className="flex flex-col h-screen bg-background text-foreground">
<div className="flex flex-1 overflow-hidden">
{/* Sidebar */}
<Sidebar
isOpen={sidebarOpen}
onToggle={() => setSidebarOpen(!sidebarOpen)}
onNewChat={onNewChat}
onSelectChat={onSelectChat}
currentChatId={id || null}
/>

{/* Main Content Area */}
<div className="flex flex-col flex-1 overflow-hidden">
<ModelSelector />
{/* Main Content Area */}
<div className="flex flex-col flex-1 overflow-hidden">
{/* <DemoBanner /> */}
<ModelSelector />

{messages.length === 0 ? (
// empty chat layout
<div className="flex-1 flex flex-col items-center justify-center p-4">
<div className="w-full max-w-3xl">
<h2 className="text-3xl font-normal text-center mb-8 text-foreground">
What can I help you with?
</h2>
{messages.length === 0 ? (
// empty chat layout
<div className="flex-1 flex flex-col items-center justify-center p-4">
<div className="w-full max-w-3xl">
<h2 className="text-3xl font-normal text-center mb-8 text-foreground">
What can I help you with?
</h2>
<InputArea
input={input}
handleInputChange={handleInputChange as any}
handleSubmit={onSubmit}
isLoading={isLoading}
onStop={stop}
/>
</div>
</div>
) : (
// chat layout
<>
<ChatContainer messages={messages} isLoading={isLoading} />
<InputArea
input={input}
handleInputChange={handleInputChange as any}
handleSubmit={onSubmit}
isLoading={isLoading}
onStop={stop}
/>
</div>
</div>
) : (
// chat layout
<>
<ChatContainer messages={messages} isLoading={isLoading} />
<InputArea
input={input}
handleInputChange={handleInputChange as any}
handleSubmit={onSubmit}
isLoading={isLoading}
onStop={stop}
/>
</>
)}
<DemoBanner />
</>
)}

{toast && (
<Toast
message={toast.message}
variant={toast.variant}
onClose={hideToast}
/>
)}
{toast && (
<Toast
message={toast.message}
variant={toast.variant}
onClose={hideToast}
/>
)}
</div>
</div>
</div>
);
Expand Down
10 changes: 10 additions & 0 deletions client/src/hooks/useChatSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useConfigStore } from '../store/config-store';
import { useChatPersistence } from './useChatPersistence';
import { useFileUpload } from './useFileUpload';
import type { Attachment } from '@/lib/types';
import { handleDemoSubmit } from '@/lib/demo-stream';

export function useChatSession() {
const {
Expand All @@ -24,6 +25,7 @@ export function useChatSession() {

const { uploadFilesToChat, isUploading: isUploadingFiles } = useFileUpload();
const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:3001';
const DEMO_MODE = import.meta.env.VITE_DEMO_MODE === 'true';
const workflowTool = tools.find((tool) => tool.enabled && tool.isWorkflow);

// Aggregate Context from Tools
Expand Down Expand Up @@ -112,6 +114,13 @@ export function useChatSession() {
// Allow submission if there's either text or files
if (!input.trim() && pendingFiles.length < 1) return {};

// DEMO MODE: Use fake streaming responses
if (DEMO_MODE) {
await handleDemoSubmit(input, setMessages, setInput);
return {};
}

// REAL MODE: Use actual API call
let chatId = currentChatId;
let newChatId: string | undefined;

Expand Down Expand Up @@ -166,6 +175,7 @@ export function useChatSession() {
uploadFilesToChat,
append,
setInput,
setMessages,
clearPendingFiles,
setCurrentAttachments,
]
Expand Down
200 changes: 200 additions & 0 deletions client/src/lib/demo-stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import type { Message } from '@ai-sdk/react';

/**
* Generates fake streaming responses that mimic AI SDK format
* Returns canned responses based on message content
*/

const DEMO_RESPONSES = [
{
trigger: ['hello', 'hi', 'hey', 'greet'],
response: `Hi! 👋

I'm a **demo version** of Feather - a lightweight chat interface for AI workflows.

To use a model provider, download Feather from GitHub and run it locally with your own API keys.

**[Get Feather on GitHub →](https://github.com/hunterphillips/feather)**`,
},
{
trigger: ['what', 'how', 'can you', 'features', 'capabilities'],
response: `Great question! In the full version of Feather, you can:

- Chat with OpenAI, Anthropic, and Google models
- Use custom system prompts (Instructions tool)
- Upload files and images (vision models)
- Run workflows like consensus mode (query multiple models at once)
- Store chat history locally with LowDB

**[Get Feather on GitHub →](https://github.com/hunterphillips/feather)**`,
},
{
trigger: ['consensus', 'workflow', 'multiple models', 'tools'],
response: `Feather's **Consensus Mode** is really cool! It:

1. Queries multiple AI models in parallel
2. Collects all their responses
3. Uses a synthesizer model to combine insights
4. Gives you the best answer from all perspectives

You can try it yourself by downloading Feather and adding your API keys.

**[Get Feather on GitHub →](https://github.com/hunterphillips/feather)**`,
},
{
trigger: ['default'],
response: `Thanks for trying Feather! This is a **demo version** with simulated responses.

The real version lets you chat with models from OpenAI, Anthropic, and Google using your own API keys.

**Features:**
- 📋 Instructions: per chat custom instructions modifier
- 👥 Consensus: multi-model query with synthesized response
- 💾 Local data storage

**[Download Feather on GitHub →](https://github.com/hunterphillips/feather)**

Try asking me about features or custom tools included with Feather!`,
},
];

export function getDemoResponse(userMessage: string): string {
const lowerMessage = userMessage.toLowerCase();

// Find matching response based on triggers
for (const { trigger, response } of DEMO_RESPONSES) {
if (trigger.some((t) => lowerMessage.includes(t))) {
return response;
}
}

// Default response
return DEMO_RESPONSES.find((r) => r.trigger.includes('default'))!.response;
}

/**
* Creates a fake readable stream that mimics AI SDK streaming format
*/
export function createFakeStream(message: string): ReadableStream<Uint8Array> {
const response = getDemoResponse(message);
const encoder = new TextEncoder();
let index = 0;

return new ReadableStream({
async start(controller) {
// Simulate typing effect - send chunks character by character
while (index < response.length) {
// Send 2-5 characters at a time for more natural typing
const chunkSize = Math.floor(Math.random() * 4) + 2;
const chunk = response.slice(index, index + chunkSize);

// Format as AI SDK data stream protocol
const dataChunk = `0:${JSON.stringify(chunk)}\n`;
controller.enqueue(encoder.encode(dataChunk));

index += chunkSize;

// Random delay between 20-80ms for natural typing
await new Promise((resolve) =>
setTimeout(resolve, Math.random() * 60 + 20)
);
}

// Send completion message (AI SDK format)
controller.enqueue(encoder.encode('d:{"finishReason":"stop"}\n'));
controller.close();
},
});
}

/**
* Handles demo mode message submission
* Creates user message, streams fake assistant response, and updates message state
*/
export async function handleDemoSubmit(
input: string,
setMessages: (updater: (prev: Message[]) => Message[]) => void,
setInput: (value: string) => void
): Promise<void> {
if (!input.trim()) return;

const userMessage = {
id: crypto.randomUUID(),
role: 'user' as const,
content: input,
createdAt: new Date(),
};

const assistantMessage = {
id: crypto.randomUUID(),
role: 'assistant' as const,
content: '',
createdAt: new Date(),
};

// Add user message immediately
setMessages((prev) => [...prev, userMessage]);
setInput('');

// Stream fake response
const stream = createFakeStream(input);
const reader = stream.getReader();
const decoder = new TextDecoder();

try {
let buffer = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;

buffer += decoder.decode(value, { stream: true });
const lines = buffer.split('\n');
buffer = lines.pop() || ''; // Keep incomplete line in buffer

for (const line of lines) {
if (line.startsWith('0:')) {
// Extract text content and unescape
try {
const jsonString = line.slice(2); // Get the part after "0:"
const text = JSON.parse(jsonString); // Parse as JSON string
assistantMessage.content += text;
} catch (e) {
// Fallback if JSON.parse fails
const text = line.slice(2).replace(/^"|"$/g, '');
assistantMessage.content += text;
}
// Update messages to show streaming effect
setMessages((prev) => {
const existing = prev.find((m) => m.id === assistantMessage.id);
if (existing) {
return prev.map((m) =>
m.id === assistantMessage.id ? { ...assistantMessage } : m
);
} else {
return [...prev, assistantMessage];
}
});
}
}
}
} catch (error) {
console.error('Demo stream error:', error);

// Fallback: Set the full response immediately without streaming
if (!assistantMessage.content) {
assistantMessage.content = getDemoResponse(input);
}

// Ensure the message is added/updated
setMessages((prev) => {
const existing = prev.find((m) => m.id === assistantMessage.id);
if (existing) {
return prev.map((m) =>
m.id === assistantMessage.id ? { ...assistantMessage } : m
);
} else {
return [...prev, assistantMessage];
}
});
}
}
Loading