Skip to content

Instantly share code, notes, and snippets.

@RajGM
RajGM / tables.js
Last active September 2, 2024 07:30
old contents table:
id
audio_transcription_id foreign key
data {title, content}
instructions {title, prompt, output_language}
contents table:
id
audio_transcription_id foreign key
title text
@RajGM
RajGM / error.js
Last active August 28, 2024 12:52
// -------------URL GENERATION WORKING-----------------
const querystring = require('querystring');
function buildAuthorizationUrl() {
const authorizationUrl = 'https://oauth.staging.blink.sv/oauth2/auth';
const params = {
response_type: 'code',
client_id: 'e894e905-3e7f-4705-a9a7-9fee4497ca4e',
redirect_uri: 'https://tg-staging.lightningnode.info/callback',

Base IP - URL for HTTP/HTTPS request - 139.59.43.126

Table Schema and sample data

CREATE TABLE "public"."users" (
    "id" UUID PRIMARY KEY,
    "created_at" TIMESTAMPTZ NOT NULL,
    "email" TEXT NOT NULL,
    "avatar_url" TEXT,
{
"originalArticle": "Version 1: Truthful Incident A human finger was discovered in a tub of ice cream purchased from a local grocery store in Springfield. The shocking find was made by a customer who immediately reported it to the authorities. Springfield Police Department has launched an investigation to determine how the finger ended up in the ice cream.",
"questions": [
"Was the human finger found in the tub of ice cream confirmed to be real?",
"Did the local grocery store immediately remove all tubs of ice cream from the same batch from its shelves?",
"Have there been any previous complaints about foreign objects found in products from the same grocery store?",
"Is the customer who found the finger considering legal action against the grocery store or the ice cream manufacturer?",
"Is the ice cream manufacturer cooperating with the authorities in the investigation?",
"Are there any indications of intentional tampering with the ice cream batch?",
"Has the public health depa
// const apiKey = "12e147cd-d402-40bb-a040-d998e66a2505";
// import { Pinecone } from '@pinecone-database/pinecone';
// const pc = new Pinecone({
// apiKey: '12e147cd-d402-40bb-a040-d998e66a2505'
// });
// const indexName = "docs-quickstart-index"
const chatWithNote = async (question, email, filters = {}) => {
filters.email = email; // Add email to filters
const matches = await queryVectors(question, filters);
if (matches.length === 0) {
return "Sorry, I couldn't find any relevant information.";
}
// Concatenate all matched texts to form the context
const context = matches.map(match => match.metadata.text).join('\n');
// Define the /api/magicChat POST endpoint
app.post('/api/magicChat', async (req, res) => {
const { history, email, note_id, tags, folder } = req.body;
const question = history[history.length()-1]
try {
// Create filters object
const filters = {};
if (note_id) filters.note = note_id;
if (tags && tags.length > 0) filters.tags = tags;
if (folder) filters.folder = folder;
// const apiKey = "12e147cd-d402-40bb-a040-d998e66a2505";
// import { Pinecone } from '@pinecone-database/pinecone';
// const pc = new Pinecone({
// apiKey: '12e147cd-d402-40bb-a040-d998e66a2505'
// });
// const indexName = "docs-quickstart-index"
app.post('/exportcsv/', async (req, res) => {
try {
// Verify the access token and get the user
const authHeader = req.headers.authorization;
if (!authHeader || !authHeader.startsWith('Bearer ')) {
return res.status(401).json({ error: 'Authorization header missing or invalid' });
}
const accessToken = authHeader.split(' ')[1];