Skip to content

Commit

Permalink
Merge pull request #29 from 2405-team3/evals-ui
Browse files Browse the repository at this point in the history
feat: evals UI dashboard
  • Loading branch information
yg-lim authored Aug 5, 2024
2 parents 5ea13f2 + ba705e9 commit 6c0cf38
Show file tree
Hide file tree
Showing 10 changed files with 470 additions and 11 deletions.
4 changes: 0 additions & 4 deletions eval_pg_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
from dotenv import load_dotenv
load_dotenv()

def filter_by_chatbot(data, chatbot_id):
filtered_data = [entry for entry in data if entry[2].get('chatbot_id') == chatbot_id]
return filtered_data

def connect_to_db():
try:
conn = psycopg2.connect(
Expand Down
46 changes: 43 additions & 3 deletions evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,50 @@ def evaluate_and_store_benchmark_data_entry(entry):

pg.insert_scored_benchmark_data(scored_entry)

def get_chat_history(chatbot_id):
def get_chat_history():
data = pg.get_data_from('chat_history')
data = pg.filter_by_chatbot(data, chatbot_id)
return data

json_data_list = []

for tuple in data:
json_data = {
'pg_id': tuple[0],
'chatbot_id': tuple[2]['chatbot_id'],
'time': tuple[1],
'input': tuple[2]['input'],
'output': tuple[2]['output'],
'context': tuple[2]['context'],
'faithfulness': tuple[2]['scores']['faithfulness'],
'answer_relevancy': tuple[2]['scores']['answer_relevancy'],
}
json_data_list.append(json_data)

return json_data_list

# [
# 7,
# "2024-08-02T19:55:41.279549",
# {
# "input": "how did giraffes necks get so long",
# "output": "Empty Response",
# "scores": {
# "faithfulness": 0,
# "answer_relevancy": 0
# },
# "context": "",
# "chatbot_id": "test1"
# }
# ]
# const data = [
# {
# "chatbot_id": "chatbot1",
# "input": "how tall are banana trees",
# "output": "Banana trees can reach up to 25 feet tall.",
# "faithfulness": 0.0,
# "answer_relevancy": 0.9541919130393199,
# "context": "This is a bunch of sample context"
# }
# ]

def get_benchmark_data():
data = pg.get_data_from('benchmark_data')
Expand Down
6 changes: 3 additions & 3 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ async def post_chatbots(request: Request):
return pipeline_json


@app.get('/api/history/{chatbot_id}')
async def get_evals(chatbot_id):
data = evals.get_chat_history(chatbot_id)
@app.get('/api/history')
async def get_evals():
data = evals.get_chat_history()
return {"table_data": data}


Expand Down
2 changes: 2 additions & 0 deletions systemd/run_system.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#! /bin/bash

# these commands are used to "reset" systemd after making changes to the unit file (e.g., test.service)
# sudo systemctl stop test.service

sudo systemctl daemon-reload
sudo systemctl enable test.service
sudo systemctl start test.service
Expand Down
62 changes: 62 additions & 0 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-checkbox": "^1.1.1",
"@radix-ui/react-dropdown-menu": "^2.1.1",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-scroll-area": "^1.1.0",
Expand All @@ -19,6 +20,7 @@
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-switch": "^1.1.0",
"@tanstack/react-query": "^5.51.15",
"@tanstack/react-table": "^8.20.1",
"axios": "^1.7.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
Expand Down
1 change: 1 addition & 0 deletions ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PageKnowledgeBase } from "./components/pages/PageKnowledgeBase.tsx";
import { PageChatbots } from "./components/pages/PageChatbots.tsx";
import { PageChatbot } from "./components/pages/PageChatbot.tsx";
import { PageEvaluations } from "./components/pages/PageEvaluations.tsx";
// import { DataTableDemo } from "./components/pages/DataTableDemo.tsx"; // testing only

const queryClient = new QueryClient();

Expand Down
Loading

0 comments on commit 6c0cf38

Please sign in to comment.