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: 1 addition & 1 deletion .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build and Push Docker Image
on:
push:
branches:
- '**' # Run on all branches
- 'main'
tags:
- 'v*.*.*'
pull_request:
Expand Down
66 changes: 66 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Contributing to OpenBookLM

First off, thank you for considering contributing to OpenBookLM! It's people like you that make OpenBookLM such a great tool for democratizing learning with AI.

We welcome all types of contributions: bug reports, bug fixes, documentation improvements, new features, and design tweaks. This document provides a simple guide to help you get started.

## How to Contribute

### 1. Fork the Repository
Start by forking the [OpenBookLM repository](https://github.com/open-biz/OpenBookLM) to your own GitHub account. You can do this by clicking the **Fork** button at the top right of the repository page.

### 2. Clone Your Fork
Clone the forked repository to your local machine:

```bash
git clone https://github.com/YOUR_USERNAME/OpenBookLM.git
cd OpenBookLM
```

### 3. Create a Feature Branch
Create a new branch for your feature or bugfix. Use a descriptive name for your branch:

```bash
git checkout -b feature/your-amazing-feature
# or for a bugfix:
git checkout -b fix/your-bugfix-name
```

### 4. Make Your Changes
Make your changes to the codebase. Remember to:
- Follow the existing code style and conventions.
- Keep your changes focused on a single feature or bug.
- Add or update tests if applicable.

### 5. Commit Your Changes
Write clear, concise commit messages. We prefer the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) format:

```bash
git commit -m "feat(ui): add new audio generation settings panel"
```

### 6. Push to Your Fork
Push your changes to your fork on GitHub:

```bash
git push origin feature/your-amazing-feature
```

### 7. Submit a Pull Request
Go back to the original OpenBookLM repository and you will see a prompt to **Compare & pull request**.
- Click it, and fill out the pull request template.
- Clearly describe what changes you've made and why.
- Link any relevant issues (e.g., "Closes #42").

## PR Format Guidelines
- **Title:** Use a clear, descriptive title (e.g., `feat: integrate WebAssembly for local token counting`).
- **Description:** Provide a brief summary of the changes, the motivation behind them, and how to test them.
- **Screenshots:** If your PR includes UI changes, please attach before/after screenshots or GIFs.

## Code of Conduct
Please be respectful and considerate of others when communicating in issues and pull requests. We aim to foster a welcoming and inclusive community.

## Need Help?
If you're stuck or have questions, feel free to open a draft PR or create an issue asking for guidance. We are happy to help!

Thank you for contributing! 🚀
11 changes: 4 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use the official Bun image
FROM oven/bun:1.1 AS base
FROM oven/bun:latest AS base
WORKDIR /app

# No Clerk environment variables
Expand Down Expand Up @@ -34,10 +34,6 @@ WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1

# Create system user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

# Copy built application
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/bun.lock ./bun.lock
Expand All @@ -48,9 +44,10 @@ COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/prisma ./prisma

# Set permissions
RUN chown -R nextjs:nodejs .
# Since we are using the official bun image, we just use the built-in bun user
RUN chown -R bun:bun .

USER nextjs
USER bun

