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.
Binary file added demo/.DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions demo/csv-analyzer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# CSV Analyzer with LangDB

Ask natural language questions about your large CSV data! This app uses [LangDB](https://langdb.dev) to take your questions and analyze the data behind the scenes.

## Features

- Upload any CSV file (like LinkedIn engagement data)
- Ask questions in plain English
- Get smart insights
- Powered by [LangDB](https://github.com/langdb/pylangdb)

## Setup Instructions

1. **Clone the repo**
```bash
git clone https://github.com/langdb/pylangdb.git
cd demo/csv-analyzer
```

2. **Install dependencies**
```bash
pip install -r requirements.txt
```

3. **Set your LangDB API key**
- Create a `.env` file:
```bash
LANGDB_API_KEY=langdb_XXXXXX
```

- Never commit this file to Git. Add it in `.gitignore`

4. **Add your CSV file**

5. **Run the app**
```bash
python app.py
```

28 changes: 28 additions & 0 deletions demo/csv-analyzer/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pandas as pd
from pylangdb import LangDb
from dotenv import load_dotenv
import os

load_dotenv()
API_KEY = os.getenv("LANGDB_API_KEY")

# Read CSV
df = pd.read_csv("sample.csv")
data = df.to_dict(orient='records')

question = "Analyze the engagement data of company's LinkedIn page for April month. What are the key insights and trends? Suggestions to improve the engagement rate?"

messages = [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": f'Analyze this CSV file data: {data} and nswer the question: {question}'},
]
# Call Gemini Model using LangDB
client = LangDb(api_key=API_KEY)
response = client.completion(
model="gemini-1.5-pro-latest",
messages=messages,
temperature=0.7,
# max_tokens=1000,
)

print(response['content'])