From d628bededf8a0810ad3ee7694a8e6557aae94088 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 11 Feb 2025 11:38:39 -0800 Subject: [PATCH 01/15] Add chatbot --- src/app/chat.tsx | 7 ++++--- src/app/layout.tsx | 13 +++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/app/chat.tsx b/src/app/chat.tsx index d58a9f928..4bf19949b 100644 --- a/src/app/chat.tsx +++ b/src/app/chat.tsx @@ -1,6 +1,6 @@ 'use client'; -import { Chatbot } from '@langbase/components'; +import {Chatbot} from '@langbase/components'; import '@langbase/components/styles'; export default function Chat() { @@ -11,8 +11,9 @@ export default function Chat() { background-color: #dedede; } `} - - {/* */} + {children} From ded9c9545879c23f7f0408a7531f50bc63eef59c Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Wed, 26 Feb 2025 11:01:23 -0800 Subject: [PATCH 02/15] Add starter questions --- src/app/chat.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/chat.tsx b/src/app/chat.tsx index 4bf19949b..32872d96c 100644 --- a/src/app/chat.tsx +++ b/src/app/chat.tsx @@ -17,20 +17,20 @@ export default function Chat() { // Remember AI can make mistakes, please double-check responses. suggestions={[ { - title: `What is SourceGraph?`, - prompt: `What is SourceGraph?` + title: `What is Sourcegraph?`, + prompt: `What is Sourcegraph?` }, { title: `What is Cody?`, prompt: `What is Cody?` }, { - title: `What can I do with Cody?`, - prompt: `What can I do with Cody?` + title: `Search query syntax?`, + prompt: `What is the search query syntax?` }, { - title: `What are search query types?`, - prompt: `What are search query types?` + title: `Language specific query examples?`, + prompt: `Give me language specific query examples?` } ]} /> From bd9e6e1b394044018463aac8fec1c09b0bddc234 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Thu, 27 Feb 2025 11:38:11 -0800 Subject: [PATCH 03/15] Add experimental badge --- src/app/chat.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/chat.tsx b/src/app/chat.tsx index 32872d96c..cdf350f18 100644 --- a/src/app/chat.tsx +++ b/src/app/chat.tsx @@ -12,6 +12,9 @@ export default function Chat() { } `} Date: Thu, 27 Feb 2025 11:58:38 -0800 Subject: [PATCH 04/15] update component to latest --- package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index ac6527a64..b5a10e180 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@docsearch/react": "3", "@headlessui/react": "^1.7.13", "@heroicons/react": "^2.0.18", - "@langbase/components": "^0.1.5", + "@langbase/components": "^0.1.6", "@mdx-js/mdx": "^3.0.1", "@next/third-parties": "^14.1.4", "@radix-ui/react-hover-card": "^1.1.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a70f5cad1..d7a3c0699 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,8 +27,8 @@ importers: specifier: ^2.0.18 version: 2.2.0(react@18.3.1) '@langbase/components': - specifier: ^0.1.5 - version: 0.1.5(@testing-library/dom@10.4.0)(@types/react-dom@18.2.7)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(tailwindcss@3.4.17)(vite@6.0.7(@types/node@20.4.9)(jiti@1.21.7)(yaml@2.7.0)) + specifier: ^0.1.6 + version: 0.1.6(@testing-library/dom@10.4.0)(@types/react-dom@18.2.7)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(tailwindcss@3.4.17)(vite@6.0.7(@types/node@20.4.9)(jiti@1.21.7)(yaml@2.7.0)) '@mdx-js/mdx': specifier: ^3.0.1 version: 3.1.0(acorn@8.14.0) @@ -813,8 +813,8 @@ packages: resolution: {integrity: sha512-n5JEf16Wr4mdkRMZ8wMP/wN9/sHmTjRPbouXjJH371mZ2LEGDl72t8tEsMRNFerQN/QJtivOxqK1frdGa4QK5Q==} engines: {node: '>=10'} - '@langbase/components@0.1.5': - resolution: {integrity: sha512-AVz0LygSCKQfl6DStza5+fmO8n9/pX85AE0phpn0Jbk+RNN42mK5tXjoDuTeh8/EAU0r8ndI1jk1q2Mo9G+cfw==} + '@langbase/components@0.1.6': + resolution: {integrity: sha512-HjZCiFeJ6klZD6iluQ15PIf+MrJtVVzgeFbulq0GC7MF6wwS7c5dd72UoAztBjT7Nt67+6GVec57aJjhLH5jzg==} engines: {node: '>=18'} peerDependencies: react: ^18 || ^19 @@ -6028,7 +6028,7 @@ snapshots: '@jsdevtools/rehype-toc@3.0.2': {} - '@langbase/components@0.1.5(@testing-library/dom@10.4.0)(@types/react-dom@18.2.7)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(tailwindcss@3.4.17)(vite@6.0.7(@types/node@20.4.9)(jiti@1.21.7)(yaml@2.7.0))': + '@langbase/components@0.1.6(@testing-library/dom@10.4.0)(@types/react-dom@18.2.7)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(tailwindcss@3.4.17)(vite@6.0.7(@types/node@20.4.9)(jiti@1.21.7)(yaml@2.7.0))': dependencies: '@baseai/core': 0.9.41(react@18.3.1)(zod@3.24.1) '@radix-ui/react-dialog': 1.1.4(@types/react-dom@18.2.7)(@types/react@18.3.18)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) From 98781a5a5a9f030a72a4895701aceb3eafd1d0d9 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 18 Mar 2025 17:26:43 -0700 Subject: [PATCH 05/15] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20memory=20refresh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- baseai/memory/docs/index.ts | 11 ++-- package.json | 3 +- pnpm-lock.yaml | 28 +++++++---- scripts/langbase-create-memory.ts | 18 +++++++ scripts/word-count.js | 83 +++++++++++++++++++++++++++++++ src/app/api/chat/route.ts | 36 ++++++++++++-- 6 files changed, 162 insertions(+), 17 deletions(-) create mode 100644 scripts/langbase-create-memory.ts create mode 100644 scripts/word-count.js diff --git a/baseai/memory/docs/index.ts b/baseai/memory/docs/index.ts index 33cff913e..c7c3cf6f5 100644 --- a/baseai/memory/docs/index.ts +++ b/baseai/memory/docs/index.ts @@ -1,14 +1,14 @@ import { MemoryI } from '@baseai/core'; const memoryDocs = (): MemoryI => ({ - name: 'docs', - description: 'Docs folder of sourcegraph docs repository as an auto-synced memory', + name: 'memory-sg-docs-live', + description: 'An AI memory storing all Sourcegraph docs.', git: { enabled: true, include: ['**/*.mdx'], gitignore: true, - deployedAt: '5f3fec8530280d01a783aadcdeb0ccc3f9cd8b70', - embeddedAt: '' + embeddedAt: '', + deployedAt: '', }, documents: { meta: doc => { @@ -22,3 +22,6 @@ const memoryDocs = (): MemoryI => ({ }); export default memoryDocs; + +// Old +// deployedAt: '5f3fec8530280d01a783aadcdeb0ccc3f9cd8b70', diff --git a/package.json b/package.json index b5a10e180..b10e7b074 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "github-slugger": "^2.0.0", "js-yaml": "^4.1.0", "kbar": "^0.1.0-beta.44", - "langbase": "^1.1.26", + "langbase": "^1.1.46", "lucide-react": "^0.372.0", "mdx": "^0.3.1", "next": "^14.2.3", @@ -68,6 +68,7 @@ }, "devDependencies": { "baseai": "^0.9.40", + "dotenv": "^16.4.7", "eslint": "8.45.0", "eslint-config-next": "13.4.16", "glob": "^11.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d7a3c0699..431a15c18 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -96,8 +96,8 @@ importers: specifier: ^0.1.0-beta.44 version: 0.1.0-beta.45(@types/react-dom@18.2.7)(@types/react@18.2.20)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) langbase: - specifier: ^1.1.26 - version: 1.1.26 + specifier: ^1.1.46 + version: 1.1.46(react@18.3.1) lucide-react: specifier: ^0.372.0 version: 0.372.0(react@18.3.1) @@ -168,6 +168,9 @@ importers: baseai: specifier: ^0.9.40 version: 0.9.41(@types/node@20.4.9)(typescript@5.1.6) + dotenv: + specifier: ^16.4.7 + version: 16.4.7 eslint: specifier: 8.45.0 version: 8.45.0 @@ -3277,9 +3280,14 @@ packages: resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} engines: {node: '>=6'} - langbase@1.1.26: - resolution: {integrity: sha512-lQNT5a98j3a5gDBGCWhinMI6UbdD5VjEOha7h8ixWo9px/+OyThhHLSrMfnSwBa9PyfGmEvqztRyJ0ffUApweQ==} + langbase@1.1.46: + resolution: {integrity: sha512-+InoRWAx2Z18JK+yGX4+tyihxBx0uXmRSPCfRK37IIa3uvxksmEJIbuG/p3M6DsgCXLf2rIj+Eo8UjYQU7S8YA==} engines: {node: '>=18'} + peerDependencies: + react: ^18 || ^19 + peerDependenciesMeta: + react: + optional: true language-subtag-registry@0.3.23: resolution: {integrity: sha512-0K65Lea881pHotoGEa5gDlMxt3pctLi2RplBb7Ezh4rRdLEOtgi7n4EwK9lamnUCkKBqaeKRVebTq6BAxSkpXQ==} @@ -3993,8 +4001,8 @@ packages: zod: optional: true - openai@4.83.0: - resolution: {integrity: sha512-fmTsqud0uTtRKsPC7L8Lu55dkaTwYucqncDHzVvO64DKOpNTuiYwjbR/nVgpapXuYy8xSnhQQPUm+3jQaxICgw==} + openai@4.87.4: + resolution: {integrity: sha512-lsfM20jZY4A0lNexfoUAkfmrEXxaTXvv8OKYicpeAJUNHObpRgkvC7pxPgMnB6gc9ID8OCwzzhEhBpNy69UR7w==} hasBin: true peerDependencies: ws: ^8.18.0 @@ -8987,12 +8995,14 @@ snapshots: kleur@4.1.5: {} - langbase@1.1.26: + langbase@1.1.46(react@18.3.1): dependencies: dotenv: 16.4.7 - openai: 4.83.0(zod@3.24.1) + openai: 4.87.4(zod@3.24.1) zod: 3.24.1 zod-validation-error: 3.4.0(zod@3.24.1) + optionalDependencies: + react: 18.3.1 transitivePeerDependencies: - encoding - ws @@ -10283,7 +10293,7 @@ snapshots: transitivePeerDependencies: - encoding - openai@4.83.0(zod@3.24.1): + openai@4.87.4(zod@3.24.1): dependencies: '@types/node': 18.19.70 '@types/node-fetch': 2.6.12 diff --git a/scripts/langbase-create-memory.ts b/scripts/langbase-create-memory.ts new file mode 100644 index 000000000..3b79dd396 --- /dev/null +++ b/scripts/langbase-create-memory.ts @@ -0,0 +1,18 @@ +import 'dotenv/config'; +import { Langbase } from 'langbase'; + +const langbase = new Langbase({ + apiKey: process.env.LANGBASE_API_KEY!, +}); + +async function main() { + const memory = await langbase.memories.create({ + name: 'memory-sg-docs-live', + description: 'An AI memory storing all Sourcegraph docs.', + chunk_size: 10000, + }); + + console.log('Memory created:', memory); +} + +main(); diff --git a/scripts/word-count.js b/scripts/word-count.js new file mode 100644 index 000000000..d4e2833d0 --- /dev/null +++ b/scripts/word-count.js @@ -0,0 +1,83 @@ +const path = require('path'); +const fs = require('fs'); +const {sync: glob} = require('glob'); + +// Configuration - Update this base URL as needed +const baseUrl = 'https://sourcegraph.com/'; + +// Find all .mdx files, ignoring node_modules +const mdxFiles = glob('**/*.mdx', {ignore: ['node_modules/**']}); + +// Array to store word counts +const wordCounts = []; +let totalWords = 0; + +// Process each file +mdxFiles.forEach(filePath => { + const fileName = path.basename(filePath); + const content = fs.readFileSync(filePath, 'utf8'); + + // Count words (split by whitespace) + const words = content + .trim() + .split(/\s+/) + .filter(word => word.length > 0); + const wordCount = words.length; + + // Add to total and array + totalWords += wordCount; + wordCounts.push({ + fileName, + filePath, + wordCount + }); + + // Log word count for each file + console.log(`${filePath}: ${wordCount} words`); +}); + +// Calculate average +const averageWordCount = totalWords / wordCounts.length; + +// Calculate median (need to sort the array first) +const sortedCounts = [...wordCounts].sort((a, b) => a.wordCount - b.wordCount); +const middleIndex = Math.floor(sortedCounts.length / 2); +const medianWordCount = + sortedCounts.length % 2 === 0 + ? (sortedCounts[middleIndex - 1].wordCount + + sortedCounts[middleIndex].wordCount) / + 2 + : sortedCounts[middleIndex].wordCount; + +// Log summary statistics +console.log('\n--- Summary Statistics ---'); +console.log(`Total files: ${wordCounts.length}`); +console.log(`Total words: ${totalWords}`); +console.log(`Average words per file: ${averageWordCount.toFixed(2)}`); +console.log(`Median words per file: ${medianWordCount}`); + +// Find shortest and longest files +const shortestFile = sortedCounts[0]; +const longestFile = sortedCounts[sortedCounts.length - 1]; +console.log( + `\nShortest file: ${shortestFile.filePath} (${shortestFile.wordCount} words)` +); +console.log( + `Longest file: ${longestFile.filePath} (${longestFile.wordCount} words)` +); + +// Optional: Write summary to a file +const summary = { + totalFiles: wordCounts.length, + totalWords, + averageWordCount, + medianWordCount, + fileCounts: wordCounts +}; + +// fs.writeFileSync( +// 'word-count-summary.json', +// JSON.stringify(summary, null, 2), +// 'utf8' +// ); +console.log('\nSummary written to word-count-summary.json'); diff --git a/src/app/api/chat/route.ts b/src/app/api/chat/route.ts index 3cffd3dcf..e6ea96aa5 100644 --- a/src/app/api/chat/route.ts +++ b/src/app/api/chat/route.ts @@ -9,11 +9,41 @@ const langbase = new Langbase({ export async function POST(req: NextRequest) { const options = await req.json(); + console.log("🚀 ~ options:", options) - const { stream, threadId } = await langbase.pipe.run({ - ...options, - name: 'ask-sourcegraph-docs' + const { completion } = await langbase.pipes.run({ + name: 'query-rewrite', + messages: [ + { + role: 'user', + content: options.messages[options.messages.length - 1].content, + }, + ], + stream: false }); + console.log("🚀 ~ completion:", completion) + + + // Parse the completion to get the rewritten query + const rewrittenQuery = JSON.parse(completion).rewrittenQuery; + console.log("🚀 ~ rewrittenQuery:", rewrittenQuery) + + // Create a new options object with the rewritten query + const updatedOptions = { + ...options, + messages: [ + ...options.messages.slice(0, -1), // Keep all messages except the last one + { + role: 'user', + content: rewrittenQuery + } + ], + name: 'ask-sourcegraph-docs', + lastMessageOnly: true, + }; + console.log("🚀 ~ updatedOptions:", updatedOptions) + + const { stream, threadId } = await langbase.pipes.run(updatedOptions); return new Response(stream, { status: 200, From b63cc8b68af8f1c1812059054921ae4fcddb18f2 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 18 Mar 2025 17:27:21 -0700 Subject: [PATCH 06/15] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20memory=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 154 +++++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/package.json b/package.json index b10e7b074..af22f7e9f 100644 --- a/package.json +++ b/package.json @@ -1,79 +1,79 @@ { - "name": "sourcegraph-docs", - "version": "0.1.0", - "private": true, - "scripts": { - "dev": "next dev", - "build": "next build", - "start": "next start", - "lint": "next lint", - "baseai": "baseai", - "sync": "npx baseai@latest deploy -m docs", - "llmstxt": "node scripts/llms-txt-generator.js" - }, - "browserslist": "defaults, not ie <= 11", - "dependencies": { - "@algolia/autocomplete-core": "^1.9.2", - "@algolia/client-search": "^4.22.1", - "@baseai/core": "^0.9.40", - "@docsearch/react": "3", - "@headlessui/react": "^1.7.13", - "@heroicons/react": "^2.0.18", - "@langbase/components": "^0.1.6", - "@mdx-js/mdx": "^3.0.1", - "@next/third-parties": "^14.1.4", - "@radix-ui/react-hover-card": "^1.1.1", - "@radix-ui/react-select": "^2.0.0", - "@radix-ui/react-slot": "^1.0.2", - "@tailwindcss/typography": "^0.5.7", - "@types/node": "20.4.9", - "@types/react": "18.2.20", - "@types/react-dom": "18.2.7", - "@types/react-highlight-words": "^0.16.4", - "algoliasearch": "^4.22.1", - "autoprefixer": "^10.4.12", - "class-variance-authority": "^0.7.0", - "clsx": "^1.2.1", - "contentlayer": "^0.3.4", - "date-fns": "^2.30.0", - "fast-glob": "^3.2.12", - "feed": "^4.2.2", - "flexsearch": "^0.7.31", - "github-slugger": "^2.0.0", - "js-yaml": "^4.1.0", - "kbar": "^0.1.0-beta.44", - "langbase": "^1.1.46", - "lucide-react": "^0.372.0", - "mdx": "^0.3.1", - "next": "^14.2.3", - "next-contentlayer": "^0.3.4", - "next-themes": "^0.2.1", - "prism-react-renderer": "^2.0.6", - "react": "18.3.1", - "react-dom": "18.3.1", - "react-highlight-words": "^0.20.0", - "react-syntax-highlighter": "^15.5.0", - "rehype-autolink-headings": "^7.1.0", - "rehype-pretty-code": "^0.10.2", - "rehype-slug": "^6.0.0", - "rehype-toc": "^3.0.2", - "remark-gfm": "3.0.1", - "shiki": "^0.14.5", - "simple-functional-loader": "^1.2.1", - "tailwind-merge": "^2.3.0", - "tailwindcss": "^3.3.3", - "tailwindcss-animate": "^1.0.7", - "typescript": "5.1.6", - "unist-util-visit": "^5.0.0" - }, - "devDependencies": { - "baseai": "^0.9.40", - "dotenv": "^16.4.7", - "eslint": "8.45.0", - "eslint-config-next": "13.4.16", - "glob": "^11.0.1", - "prettier": "^3.0.1", - "prettier-plugin-tailwindcss": "^0.5.2", - "sharp": "^0.32.0" - } + "name": "sourcegraph-docs", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev", + "build": "next build", + "start": "next start", + "lint": "next lint", + "baseai": "baseai", + "sync": "npx baseai@latest deploy -m memory-sg-docs-live", + "llmstxt": "node scripts/llms-txt-generator.js" + }, + "browserslist": "defaults, not ie <= 11", + "dependencies": { + "@algolia/autocomplete-core": "^1.9.2", + "@algolia/client-search": "^4.22.1", + "@baseai/core": "^0.9.40", + "@docsearch/react": "3", + "@headlessui/react": "^1.7.13", + "@heroicons/react": "^2.0.18", + "@langbase/components": "^0.1.6", + "@mdx-js/mdx": "^3.0.1", + "@next/third-parties": "^14.1.4", + "@radix-ui/react-hover-card": "^1.1.1", + "@radix-ui/react-select": "^2.0.0", + "@radix-ui/react-slot": "^1.0.2", + "@tailwindcss/typography": "^0.5.7", + "@types/node": "20.4.9", + "@types/react": "18.2.20", + "@types/react-dom": "18.2.7", + "@types/react-highlight-words": "^0.16.4", + "algoliasearch": "^4.22.1", + "autoprefixer": "^10.4.12", + "class-variance-authority": "^0.7.0", + "clsx": "^1.2.1", + "contentlayer": "^0.3.4", + "date-fns": "^2.30.0", + "fast-glob": "^3.2.12", + "feed": "^4.2.2", + "flexsearch": "^0.7.31", + "github-slugger": "^2.0.0", + "js-yaml": "^4.1.0", + "kbar": "^0.1.0-beta.44", + "langbase": "^1.1.46", + "lucide-react": "^0.372.0", + "mdx": "^0.3.1", + "next": "^14.2.3", + "next-contentlayer": "^0.3.4", + "next-themes": "^0.2.1", + "prism-react-renderer": "^2.0.6", + "react": "18.3.1", + "react-dom": "18.3.1", + "react-highlight-words": "^0.20.0", + "react-syntax-highlighter": "^15.5.0", + "rehype-autolink-headings": "^7.1.0", + "rehype-pretty-code": "^0.10.2", + "rehype-slug": "^6.0.0", + "rehype-toc": "^3.0.2", + "remark-gfm": "3.0.1", + "shiki": "^0.14.5", + "simple-functional-loader": "^1.2.1", + "tailwind-merge": "^2.3.0", + "tailwindcss": "^3.3.3", + "tailwindcss-animate": "^1.0.7", + "typescript": "5.1.6", + "unist-util-visit": "^5.0.0" + }, + "devDependencies": { + "baseai": "^0.9.40", + "dotenv": "^16.4.7", + "eslint": "8.45.0", + "eslint-config-next": "13.4.16", + "glob": "^11.0.1", + "prettier": "^3.0.1", + "prettier-plugin-tailwindcss": "^0.5.2", + "sharp": "^0.32.0" + } } From 991adaca79bf5ae569e1cea4b72ea90c640995e0 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 18 Mar 2025 17:27:53 -0700 Subject: [PATCH 07/15] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20memory=20name=20dir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- baseai/memory/{docs => memory-sg-docs-live}/index.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename baseai/memory/{docs => memory-sg-docs-live}/index.ts (100%) diff --git a/baseai/memory/docs/index.ts b/baseai/memory/memory-sg-docs-live/index.ts similarity index 100% rename from baseai/memory/docs/index.ts rename to baseai/memory/memory-sg-docs-live/index.ts From f58b748c926a1f2ff19e7781155d555b829a5cdd Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 18 Mar 2025 17:57:04 -0700 Subject: [PATCH 08/15] Update memory --- baseai/memory/memory-sg-docs-live/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseai/memory/memory-sg-docs-live/index.ts b/baseai/memory/memory-sg-docs-live/index.ts index c7c3cf6f5..4de11e4ab 100644 --- a/baseai/memory/memory-sg-docs-live/index.ts +++ b/baseai/memory/memory-sg-docs-live/index.ts @@ -8,7 +8,7 @@ const memoryDocs = (): MemoryI => ({ include: ['**/*.mdx'], gitignore: true, embeddedAt: '', - deployedAt: '', + deployedAt: '991adaca79bf5ae569e1cea4b72ea90c640995e0' }, documents: { meta: doc => { From 95f91cdf01c37ddaf870980dc1a4f389c171829d Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 18 Mar 2025 18:13:08 -0700 Subject: [PATCH 09/15] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20no=20need=20to=20re?= =?UTF-8?q?writer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/chat/route.ts | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/app/api/chat/route.ts b/src/app/api/chat/route.ts index e6ea96aa5..1d7cdf6b8 100644 --- a/src/app/api/chat/route.ts +++ b/src/app/api/chat/route.ts @@ -9,35 +9,11 @@ const langbase = new Langbase({ export async function POST(req: NextRequest) { const options = await req.json(); - console.log("🚀 ~ options:", options) - - const { completion } = await langbase.pipes.run({ - name: 'query-rewrite', - messages: [ - { - role: 'user', - content: options.messages[options.messages.length - 1].content, - }, - ], - stream: false - }); - console.log("🚀 ~ completion:", completion) - - - // Parse the completion to get the rewritten query - const rewrittenQuery = JSON.parse(completion).rewrittenQuery; - console.log("🚀 ~ rewrittenQuery:", rewrittenQuery) + // console.log("🚀 ~ options:", options) // Create a new options object with the rewritten query const updatedOptions = { ...options, - messages: [ - ...options.messages.slice(0, -1), // Keep all messages except the last one - { - role: 'user', - content: rewrittenQuery - } - ], name: 'ask-sourcegraph-docs', lastMessageOnly: true, }; From 47153aa8a7fa9708ed976517a531dc222c7f4a30 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 18 Mar 2025 18:22:54 -0700 Subject: [PATCH 10/15] =?UTF-8?q?=F0=9F=90=9B=20FIX:=20memory=20scratch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- baseai/memory/memory-sg-docs-live/index.ts | 2 +- scripts/langbase-create-memory.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/baseai/memory/memory-sg-docs-live/index.ts b/baseai/memory/memory-sg-docs-live/index.ts index 4de11e4ab..5b6be637c 100644 --- a/baseai/memory/memory-sg-docs-live/index.ts +++ b/baseai/memory/memory-sg-docs-live/index.ts @@ -8,7 +8,7 @@ const memoryDocs = (): MemoryI => ({ include: ['**/*.mdx'], gitignore: true, embeddedAt: '', - deployedAt: '991adaca79bf5ae569e1cea4b72ea90c640995e0' + deployedAt: '' }, documents: { meta: doc => { diff --git a/scripts/langbase-create-memory.ts b/scripts/langbase-create-memory.ts index 3b79dd396..5e9407f0c 100644 --- a/scripts/langbase-create-memory.ts +++ b/scripts/langbase-create-memory.ts @@ -9,7 +9,7 @@ async function main() { const memory = await langbase.memories.create({ name: 'memory-sg-docs-live', description: 'An AI memory storing all Sourcegraph docs.', - chunk_size: 10000, + chunk_size: 30000, }); console.log('Memory created:', memory); From 9386e7a3c1d368a3664443fd619ba747d2a009df Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Wed, 19 Mar 2025 10:13:59 -0700 Subject: [PATCH 11/15] sync latest memory --- baseai/memory/memory-sg-docs-live/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseai/memory/memory-sg-docs-live/index.ts b/baseai/memory/memory-sg-docs-live/index.ts index 5b6be637c..641942130 100644 --- a/baseai/memory/memory-sg-docs-live/index.ts +++ b/baseai/memory/memory-sg-docs-live/index.ts @@ -8,7 +8,7 @@ const memoryDocs = (): MemoryI => ({ include: ['**/*.mdx'], gitignore: true, embeddedAt: '', - deployedAt: '' + deployedAt: '47153aa8a7fa9708ed976517a531dc222c7f4a30' }, documents: { meta: doc => { From 6dd7948b825e345f83ef4b47fc5253e5f86727db Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Wed, 19 Mar 2025 12:27:48 -0700 Subject: [PATCH 12/15] Mem sync --- baseai/memory/memory-sg-docs-live/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseai/memory/memory-sg-docs-live/index.ts b/baseai/memory/memory-sg-docs-live/index.ts index 641942130..09a7c6747 100644 --- a/baseai/memory/memory-sg-docs-live/index.ts +++ b/baseai/memory/memory-sg-docs-live/index.ts @@ -8,7 +8,7 @@ const memoryDocs = (): MemoryI => ({ include: ['**/*.mdx'], gitignore: true, embeddedAt: '', - deployedAt: '47153aa8a7fa9708ed976517a531dc222c7f4a30' + deployedAt: '894e04c168dfb579763f7eb0c8d5e6a3f936a97e' }, documents: { meta: doc => { From 82b01e94bf3673959f99a3f763c8063459392db5 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Wed, 19 Mar 2025 17:39:20 -0700 Subject: [PATCH 13/15] Add more questions --- src/app/chat.tsx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/app/chat.tsx b/src/app/chat.tsx index cdf350f18..88d38d2bd 100644 --- a/src/app/chat.tsx +++ b/src/app/chat.tsx @@ -20,19 +20,27 @@ export default function Chat() { // Remember AI can make mistakes, please double-check responses. suggestions={[ { - title: `What is Sourcegraph?`, - prompt: `What is Sourcegraph?` + title: `Tell me about Sourcegraph.`, + prompt: `Tell me about Sourcegraph.` }, { - title: `What is Cody?`, - prompt: `What is Cody?` + title: `What are the input/output token limits for Cody?`, + prompt: `What are the input/output token limits for Cody?` }, { - title: `Search query syntax`, - prompt: `What is the search query syntax?` + title: `Why doesn't Cody work with VPN?`, + prompt: `Why doesn't Cody work with VPN?` }, { - title: `Language specific query examples`, + title: `How do I add all open files to context in Cody?`, + prompt: `How do I add all open files to context in Cody?` + }, + { + title: `What is Sourcegraph search query syntax?`, + prompt: `What is Sourcegraph search query syntax?` + }, + { + title: `Give me language specific query examples?`, prompt: `Give me language specific query examples?` } ]} From 1a04669a5533433b5e8be0f3fefca0b8617db0c9 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Thu, 20 Mar 2025 15:17:53 -0700 Subject: [PATCH 14/15] Mem sync --- baseai/memory/memory-sg-docs-live/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/baseai/memory/memory-sg-docs-live/index.ts b/baseai/memory/memory-sg-docs-live/index.ts index 09a7c6747..e94236e90 100644 --- a/baseai/memory/memory-sg-docs-live/index.ts +++ b/baseai/memory/memory-sg-docs-live/index.ts @@ -8,7 +8,7 @@ const memoryDocs = (): MemoryI => ({ include: ['**/*.mdx'], gitignore: true, embeddedAt: '', - deployedAt: '894e04c168dfb579763f7eb0c8d5e6a3f936a97e' + deployedAt: 'ab6065ecc6c667a5b8c0ded35498a17659d34333' }, documents: { meta: doc => { From 215dc01d7b03481c62aabbc722bfa066c5f63e80 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Wed, 9 Apr 2025 22:15:58 -0700 Subject: [PATCH 15/15] fix path --- src/app/chat.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/chat.tsx b/src/app/chat.tsx index 88d38d2bd..8c638dfd7 100644 --- a/src/app/chat.tsx +++ b/src/app/chat.tsx @@ -1,6 +1,6 @@ 'use client'; -import {Chatbot} from '@langbase/components'; +import { Chatbot } from '@langbase/components'; import '@langbase/components/styles'; export default function Chat() { @@ -15,7 +15,7 @@ export default function Chat() { title="Ask AI" triggerText="Ask AI" badge="Experimental" - apiRoute="/docs/api/chat" + apiRoute="/api/chat" openingMessage="Hi there! I'm Sourcegraph's AI assistant trained for our documentation. How can I help you?" // Remember AI can make mistakes, please double-check responses. suggestions={[