Skip to content

Commit

Permalink
finalized things ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiti-Dev committed Mar 21, 2023
1 parent f655650 commit 437f60c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app-tracker/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
OPEN_AI_API_KEY=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
OPEN_AI_API_KEY=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
OEPN_AI_ORG_ID=org-kFKLuyGexaaaLmC0bcxfe5G8
5 changes: 3 additions & 2 deletions app-tracker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ dotenv.config(); // load the environment variables

(async () => {
await Storage.initializeDatabase();

setInterval(AppTracker.getCurrentFocusedApp, 1000);
setInterval(Storage.proceedSummerizationReport.bind(Storage), 10000);
setInterval(DataSummarizeReport.getNotificationAlert, 60000 * 60);
setInterval(Storage.proceedSummerizationReport.bind(Storage), 20000);
setInterval(DataSummarizeReport.getNotificationAlert, 3600000);

const PORT = 3000;

Expand Down
8 changes: 5 additions & 3 deletions app-tracker/src/instances/data-summarize-report/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChatCompletionRequestMessageRoleEnum } from 'openai';
import OpenAI from '../open-ai/openai';
import { Storage } from '../storage/storage';
import { exec } from 'child_process';
import pushMessageToChat from '../../pushMessage';

export class DataSummarizeReport {
public static async getAndSendSummarization(tracks: any[], searchKeywords: any[]) {
Expand Down Expand Up @@ -41,7 +42,8 @@ export class DataSummarizeReport {
},
],
});
console.log(response.data.choices[0].message);
const message: any = response.data.choices[0].message?.content;
pushMessageToChat(message); // probably message size too large <must chunk and send multiple time
}

public static async getNotificationAlert() {
Expand All @@ -56,7 +58,7 @@ export class DataSummarizeReport {
{
role: ChatCompletionRequestMessageRoleEnum.Assistant,
content: `
I want you to act as a good psychological messenger. I’ll write you my activity log, and you’ll suggest a short message as a notification in case of exceeding the time spent for me to help me estimate my mental health. In some cases, I will also tell you my activity log. You will also suggest the short message to recommend the suitable actions to help me avoid the mental issues. and if I don't have thing to worry please just send me back a good cheers
I want you to act as a good psychological messenger. I’ll write you my activity log, and you’ll suggest a short message as a notification in case of exceeding the time spent for me to help me estimate my mental health. In some cases, I will also tell you my activity log. You will also suggest the short message to recommend the suitable actions to help me avoid the mental issues. and if I don't have thing to worry please just send me back a good cheers. and please respond me back without the special character or any quotes
the activity logs are
Expand All @@ -70,7 +72,7 @@ export class DataSummarizeReport {

const title = 'Hey',
subtitle = 'Titan',
message = response.data.choices[0].message?.content;
message = response.data.choices[0].message?.content.replace(/"/g, '\\"');

const script = 'display notification "' + message + '" with title "' + title + '" subtitle "' + subtitle + '"';

Expand Down
6 changes: 3 additions & 3 deletions app-tracker/src/instances/open-ai/openai.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Configuration, OpenAIApi } from "openai";
import { IOpenAI } from "./openai.interfaces";
import { Configuration, OpenAIApi } from 'openai';
import { IOpenAI } from './openai.interfaces';

export default class OpenAI implements IOpenAI {
private instance: OpenAIApi;
Expand All @@ -8,7 +8,7 @@ export default class OpenAI implements IOpenAI {
}
private init(): OpenAIApi {
const configuration = new Configuration({
organization: process.env.OEPN_AI_ORG_ID,
//organization: process.env.OEPN_AI_ORG_ID,
apiKey: process.env.OPEN_AI_API_KEY,
});

Expand Down

0 comments on commit 437f60c

Please sign in to comment.