Skip to content

Commit

Permalink
chore: up ai models
Browse files Browse the repository at this point in the history
  • Loading branch information
uigywnkiub committed Feb 6, 2025
1 parent a9376f0 commit 176e8a3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/lib/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ export async function getExpenseTipsAI(categories: string[]): Promise<string> {
try {
const categoriesStr = categories.join(', ')

const prompt = `Provide a few actionable tips on decreasing expenses for the following categories: ${categoriesStr}. Include practical strategies, potential savings opportunities, and any recommendations that could help manage and reduce costs within these categories. The output category field must be with an emoji. Advice must be one per category.`
const prompt = `Provide actionable tips on decreasing expenses for the following categories: ${categoriesStr}. Include practical strategies, potential savings opportunities, and any recommendations that could help manage and reduce costs within these categories. The output category field must be with an emoji. Advice must be one per category.`

const content = await ExpenseTipsAIModel.generateContent(prompt)
const text = content.response.text().trim()
Expand Down
1 change: 1 addition & 0 deletions app/lib/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const safetySettings = [
// TPD: Tokens per day

export const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY)

export const CompletionAIModel = genAI.getGenerativeModel({
model: process.env.GEMINI_MODEL,
// Docs https://ai.google.dev/api/generate-content#v1beta.GenerationConfig
Expand Down
6 changes: 3 additions & 3 deletions app/ui/home/transaction-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ function TransactionForm({ currency, userCategories }: TProps) {
const [isTransactionTypeAIValid, setIsTransactionTypeAIValid] =
useState(false)
const [categoryItemNameAI, setCategoryItemNameAI] = useState('')
const isAnyAIDataExist =
isAmountAIValid || isTransactionTypeAIValid || Boolean(categoryItemNameAI)
const trimmedDescription = description.trim()
// Memoized values
const approxCategoryItemName = useMemo(
Expand Down Expand Up @@ -370,6 +368,7 @@ function TransactionForm({ currency, userCategories }: TProps) {
])

setCategoryItemNameAI(categoryItemNameAI)

const rawAmountAI = formatAmount(amountAI)
if (
!isNaN(Number(rawAmountAI)) &&
Expand All @@ -379,6 +378,7 @@ function TransactionForm({ currency, userCategories }: TProps) {
setAmount(getFormattedCurrency(rawAmountAI, false))
setIsAmountAIValid(true)
}

if (transactionTypeAI === 'true') {
setIsSwitchedOn(true)
setIsTransactionTypeAIValid(true)
Expand Down Expand Up @@ -632,7 +632,7 @@ function TransactionForm({ currency, userCategories }: TProps) {
description={
<div className='flex flex-wrap items-center gap-1'>
<div className='flex'>
<AILogo asText={isAnyAIDataExist && !isLoadingAIData} />
<AILogo />
</div>
<InfoText
text='fills in the remaining fields.'
Expand Down

0 comments on commit 176e8a3

Please sign in to comment.