Compare commits

...

17 Commits

Author SHA1 Message Date
77cf893121 Merge branch 'dev' into feature/test-ai-pr-action 2025-07-16 00:08:21 -06:00
61348aa351 fix: update workflow to use HuggingFace Falcon model for PR description generation 2025-07-16 00:08:08 -06:00
b281ad766d Merge branch 'dev' into feature/test-ai-pr-action 2025-07-16 00:05:49 -06:00
dea942f11e fix: update workflow to use HuggingFace for PR description generation 2025-07-16 00:05:33 -06:00
bed2c526dd Merge branch 'dev' into feature/test-ai-pr-action 2025-07-15 23:48:01 -06:00
d62e620828 fix: update workflow name and enhance OpenAI request handling in AI PR Description 2025-07-15 23:47:45 -06:00
3ebca8d98f Merge branch 'dev' into feature/test-ai-pr-action 2025-07-15 23:45:34 -06:00
f0556813ac fix: update workflow name and enhance commit message handling in AI PR Description 2025-07-15 23:45:16 -06:00
eac72dd2a4 Merge branch 'dev' into feature/test-ai-pr-action 2025-07-15 23:43:15 -06:00
6d2252a403 fix: add debug information to AI PR Description workflow 2025-07-15 23:43:00 -06:00
2b1f5190ef Merge branch 'dev' into feature/test-ai-pr-action 2025-07-15 23:39:19 -06:00
8d265c9105 fix: update workflow name and change GitHub token secret 2025-07-15 23:38:57 -06:00
ffa38de046 Test AI PR Action from internal branch 2025-07-15 23:25:51 -06:00
a4095c837b fix: rename workflow and update AI description generation method 2025-07-15 23:19:22 -06:00
65d4a56135 fix: update GitHub CLI installation method and refine AI PR description prompt 2025-07-15 19:00:23 -06:00
fffa27b6ee Add AI PR Description Action 2025-07-15 18:48:43 -06:00
12579fcd6e fix nodemailer import (#473) 2025-07-15 16:46:50 +03:00
8 changed files with 62 additions and 115 deletions

61
.github/workflows/pr-description.yml vendored Normal file
View File

@ -0,0 +1,61 @@
name: 🤖 AI PR Description with HuggingFace Falcon
on:
pull_request:
types: [opened, edited]
jobs:
generate-description:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install GitHub CLI and jq
run: |
sudo apt-get update
sudo apt-get install gh jq -y
- name: Fetch PR Commits
id: fetch_commits
run: |
COMMITS=$(gh pr view ${{ github.event.pull_request.number }} --json commits --jq '.commits[].message' | sed 's/^/- /')
echo "commits<<EOF" >> $GITHUB_ENV
echo "$COMMITS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}
- name: Generate PR Description with HuggingFace Falcon
run: |
REQUEST_BODY=$(jq -n \
--arg inputs "Given the following commit messages:\n\n${commits}\n\nGenerate a clear and professional pull request description." \
'{ inputs: $inputs }'
)
RESPONSE=$(curl -s https://api-inference.huggingface.co/models/tiiuae/falcon-7b-instruct \
-H "Authorization: Bearer $HUGGINGFACE_API_KEY" \
-H "Content-Type: application/json" \
-d "$REQUEST_BODY")
echo "---------- HuggingFace Raw Response ----------"
echo "$RESPONSE"
DESCRIPTION=$(echo "$RESPONSE" | jq -r 'if type=="array" then .[0].generated_text else .error else "Error: Unexpected response" end')
echo "---------- Extracted Description ----------"
echo "$DESCRIPTION"
echo "description<<EOF" >> $GITHUB_ENV
echo "$DESCRIPTION" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
env:
HUGGINGFACE_API_KEY: ${{ secrets.HUGGINGFACE_API_KEY }}
commits: ${{ env.commits }}
- name: Post AI Generated Description as Comment
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "${{ env.description }}"
env:
GH_TOKEN: ${{ secrets.GH_PERSONAL_TOKEN }}

View File

@ -1,7 +1,7 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import axios from 'axios';
import nodemailer from 'nodemailer';
import * as nodemailer from 'nodemailer';
import Mail from 'nodemailer/lib/mailer';
import { BatchEmailData } from './batch-email.interface';
import { SingleEmailData } from './single-email.interface';

View File

@ -1 +0,0 @@
export * from './weather.controller';

View File

@ -1,28 +0,0 @@
import { Controller, Get, Query } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { EnableDisableStatusEnum } from '@app/common/constants/days.enum';
import { ControllerRoute } from '@app/common/constants/controller-route'; // Assuming this is where the routes are defined
import { WeatherService } from '../services';
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
import { GetWeatherDetailsDto } from '../dto/get.weather.dto';
@ApiTags('Weather Module')
@Controller({
version: EnableDisableStatusEnum.ENABLED,
path: ControllerRoute.WEATHER.ROUTE, // use the static route constant
})
export class WeatherController {
constructor(private readonly weatherService: WeatherService) {}
@Get()
@ApiOperation({
summary: ControllerRoute.WEATHER.ACTIONS.FETCH_WEATHER_DETAILS_SUMMARY,
description:
ControllerRoute.WEATHER.ACTIONS.FETCH_WEATHER_DETAILS_DESCRIPTION,
})
async fetchWeatherDetails(
@Query() query: GetWeatherDetailsDto,
): Promise<BaseResponseDto> {
return await this.weatherService.fetchWeatherDetails(query);
}
}

View File

@ -1,21 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsNumber } from 'class-validator';
export class GetWeatherDetailsDto {
@ApiProperty({
description: 'Latitude coordinate',
example: 35.6895,
})
@IsNumber()
@Type(() => Number)
lat: number;
@ApiProperty({
description: 'Longitude coordinate',
example: 139.6917,
})
@IsNumber()
@Type(() => Number)
lon: number;
}

