Skip to content

Conversation

@nahcol10
Copy link

@nahcol10 nahcol10 commented Jul 1, 2025

✅ Database Sync & Feature Integration

I’ve implemented the following tables and related methods to ensure they are fully in sync with the rest of the codebase:


📦 Tables Implemented:

  • docs_response
  • documents
  • responses

Following this ER diagram:

image


🛠️ Core Functions:

Database & Table Setup

  • create_connection()
  • create_table(conn)
  • create_prompts_table(conn)
  • create_response_table(conn)
  • create_document_table(conn)
  • create_docs_response_table(conn)
  • create_all_tables(conn)

User Management

  • insert_user(conn, username, email, type)
  • update_user_loggedin(conn, email, loggedin)
  • update_user_email_verified(conn, email, email_verified)
  • get_user(conn, email)

Prompt Management

  • save_prompt(conn, prompt_type, prompt_value)
  • get_prompt(conn, prompt_type)
  • get_all_prompts(conn)

Response Management

  • insert_response(conn, answer, question, id_user=None)
  • get_response(conn, response_id)
  • get_responses_by_user(conn, user_id)
  • update_response(conn, response_id, answer=None, question=None)
  • delete_response(conn, response_id)

Document Management

  • insert_document(conn, source, metadata=None)
  • get_document(conn, document_id)
  • get_document_by_source(conn, source)
  • get_all_documents(conn)
  • update_document(conn, document_id, source=None, metadata=None)
  • delete_document(conn, document_id)

Linking Docs & Responses

  • link_document_response(conn, id_response, id_document)
  • unlink_document_response(conn, id_response, id_document)
  • get_documents_for_response(conn, response_id)
  • get_responses_for_document(conn, document_id)
  • get_all_document_response_links(conn)
  • get_all_responses_with_documents(conn)

Migration

  • migrate_text_file_to_database(conn, responses_file="responses.txt")

📄 Text-to-DB Migration

  • The system originally stored all AI responses in a flat responses.txt file.
  • Each line included:
    • A complete response (question + answer)
    • Associated document(s)
    • Metadata in a structured string format
  • Now, this data is successfully migrated and normalized into the database using the above methods.

🎬 Demo of the fix:
Watch here


…debase

Signed-off-by: lochan paudel <lochanpaudel10@gmail.com>
@gcapuzzi gcapuzzi merged commit 5de88e2 into hyperledger-labs:agents Jul 2, 2025
5 checks passed
@nahcol10 nahcol10 deleted the database branch August 3, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants