This pull request introduces several improvements and cleanups to the prompt handling API, particularly around LinkedIn profile analysis and prompt record management. #85
Merged
goldlabelapps merged 5 commits intomasterfrom Apr 13, 2026
Conversation
Accept both linkedin_url and legacy linkedinUrl in request payloads and normalize to linkedin_url. Update error message to reference linkedin_url. Query logic now checks for a search_vector column and, if present, uses full-text search (plainto_tsquery) plus COALESCE(data->>'linkedin_url', data->>'linkedinUrl') to match stored data; otherwise fall back to previous prompt ILIKE / data match. Responses now return linkedin_url in the data payload for consistency and backwards-compatible lookup.
Remove the prospect_id foreign key from the prompt CREATE TABLE SQL and adjust column order (model moved before data). Also delete drop_llm_table.sql which contained DROP TABLE IF EXISTS llm. Note: this updates the table creation script only—apply a DB migration if you need to remove the existing column or preserve data.
Include the original prompt in cached LinkedIn prompt lookups by adding the prompt column to the SELECT queries and updating the row index mappings. Also add a prompt key (None when not cached) to the response payload so callers receive the associated prompt along with completion, time, model, and record data.
Drop prospect_id filtering and storage from prompt APIs and DB interactions. get_prompt_records no longer accepts or handles prospect_id and always returns paginated prompt records (SELECT no longer includes prospect_id). llm_post no longer reads prospect_id from payload and INSERT into prompt omits the prospect_id column. Error handling and pagination metadata preserved.
When a LinkedIn URL is not found in cache, call Google Gemini to generate a profile analysis and store the result. Adds GEMINI_API_KEY env check, a default prompt if none supplied, and a model fallback loop that tries several Gemini models until one returns text. Inserts the completion, model, duration and metadata into the prompt table (with search_vector when available), closes DB cursors/connections earlier, and returns the generated completion and record id in the response. Improves error handling and updates response meta messages accordingly.
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 most significant changes include enhancing the LinkedIn prompt endpoint to use Gemini models for analysis, improving prompt caching and database logic, and removing the deprecated
prospect_idfield and related logic from the codebase and database schema.LinkedIn Prompt Enhancements:
/prompt/linkedinendpoint now generates a Gemini model analysis if no cached result is found, using multiple model fallbacks and returning a detailed response with metadata, model used, and duration. The prompt is also dynamically constructed if not provided. [1] [2] [3] [4]Database and Schema Updates:
prompttable schema has been updated to remove theprospect_idfield and its foreign key, as well as the deprecateddatacolumn placement.llmtable drop statement has been removed from the SQL migration scripts.Prompt Record Management Cleanups:
prospect_idhave been removed from the/promptendpoints, simplifying both the API and the database interactions. [1] [2] [3] [4]These changes modernize the prompt analysis workflow, streamline the database schema, and remove unused or deprecated functionality for improved maintainability.