Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
41c5c44
Add openrouter support
HamedMP Aug 20, 2024
9255c8b
feat: cost configuration and calculations for stats page
gruckion Aug 18, 2024
185c9d5
chore: refactor model config into a single object
gruckion Aug 20, 2024
932d2d2
chore: fix persist config
gruckion Aug 20, 2024
3b8de2a
Add maxToken 8192 for Anthropic
HamedMP Aug 21, 2024
a712346
Update AI sdk
HamedMP Aug 22, 2024
f1d9db4
Update LogDetails to have collpsable sections for easy debugging
HamedMP Aug 22, 2024
dcea389
Add anthropicCached provider for configuring cached client for Anthropic
HamedMP Aug 22, 2024
58140b5
Update stats page to separate same model name but from different prov…
HamedMP Aug 22, 2024
3dbd02c
Log all properties in onFinish hook
HamedMP Aug 22, 2024
5deeb18
Upgrade anthropic's version
HamedMP Aug 22, 2024
de22739
Add testAnthropicCached to GET routes
HamedMP Aug 22, 2024
0cfb3a3
Revert "Add caching support for Anthropic Sonnet 3.5"
HamedMP Aug 22, 2024
39fe8e2
Revert "Revert "Add caching support for Anthropic Sonnet 3.5""
HamedMP Aug 22, 2024
3142fce
Update screenshot
HamedMP Aug 22, 2024
1d505b4
Set max token for both anthropic providers
HamedMP Aug 22, 2024
6f081ae
Log the input object to streamText in full
HamedMP Aug 22, 2024
82b4b3e
Apply Cache control to Cursor Tab messages as well (to the second obj…
HamedMP Aug 22, 2024
ce6072d
Update README
HamedMP Aug 22, 2024
aa83567
Update README
HamedMP Aug 22, 2024
a88a4a3
Add new shadcn components
HamedMP Aug 24, 2024
b5d9025
Add CostModel, add costs per api call in saving time and update logs/…
HamedMP Aug 24, 2024
c8fed0b
Create seed and retroactive cost calculation scripts
HamedMP Aug 24, 2024
006b584
Update readme with instructions
HamedMP Aug 24, 2024
00d6327
Add docker support
HamedMP Aug 24, 2024
1b95f37
Add openrouter support
HamedMP Aug 24, 2024
4684801
Add openrouter support + their model costs to seed script
HamedMP Aug 24, 2024
1ca98b5
chore: refactor model config into a single object
gruckion Aug 20, 2024
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 .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ ANTHROPIC_API_KEY=your_anthropic_api_key_here
COHERE_API_KEY=your_cohere_api_key_here
MISTRAL_API_KEY=your_mistral_api_key_here
GROQ_API_KEY=your_groq_api_key_here

OPENROUTER_API_KEY=
DATABASE_URL=
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

.env
.env
certificates
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM node:18-alpine

WORKDIR /app

RUN apk add --no-cache libc6-compat
RUN apk update

# Install pnpm
RUN npm install -g pnpm

# Copy package.json and pnpm-lock.yaml
COPY package.json pnpm-lock.yaml ./

# Install dependencies
RUN pnpm install

# Copy the rest of the application
COPY . .

# Generate Prisma Client
RUN pnpm prisma generate

# Build the application
RUN pnpm run build

# Expose the port the app runs on
EXPOSE 3000

# Start the application
CMD ["sh", "./start.sh"]
71 changes: 70 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,76 @@ For full details on each step, please see the [Installation Guide](https://www.c

## Stats page

![Cursor Lens Stats](public/cl-stats.png)
![Cursor Lens Stats](public/cl-stats.jpeg)

## Prompt caching with Anthropic (v0.1.2):

1. Create a new config on `/configuration` page, choose `antropicCached` with Sonnet 3.5. Name it as you like.
2. Mark it as default.
3. Use Cursor with CursorLens as normal. The system and context messages in `CMD+L` and `CMD+i` chats will be cached from now on.

> Note that TTL for the cache is 5 minutes.

![Add a new config with Antropic Cached](public/anthropicCashedXConfig.png)
![Example Cache creation response](public/ant-cache-create.png)
![Example Cache read response](public/ant-cache-read.png)

# Releases

## Nightly - 2024-08-24

- Add new cost calculation

To run it, make sure to run:

- `npx prisma seed db` and then
- `pnpm run update-log-costs` to add cost info in metadata for all previous logs

## [0.1.2-alpha] - 2024-08-22

### ⚠️ ALPHA RELEASE

### Added

- Add Anthropic Cache support for context messages
- Increase Token limit for Anthropic to 8192 tokens
- Improved statistics page: Now you can select the data points you want to see

### Improved and fixed

- Log details are now collapsible
- Full response is captured in the logs

## [0.1.1-alpha] - 2024-08-18

### ⚠️ ALPHA RELEASE

### Added

- Added support for Mistral AI, Cohere, Groq, and Ollama

## [0.1.0-alpha] - 2024-08-17

This is the initial alpha release of CursorLens. As an alpha version, it may contain bugs and is not yet feature-complete. Use with caution in non-production environments.

### Added

- Initial project setup with Next.js
- Basic proxy functionality between Cursor and AI providers (OpenAI, Anthropic)
- Simple dashboard for viewing AI interaction logs
- Token usage tracking for OpenAI and Anthropic models
- Basic cost estimation based on token usage
- Support for PostgreSQL database with Prisma ORM
- Environment variable configuration for API keys and database connection
- Basic error handling and logging

### Known Issues

- Limited error handling for edge cases
- Incomplete test coverage
- Basic UI with limited customization options
- Potential performance issues with large volumes of requests
- Cost calculation for cached messages in Anthropic are not correct

## Contributing

Expand Down
41 changes: 41 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
services:
db:
image: postgres:14
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 5s
timeout: 5s
retries: 5
ports:
- "5432:5432"

app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
depends_on:
db:
condition: service_healthy

ngrok:
image: ngrok/ngrok:latest
environment:
NGROK_AUTHTOKEN: ${NGROK_AUTHTOKEN}
command: http app:3000
ports:
- "4040:4040"
depends_on:
- app

volumes:
postgres_data:
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"seed": "tsx prisma/seed.ts"
"seed": "tsx prisma/seed.ts",
"update-log-costs": "tsx scripts/update-log-costs.ts"
},
"prisma": {
"seed": "tsx prisma/seed.ts"
},
"dependencies": {
"@ai-sdk/amazon-bedrock": "^0.0.17",
"@ai-sdk/anthropic": "^0.0.41",
"@ai-sdk/anthropic": "^0.0.46",
"@ai-sdk/cohere": "^0.0.17",
"@ai-sdk/google-vertex": "^0.0.28",
"@ai-sdk/mistral": "^0.0.34",
Expand All @@ -25,13 +26,14 @@
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.1.1",
"@radix-ui/react-progress": "^1.1.0",
"@radix-ui/react-scroll-area": "^1.1.0",
"@radix-ui/react-select": "^2.1.1",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@t3-oss/env-nextjs": "^0.11.0",
"@types/react-syntax-highlighter": "^15.5.13",
"ai": "^3.3.7",
"ai": "^3.3.14",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
Expand Down
Loading