File size: 954 Bytes
4c23a14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import gradio as gr
import sqlite3
from dotenv import load_dotenv
from groq import Groq
from utils import generate_double_entry, save_transaction

load_dotenv()
client = Groq(api_key=os.environ["GROQ_API_KEY"])

def call_groq(prompt):
    response = client.chat.completions.create(
        messages=[{"role": "user", "content": prompt}],
        model="mixtral-8x7b-instruct",
        stream=False,
    )
    return response.choices[0].message.content

def accounting_chatbot(user_input):
    llm_output = call_groq(user_input)
    debit, credit, amount = generate_double_entry(llm_output)
    save_transaction(debit, credit, amount, user_input)
    
    output = f"**Double Entry**\n- Debit: {debit}\n- Credit: {credit}\n- Amount: {amount}\n\n🧠 {llm_output}"
    
    # Optional: return audio path from Promot integration here
    return output

demo = gr.ChatInterface(fn=accounting_chatbot, title="AI Accounting Assistant")
demo.launch()