Skip to content

Commit be5d7ca

Browse files
πŸ“¦ NEW: Git synced memory
* πŸ“¦ NEW: Add support for git-memory * πŸ“¦ NEW: Add deployedCommitHash in memory config * πŸ“¦ NEW: get changed files between commits for memory * πŸ“¦ NEW: Save deployed commit in memory config * πŸ“¦ NEW: Handle git synced memories in deploy command * πŸ‘Œ IMPROVE: Handle custom directory option for getting changed files * πŸ“¦ NEW: Handle all files or changed file deployment * πŸ‘Œ IMPROVE: Get changed or new file names for git synced memory * πŸ“¦ NEW: handle deployemnt for git synced memories * πŸ“¦ NEW: Handle new files by listing prod documents * πŸ“¦ NEW: add deployment for git sync --------- Co-authored-by: Saqib Ameen <[email protected]>
1 parent 5d3b4a9 commit be5d7ca

File tree

19 files changed

+911
-106
lines changed

19 files changed

+911
-106
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { MemoryI } from '@baseai/core';
2+
import path from 'path';
3+
4+
const memoryChatWithRepo = (): MemoryI => ({
5+
name: 'chat-with-repo',
6+
description: '',
7+
config: {
8+
useGitRepo: true,
9+
dirToTrack: path.posix.join('examples'),
10+
extToTrack: ["*"]
11+
}
12+
});
13+
14+
export default memoryChatWithRepo;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {PipeI} from '@baseai/core';
2+
import chatWithRepoMemory from '../memory/chat-with-repo';
3+
4+
const buildPipe = (): PipeI => ({
5+
apiKey: process.env.LANGBASE_API_KEY!, // Replace with your API key https://langbase.com/docs/api-reference/api-keys
6+
name: 'chat-with-docs',
7+
description: '',
8+
status: 'private',
9+
model: 'openai:gpt-4o-mini',
10+
stream: true,
11+
json: false,
12+
store: true,
13+
moderate: true,
14+
top_p: 1,
15+
max_tokens: 1000,
16+
temperature: 0.7,
17+
presence_penalty: 1,
18+
frequency_penalty: 1,
19+
stop: [],
20+
tool_choice: 'auto',
21+
parallel_tool_calls: false,
22+
messages: [
23+
{role: 'system', content: `You are a helpful AI assistant.`},
24+
{
25+
role: 'system',
26+
name: 'rag',
27+
content:
28+
"Below is some CONTEXT for you to answer the questions. ONLY answer from the CONTEXT. CONTEXT consists of multiple information chunks. Each chunk has a source mentioned at the end.\n\nFor each piece of response you provide, cite the source in brackets like so: [1].\n\nAt the end of the answer, always list each source with its corresponding number and provide the document name. like so [1] Filename.doc.\n\nIf you don't know the answer, just say that you don't know. Ask for more context and better questions if needed.",
29+
},
30+
],
31+
variables: [],
32+
memory: [chatWithRepoMemory()],
33+
tools: [],
34+
});
35+
36+
export default buildPipe;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import 'dotenv/config';
2+
import {getRunner, Pipe} from '@baseai/core';
3+
import chatWithRepo from '../baseai/pipes/chat-with-repo';
4+
5+
const pipe = new Pipe(chatWithRepo());
6+
7+
async function main() {
8+
const {stream, threadId, rawResponse} = await pipe.run({
9+
messages: [
10+
{
11+
role: 'user',
12+
content: 'Generate example of chat with docs using pipe',
13+
},
14+
],
15+
stream: true,
16+
});
17+
18+
// Convert the stream to a stream runner.
19+
const runner = getRunner(stream);
20+
21+
// Method 1: Using event listeners
22+
runner.on('connect', () => {
23+
console.log('Stream started.\n');
24+
});
25+
26+
runner.on('content', content => {
27+
process.stdout.write(content);
28+
});
29+
30+
runner.on('end', () => {
31+
console.log('\nStream ended.');
32+
});
33+
34+
runner.on('error', error => {
35+
console.error('Error:', error);
36+
});
37+
}
38+
39+
main();

β€Žpackages/baseai/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"dotenv": "^16.4.5",
6767
"execa": "^9.4.0",
6868
"figures": "^6.1.0",
69-
"find-up": "^7.0.0",
7069
"get-package-json-file": "^2.0.0",
7170
"hono": "^4.5.11",
7271
"js-tiktoken": "^1.0.14",

β€Žpackages/baseai/src/deploy/document.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,9 @@ export async function handleSingleDocDeploy({
154154
// Fetch the existing documents
155155
const prodDocs = await listMemoryDocuments({
156156
account,
157-
memory
157+
memoryName: memory.name
158158
});
159159

160-
// Get the list of local document names
161-
const localDocs = await getMemoryFileNames(memory.name);
162-
163160
// If overwrite is present, deploy.
164161
if (overwrite) {
165162
await uploadDocumentsToMemory({
@@ -173,6 +170,9 @@ export async function handleSingleDocDeploy({
173170
return;
174171
}
175172

173+
// Get the list of local document names
174+
const localDocs = await getMemoryFileNames(memory.name);
175+
176176
// If it is the only that does not exist in prod, deploy.
177177
const onlyDeployDocMissing = checkOnlyDeployDocumentMissing({
178178
localDocs,

0 commit comments

Comments
Β (0)