Skip to content

DennieDan/classifier-agent

Repository files navigation

Autonomous Regulatory Auditor Agent

ChainofThought

Try out the Classifier Agent UI here: https://classifier-agent.onrender.com/ui/

Suggested Questions

  1. What is the HS-Code of Coconut Candy with rice paper wrapper?
  2. What is the HS-Code of gold necklace with a silver pendant?

Feel free to give more complex descriptions to test the agent's limit.

classifier_agent-2-2.mov

Set up

.env

LLAMA_PARSE_API_KEY=llx-xxx
GROQ_API_KEY=gsk_xxx
OPENAI_API_KEY=sk-proj-xxx

From the project root, install dependencies and run the UI:

pip install -r requirements.txt

To run local model, install them:

ollama run llama3.1:8b-instruct-q8_0 # must install
ollama run llama3-groq-tool-use # optional
ollama run mistral:7b # optional

Prepare knowledge base

The Knowledge base is prepared for LLM model llama3.1:8b-instruct-q8_0 and Embedding Model BAAI/bge-small-en-v1.5 (free from HuggingFace). Knowledge base is built on the file stcced2022.pdf

Therefore, the search tool in regulatory_server.py is always used with LLM model llama3.1:8b-instruct-q8_0. (More adjustment will be done in the future)

The file stcced2022.pdf is already parsed using LlamaParse and stored as docs.md

To build the index (takes 32 seconds):

python app/index_server.py

If there is a need to parse the data again, run this. This script already included index building step. This may take up to 40 minutes.

python app/index_server_improved.py

Run on local machine

Run the FastAPI server

uvicorn app.main:app --host 0.0.0.0 --port 8000
  1. NiceGUI Open http://localhost:8000/ui in your browser. The UI has a left sidebar with conversation list, a main area for input (or process/conversation view), and a plus button (top right) to start a new prompt.

  2. Run agent alone and view CoT in NiceGUI

curl --location 'http://localhost:8000/agent' \
--header 'Content-Type: application/json' \
--data '{
    "user_input": "What is the HS-Code of Personal Deodorant?",
    "model": "llama-3.3-70b-versatile",
    "host": "cloud groq"
}'

Note: The model is llama-3.3-70b-versatile from Cloud Groq by default if no information is provided. Only the following models are supported right now.

[
("Cloud OpenAI", "gpt-4o"),
("Cloud Groq", "llama-3.3-70b-versatile"),
("Cloud Groq", "llama3.1:8b-instruct-q8_0"),
("Local", "llama3.1:8b-instruct-q8_0"),
("Local", "llama3-groq-tool-use"),
("Local", "mistral:7b"),
]

Run with Dockerfile

This may take a long time to build. Can try Running on local machine

docker build -t agent-ui --no-cache .
docker run -p 8888:8888 --name agent-ui agent-ui
  1. NiceGUI UI

Access: http://localhost:8888/ui


Pareto Frontier Evaluation

Model Latency accuracy Token cost/permit
cloud openai gpt4o 125s 5700 token/$0.0108
cloud groq llama-3.3-70b-versatile 110s 27900 token/$0.00
local llama3.1:8b-instruct-q8_0 112s 41000 token (local)
local llama3-groq-tool-use 117s High 13200 token (local)
local mistral:7b Cannot call tools

Chain of Thought

To access Chain of Thought, please access NiceGUI to view all current chains of thought.

vid_cot.mp4

What is still Missing?

  • Ensure Accuracy of the agent in different models
  • Latency is still higher than the required threshold
  • Dockerfile run requires more testing, still not stable

Acknowledgement

  • NiceGUI implementation by Cursor AI

About

A ReAct agent with Vector Store knowledge base of STCCED

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages