This pull request introduces significant improvements to the LLM API, including database integration for storing and retrieving LLM completions, new SQL and utility scripts, and updated tests.#58
Merged
goldlabelapps merged 2 commits intomasterfrom Apr 4, 2026
Conversation
Create a new llm table SQL schema (vector(1536), prompt, completion, duration, time, data). Add a small psycopg2 seed script (insert_llm_lorem.py) that loads .env, connects to the DB and inserts 5 dummy records with random 1536-d vectors. Rename tests/test_gemini.py to tests/test_llm.py and update tests to use LLM naming and /llm endpoints, adjust skip/failure messages and assertions accordingly (including updated mocked API handling). These changes introduce the DB schema and local seeding helper and align tests to the LLM endpoint/name changes.
Add a paginated GET /llm endpoint that queries the llm table and returns page metadata. Enhance POST /llm to time Gemini calls, persist completions (prompt, completion, duration, data, model) to the database (errors logged but not exposed), and use a direct DB connection helper. Update SQL to add a model column to the llm table, bump package version to 2.1.2, and adjust tests to match the new meta title content.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
/llmendpoint now supports paginated retrieval of completions from the database, and the POST endpoint records each completion along with metadata. Additionally, a new table schema and a data seeding script are added, and tests are updated to reflect the new API.API and Database Integration:
/llmGET endpoint now returns a paginated list of LLM completions from the database, including metadata such as total records and pages./llmPOST endpoint now records each prompt, completion, duration, and related metadata in the newllmdatabase table after a successful LLM call. [1] [2] [3]Database Schema and Utility Scripts:
app/api/llm/sql/create_table.sqlto define thellmtable schema, including fields for vector, prompt, completion, duration, time, data, and model.app/api/llm/sql/insert_llm_lorem.pyscript to insert sample records into thellmtable for testing or development purposes.Testing and Versioning:
test_gemini.pytotest_llm.py, updating them to target the new/llmendpoints and revised API responses. [1] [2] [3] [4]2.1.2inapp/__init__.py.