ZeeAI1 commited on
Commit
8d6f5ea
·
verified ·
1 Parent(s): e00c487

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -1,29 +1,29 @@
 
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[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])
 
 
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")
 
1
+
2
  import os
3
  import gradio as gr
4
  import sqlite3
5
  from dotenv import load_dotenv
6
+ import openai
7
  from utils import generate_double_entry, save_transaction
8
 
9
  load_dotenv()
10
+
11
+ openai.api_key = os.getenv(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)
12
+ openai.api_base = "https://api.groq.com/openai/v1"
13
 
14
  def call_groq(prompt):
15
+ response = openai.ChatCompletion.create(
 
16
  model="mixtral-8x7b-instruct",
17
+ messages=[{"role": "user", "content": prompt}]
18
  )
19
+ return response['choices'][0]['message']['content']
20
 
21
  def accounting_chatbot(user_input):
22
  llm_output = call_groq(user_input)
23
  debit, credit, amount = generate_double_entry(llm_output)
24
  save_transaction(debit, credit, amount, user_input)
25
+
26
  output = f"**Double Entry**\n- Debit: {debit}\n- Credit: {credit}\n- Amount: {amount}\n\n🧠 {llm_output}"
 
 
27
  return output
28
 
29
  demo = gr.ChatInterface(fn=accounting_chatbot, title="AI Accounting Assistant")