Skip to content

Commit

Permalink
Merge pull request #5 from pradeepgudipati/bug_fixes_22_Apr
Browse files Browse the repository at this point in the history
Bug fixes 22 apr
  • Loading branch information
Pradeep Gudipati committed Apr 22, 2024
2 parents 6ae7826 + 55a809e commit f365fdc
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,4 @@ cython_debug/
*.jsonl
*.csv
*.ann
/chroma_db
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ This python code converts the jsonl data to a sqllite database with a table call
The messages table has 3 rows

1. id - Primary key
2. User - Contains the Question
3. Assistant - Contains the answer to the Question
2. Question - Contains the Question
3. Answer - Contains the answer to the Question

### 2. DB to JSONL
- SQLite to JSONL Converter code - [db_to_jsonl.py](jsonl_data_to_db%2Fdb_to_jsonl.py)
Expand Down
2 changes: 1 addition & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def add_new_qa():
:return: response
"""
data = request.json
new_item = LLMDataModel(user=data["question"], assistant=data["answer"])
new_item = LLMDataModel(question=data["question"], answer=data["answer"])
db.session.add(new_item)
db.session.commit()
return jsonify(status="success", message=f"New item added."), 200
Expand Down
1 change: 1 addition & 0 deletions src/frontend/static/css/table_main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/* CSS class for CKEditor field in edit mode */
.editing {
background-color: cornsilk !important;
border: black 3px solid;
}

.not-editing {
Expand Down
8 changes: 5 additions & 3 deletions src/frontend/static/js/table_main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ let upload_file_name = "";
// Toggle Edit or Save Question buttons
function toggleQuestionEditor(item_id) {
const questionDiv = document.getElementById('question-' + item_id);
const isEditing = questionDiv.getAttribute('contenteditable') === 'true';
const innerDiv = questionDiv.querySelector('div');
const isEditing = questionDiv.getAttribute('contenteditable');
const question_btn_text_field = document.getElementById('q-edit-button-text-' + item_id);
const question_btn_icon_field = document.getElementById('q-edit-button-icon-' + item_id);
if (isEditing) {
if (isEditing === 'true') {
// Save the edited question
let newQuestion = questionDiv.innerText;
fetch('/api/update_question', {
Expand All @@ -27,19 +28,20 @@ function toggleQuestionEditor(item_id) {
});

questionDiv.setAttribute('contenteditable', 'false');
innerDiv.setAttribute('contenteditable', 'false');
questionDiv.classList.remove('editing');
question_btn_text_field.innerText = 'Edit Q';
question_btn_icon_field.src = staticUrl + "res/questionEditIcon.svg";
questionDiv.classList.add('not-editing');
} else {
// Enable editing
questionDiv.setAttribute('contenteditable', 'true');
innerDiv.setAttribute('contenteditable', 'true');
questionDiv.classList.add('editing');
questionDiv.focus();

question_btn_text_field.innerText = 'Save';
question_btn_icon_field.src = staticUrl + "res/saveIcon.svg";
questionDiv.focus();
questionDiv.classList.add('editing');
}
}
Expand Down
1 change: 1 addition & 0 deletions src/frontend/templates/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css" rel="stylesheet">
<script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script>
<title>LLM Training Tools</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/table_main.css') }}">
</head>

0 comments on commit f365fdc

Please sign in to comment.