EXPOSE 3000

Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,7 @@ To get a local copy up and running, follow these steps.

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
Please see our [CONTRIBUTING.md](CONTRIBUTING.md) file for detailed guidelines on how to fork the repository, structure your branches, format your pull requests, and start building!

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
12 changes: 6 additions & 6 deletions src/app/api/chat/history/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export async function GET(req: Request) {
const user = await getCurrentUser();
const userId = user?.id;
if (!userId) {
return new NextResponse("Unauthorized", { status: 401 });
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const url = new URL(req.url);
const notebookId = url.searchParams.get("notebookId");
if (!notebookId) {
return new NextResponse("NotebookId is required", { status: 400 });
return NextResponse.json({ error: "NotebookId is required" }, { status: 400 });
}

const key = `chat:${userId}:${notebookId}`;
Expand Down Expand Up @@ -67,7 +67,7 @@ export async function GET(req: Request) {
return NextResponse.json(messages);
} catch (error) {
console.error("[CHAT_HISTORY_GET]", error);
return new NextResponse("Internal Error", { status: 500 });
return NextResponse.json({ error: "Internal Error" }, { status: 500 });
}
}

Expand All @@ -76,12 +76,12 @@ export async function POST(req: Request) {
const user = await getCurrentUser();
const userId = user?.id;
if (!userId) {
return new NextResponse("Unauthorized", { status: 401 });
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const { messages, notebookId } = await req.json();
if (!notebookId || !Array.isArray(messages)) {
return new NextResponse("Invalid request data", { status: 400 });
return NextResponse.json({ error: "Invalid request data" }, { status: 400 });
}

// Save to database first
Expand All @@ -107,6 +107,6 @@ export async function POST(req: Request) {
return NextResponse.json({ success: true });
} catch (error) {
console.error("[CHAT_HISTORY_POST]", error);
return new NextResponse("Internal Error", { status: 500 });
return NextResponse.json({ error: "Internal Error" }, { status: 500 });
}
}
4 changes: 2 additions & 2 deletions src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function POST(req: Request) {
try {
const user = await getOrCreateUser();
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const body = await req.json();
Expand Down Expand Up @@ -167,6 +167,6 @@ const finalMessages = [
{ status: 400 }
);
}
return new NextResponse("Internal Error", { status: 500 });
return NextResponse.json({ error: "Internal Error" }, { status: 500 });
}
}
12 changes: 6 additions & 6 deletions src/app/api/notebooks/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export async function GET(
) {
const params = await props.params;
try {
const user = await getOrCreateUser();
const user = await getOrCreateUser(true);
if (!user) {
return NextResponse.json(
{ error: "Please sign in to access notebooks" },
Expand Down Expand Up @@ -83,15 +83,15 @@ export async function PUT(
) {
const params = await props.params;
try {
const user = await getCurrentUser();
const user = await getOrCreateUser(true);
const userId = user?.id;
if (!userId) {
return new NextResponse("Unauthorized", { status: 401 });
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const redis = getRedisClient();
if (!redis) {
return new NextResponse("Redis connection failed", { status: 500 });
return NextResponse.json({ error: "Redis connection failed" }, { status: 500 });
}

const notebook = await req.json();
Expand All @@ -102,7 +102,7 @@ export async function PUT(
return NextResponse.json({ success: true });
} catch (error) {
console.error("[NOTEBOOK_PUT]", error);
return new NextResponse("Internal Error", { status: 500 });
return NextResponse.json({ error: "Internal Error" }, { status: 500 });
}
}

Expand All @@ -112,7 +112,7 @@ export async function PATCH(
) {
const params = await props.params;
try {
const user = await getOrCreateUser();
const user = await getOrCreateUser(true);
if (!user) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
Expand Down
14 changes: 7 additions & 7 deletions src/app/api/notebooks/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export async function GET() {
const currentUser = await getCurrentUser();
const userId = currentUser?.id;
if (!userId) {
return new NextResponse("Unauthorized", { status: 401 });
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const user = await getOrCreateUser();
const user = await getOrCreateUser(true);
const notebooks = await prisma.notebook.findMany({
where: {
userId: user?.id,
Expand All @@ -28,22 +28,22 @@ export async function GET() {
return NextResponse.json(notebooks);
} catch (error) {
console.error("[NOTEBOOKS_GET]", error);
return new NextResponse("Internal Error", { status: 500 });
return NextResponse.json({ error: "Internal Error" }, { status: 500 });
}
}

export async function POST(req: Request) {
try {
const user = await getOrCreateUser();
const user = await getOrCreateUser(true);
if (!user) {
return new NextResponse("Unauthorized", { status: 401 });
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const body = await req.json();
const { title, provider } = body;

if (!title) {
return new NextResponse("Title is required", { status: 400 });
return NextResponse.json({ error: "Title is required" }, { status: 400 });
}

const notebook = await prisma.notebook.create({
Expand All @@ -58,6 +58,6 @@ export async function POST(req: Request) {
return NextResponse.json(notebook);
} catch (error) {
console.error("[NOTEBOOKS_POST]", error);
return new NextResponse("Internal Error", { status: 500 });
return NextResponse.json({ error: "Internal Error" }, { status: 500 });
}
}
Loading
Loading