{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from langchain.agents.agent_toolkits import SQLDatabaseToolkit\n", "from langchain.sql_database import SQLDatabase\n", "from langchain.agents import Tool" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import sqlite3\n", "\n", "conn = sqlite3.connect(\"query_log.db\")\n", "cursor = conn.cursor()\n", "\n", "cursor.execute('''\n", "CREATE TABLE IF NOT EXISTS search_history (\n", " id INTEGER PRIMARY KEY AUTOINCREMENT,\n", " thread_id TEXT,\n", " username TEXT,\n", " feedback TEXT,\n", " reply TEXT,\n", " timestamp DATETIME DEFAULT CURRENT_TIMESTAMP\n", ")\n", "''')\n", "\n", "conn.commit()\n", "conn.close()\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(1, '70d8aa56-75c6-491d-bbb9-a271ac0a6a40', 'benny', \"The assistant provided a comprehensive list of some of the best Italian restaurants in New York City, effectively addressing the user's request for the best Italian food in the area. Each restaurant was accompanied by a brief description, helping the user to understand their options. Overall, the response meets the user's request satisfactorily without additional requests for clarification or further input from the user.\", \"Evaluator Feedback on this answer: The assistant provided a comprehensive list of some of the best Italian restaurants in New York City, effectively addressing the user's request for the best Italian food in the area. Each restaurant was accompanied by a brief description, helping the user to understand their options. Overall, the response meets the user's request satisfactorily without additional requests for clarification or further input from the user.\", '2025-05-17 16:44:55')\n" ] } ], "source": [ "import sqlite3\n", "\n", "# Connect to the database\n", "conn = sqlite3.connect(\"query_log.db\")\n", "cursor = conn.cursor()\n", "\n", "# Fetch all records\n", "cursor.execute(\"SELECT * FROM search_history\")\n", "all_data = cursor.fetchall()\n", "\n", "# Print the data\n", "for row in all_data:\n", " print(row)\n", "\n", "# Close the connection when done\n", "conn.close()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 2 }