ZeeAI1 commited on
Commit
4c23a14
·
verified ·
1 Parent(s): 20e2d3c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import sqlite3
4
+ from dotenv import load_dotenv
5
+ from groq import Groq
6
+ from utils import generate_double_entry, save_transaction
7
+
8
+ load_dotenv()
9
+ client = Groq(api_key=os.environ["GROQ_API_KEY"])
10
+
11
+ def call_groq(prompt):
12
+ response = client.chat.completions.create(
13
+ messages=[{"role": "user", "content": prompt}],
14
+ model="mixtral-8x7b-instruct",
15
+ stream=False,
16
+ )
17
+ return response.choices[0].message.content
18
+
19
+ def accounting_chatbot(user_input):
20
+ llm_output = call_groq(user_input)
21
+ debit, credit, amount = generate_double_entry(llm_output)
22
+ save_transaction(debit, credit, amount, user_input)
23
+
24
+ output = f"**Double Entry**\n- Debit: {debit}\n- Credit: {credit}\n- Amount: {amount}\n\n🧠 {llm_output}"
25
+
26
+ # Optional: return audio path from Promot integration here
27
+ return output
28
+
29
+ demo = gr.ChatInterface(fn=accounting_chatbot, title="AI Accounting Assistant")
30
+ demo.launch()