View File

@ -1 +0,0 @@
export * from './weather.service';

View File

@ -1,51 +0,0 @@
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import { HttpService } from '@nestjs/axios';
import { ConfigService } from '@nestjs/config';
import { firstValueFrom } from 'rxjs';
import { GetWeatherDetailsDto } from '../dto/get.weather.dto';
import { calculateAQI } from '@app/common/util/calculate.aqi';
import { BaseResponseDto } from '@app/common/dto/base.response.dto';
import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
@Injectable()
export class WeatherService {
private readonly weatherApiUrl: string;
constructor(
private readonly configService: ConfigService,
private readonly httpService: HttpService,
) {
this.weatherApiUrl = this.configService.get<string>('WEATHER_API_URL');
}
async fetchWeatherDetails(
query: GetWeatherDetailsDto,
): Promise<BaseResponseDto> {
try {
const { lat, lon } = query;
const weatherApiKey = this.configService.get<string>(
'OPEN_WEATHER_MAP_API_KEY',
);
const url = `${this.weatherApiUrl}/current.json?key=${weatherApiKey}&q=${lat},${lon}&aqi=yes`;
const response = await firstValueFrom(this.httpService.get(url));
const pm2_5 = response.data.current.air_quality.pm2_5; // Raw PM2.5 (µg/m³)
return new SuccessResponseDto({
message: `Weather details fetched successfully`,
data: {
aqi: calculateAQI(pm2_5), // Converted AQI (0-500)
temperature: response.data.current.temp_c,
humidity: response.data.current.humidity,
},
statusCode: HttpStatus.OK,
});
} catch (error) {
console.log(`Error fetching weather data: ${error}`);
throw new HttpException(
`Api can't handle these lat and lon values`,
error.response?.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
}
}
}

View File

@ -1,12 +0,0 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { HttpModule } from '@nestjs/axios'; // <-- Import this!
import { WeatherController } from './controllers';
import { WeatherService } from './services';
@Module({
imports: [ConfigModule, HttpModule],
controllers: [WeatherController],
providers: [WeatherService],
})
export class WeatherModule {}