Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Windows support #42

Merged
merged 8 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fixed joinPath bug, catching no-ai key errors (only appear during dev…
…elopment)
  • Loading branch information
rllyy97 committed Jan 1, 2024
commit 4c5dd38430e369832b2b63f96d6c12b9b239b572
26 changes: 16 additions & 10 deletions src/main/utils/pileVectorIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ class PileVectorIndex {

this.pilePath = pilePath;

await this.setAPIKeyToEnv();
await this.setStorageContext();
await this.setServiceContext();
await this.initVectorStoreIndex();
await this.initQueryEngine();
await this.initChatEngine();
try {
await this.setAPIKeyToEnv();
await this.setStorageContext();
await this.setServiceContext();
await this.initVectorStoreIndex();
await this.initQueryEngine();
await this.initChatEngine();
} catch (e) {
console.error(e);
return false;
}
}

async sendMessageToRenderer(channel = 'status', message) {
Expand All @@ -57,8 +62,7 @@ class PileVectorIndex {
async setAPIKeyToEnv() {
const apikey = await keytar.getPassword('pile', 'aikey');
if (!apikey) {
console.error('API key not found. Please set it first.');
throw new Error('API key not found');
throw new Error('API key not found. Please set it first.');
}
process.env['OPENAI_API_KEY'] = apikey;
}
Expand Down Expand Up @@ -136,7 +140,8 @@ class PileVectorIndex {
// when new entries are created or when they are updated.
async add(pilePath, relativeFilePath, parentRelativeFilePath = null) {
// Initialize if needed
await this.initialize(pilePath);
const initialized = await this.initialize(pilePath);
if (!initialized) return;

const filePath = path.join(pilePath, relativeFilePath);
const fileContent = await fs.promises.readFile(filePath, 'utf-8');
Expand Down Expand Up @@ -263,7 +268,8 @@ class PileVectorIndex {
if (!pilePath) return;

// Setup or load the vector store
await this.initialize(pilePath);
const initialized = await this.initialize(pilePath);
if (!initialized) return;

// Load the base index
this.pilePath = pilePath;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/hooks/usePost.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function usePost(
);

const addReplyToParent = async (parentPostPath, replyPostPath) => {
const relativeReplyPath = window.electron.joinPath(replyPostPath.split(/[/\\]/).slice(-3));
const relativeReplyPath = window.electron.joinPath(...replyPostPath.split(/[/\\]/).slice(-3));
const fullParentPostPath = getCurrentPilePath(parentPostPath);
const parentPost = await getPost(fullParentPostPath);
const content = parentPost.content;
Expand Down