Skip to content

Commit

Permalink
Merge pull request #74 from ubranch/main
Browse files Browse the repository at this point in the history
SafetySettings & Log file name (Windows)
  • Loading branch information
tak-bro authored Aug 27, 2024
2 parents a851305 + e8a6ceb commit d32f172
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/services/ai/gemini.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GoogleGenerativeAI } from '@google/generative-ai';
import { GoogleGenerativeAI, HarmBlockThreshold, HarmCategory } from '@google/generative-ai';
import chalk from 'chalk';
import { ReactiveListChoice } from 'inquirer-reactive-list-prompt';
import { Observable, catchError, concatMap, from, map, of } from 'rxjs';
Expand Down Expand Up @@ -60,7 +60,26 @@ export class GeminiService extends AIService {
maxOutputTokens: maxTokens,
temperature: this.params.config.temperature,
},
safetySettings: [
{
category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
},
{
category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
},
{
category: HarmCategory.HARM_CATEGORY_HARASSMENT,
threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
},
{
category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE,
},
],
});

const result = await model.generateContent(`Here are diff: ${diff}`);
const response = result.response;
const completion = response.text();
Expand Down
2 changes: 1 addition & 1 deletion src/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const generateLogFileName = (date: Date, diff: string) => {
const { year, month, day, hours, minutes, seconds } = getDateString(date);
const hasher = xxh64(0);
const hash = hasher.update(diff).digest('hex');
return `aic2_${year}-${month}-${day}_${hours}:${minutes}:${seconds}_${hash}.log`;
return `aic2_${year}-${month}-${day}_${hours}-${minutes}-${seconds}_${hash}.log`;
};

export const writeFileSyncRecursive = (fileName: string, content: string = '') => {
Expand Down

0 comments on commit d32f172

Please sign in to comment.