Skip to content
Draft
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
28 changes: 28 additions & 0 deletions examples/chat-groq/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# AI providers
GROQ_API_KEY= # gsk-xxx... (Get your API key from https://console.groq.com/keys)
OPENAI_API_KEY= # sk-xxx... (Optional, only needed for image generation)
EXA_API_KEY= # To enable web searches

# Pipedream credentials
# Read more here: https://pipedream.com/docs/connect/mcp/developers/#prerequisites
PIPEDREAM_CLIENT_ID=
PIPEDREAM_CLIENT_SECRET=
PIPEDREAM_PROJECT_ID= # proj_xxxxxxx
PIPEDREAM_PROJECT_ENVIRONMENT= # development | production

# Chat app configs
DISABLE_AUTH=true # Disable user sign-in (useful when developing locally and getting started)
DISABLE_PERSISTENCE=true # Disable any chat or session storage (useful when developing locally and getting started)
EXTERNAL_USER_ID= # You'll pass this via code in practice, but you can hardcode it here while developing

# Generate a random secret: https://generate-secret.vercel.app/32 or `openssl rand -base64 32`
AUTH_SECRET=

# For user sign-in in the chat app using nextauth
# Make sure to also add the appropriate redirect URIs in Google Cloud for your OAuth app
# GOOGLE_CLIENT_ID= # For enabling Google OAuth in the chat app
# GOOGLE_CLIENT_SECRET= # For enabling Google OAuth in the chat app

# Datadog (Optional)
# NEXT_PUBLIC_DATADOG_APPLICATION_ID=
# NEXT_PUBLIC_DATADOG_CLIENT_TOKEN=
22 changes: 22 additions & 0 deletions examples/chat-groq/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": [
"next/core-web-vitals",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier",
"plugin:tailwindcss/recommended"
],
"plugins": ["tailwindcss"],
"rules": {
"tailwindcss/no-custom-classname": "off",
"tailwindcss/classnames-order": "off"
},
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
},
"ignorePatterns": ["**/components/ui/**"]
}
25 changes: 25 additions & 0 deletions examples/chat-groq/.github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint
on:
push:

jobs:
build:
runs-on: ubuntu-22.04
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.12.3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Run lint
run: pnpm lint
72 changes: 72 additions & 0 deletions examples/chat-groq/.github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

jobs:
test:
timeout-minutes: 30
runs-on: ubuntu-latest
env:
AUTH_SECRET: ${{ secrets.AUTH_SECRET }}
POSTGRES_URL: ${{ secrets.POSTGRES_URL }}
BLOB_READ_WRITE_TOKEN: ${{ secrets.BLOB_READ_WRITE_TOKEN }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: latest
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT

- uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: "pnpm"

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Cache Playwright browsers
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}

- name: Install Playwright Browsers
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: pnpm exec playwright install --with-deps chromium

- name: Run Playwright tests
run: pnpm test

- uses: actions/upload-artifact@v4
if: always() && !cancelled()
with:
name: playwright-report
path: playwright-report/
retention-days: 7
44 changes: 44 additions & 0 deletions examples/chat-groq/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
.pnp
.pnp.js
.pnpm-store

# testing
coverage

# next.js
.next/
out/
build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# turbo
.turbo

.env
.vercel
.env*.local

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/*
1 change: 1 addition & 0 deletions examples/chat-groq/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 18.18.0
3 changes: 3 additions & 0 deletions examples/chat-groq/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
17 changes: 17 additions & 0 deletions examples/chat-groq/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.workingDirectories": [
{ "pattern": "app/*" },
{ "pattern": "packages/*" }
]
}
61 changes: 61 additions & 0 deletions examples/chat-groq/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# syntax=docker.io/docker/dockerfile:1

FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat python3 make g++
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \
else echo "Lockfile not found." && exit 1; \
fi


# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
# ENV NEXT_TELEMETRY_DISABLED=1

RUN corepack enable pnpm && pnpm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV=production
# Uncomment the following line in case you want to disable telemetry during runtime.
# ENV NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT=3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/config/next-config-js/output
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
13 changes: 13 additions & 0 deletions examples/chat-groq/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2024 Vercel, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
95 changes: 95 additions & 0 deletions examples/chat-groq/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
## Pipedream Chat - Groq Edition

A high-performance implementation of Pipedream's MCP server integration powered by Groq's blazing-fast LLMs. This demo provides access to 10,000+ tools across 2,700+ APIs through a conversational interface, leveraging Groq's industry-leading inference speeds.

> Based on the [Next.js AI Chatbot](https://chat.vercel.ai/) and [Pipedream Chat](https://chat.pipedream.com)

### Key Features

- **Groq-powered inference**: Lightning-fast responses using Groq's LLMs including Llama 3.3, DeepSeek R1, and Gemma2
- **MCP integrations**: Connect to thousands of APIs through Pipedream's MCP server with built-in auth
- **Optimized for tool use**: Leverage Groq's specialized tool-use models for enhanced function calling
- **Tool discovery**: Execute tool calls across different APIs via chat

> Check out [Pipedream's developer docs](https://pipedream.com/docs/connect/mcp/developers) for the most up to date information.

### Development Mode

For local development, you can disable authentication and persistence:

```bash
# In your .env file
DISABLE_AUTH=true
DISABLE_PERSISTENCE=true
EXTERNAL_USER_ID=your-dev-user-id
```

This allows you to test the chat functionality without setting up authentication or database persistence.

> [!IMPORTANT]
> Treat this project as a reference implementation for integrating MCP servers into AI applications.

## Model Providers

This app is optimized for Groq's high-performance models:

- **DeepSeek R1 Distill Llama 70B**: Advanced reasoning with 128k context
- **Llama 3.3 70B Versatile**: Latest Llama model for versatile tasks
- **Llama 3.1 8B Instant**: Fast, lightweight model for quick responses
- **Llama 3 Groq Tool Use models**: Optimized for function calling (70B and 8B variants)
- **Gemma2 9B IT**: Google's efficient instruction-tuned model

## Running locally

You can run this chat app in two ways:

### Option 1: From the monorepo root (recommended)

If you're working within the full MCP monorepo:

```bash
# From the root of the monorepo
cp .env.example .env # Edit with your values, including GROQ_API_KEY
pnpm install
pnpm chat-groq
```

This will automatically use the `.env` file from the root directory and start the chat app.

### Option 2: From this directory

If you're working directly in the chat example:

```bash
# From examples/chat directory
cp .env.example .env # Edit with your values
```

Then run all required local services:

```bash
docker compose up -d
```

Run migrations:

```bash
POSTGRES_URL=postgresql://postgres@localhost:5432/postgres pnpm db:migrate
```

Then start the app:

```bash
pnpm install
pnpm chat
```

### Configuration

By default the client will point at https://remote.mcp.pipedream.net. Use the `MCP_SERVER` env var to point to an MCP server running locally:

```bash
MCP_SERVER=http://localhost:3010 pnpm chat
```

Your local app should now be running on [http://localhost:3000](http://localhost:3000/).
Loading