Skip to content

Commit 38af092

Browse files
committed
Return prompt in LinkedIn prompt responses
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.
1 parent 5c5f427 commit 38af092

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

app/api/prompt/linkedin.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def linkedin_prompt_success(payload: dict, api_key: str = Depends(get_api_key))
3636
if has_search_vector:
3737
cur.execute(
3838
"""
39-
SELECT id, completion, time, model, data
39+
SELECT id, prompt, completion, time, model, data
4040
FROM prompt
4141
WHERE (
4242
COALESCE(data->>'linkedin_url', data->>'linkedinUrl') = %s
@@ -51,7 +51,7 @@ def linkedin_prompt_success(payload: dict, api_key: str = Depends(get_api_key))
5151
else:
5252
cur.execute(
5353
"""
54-
SELECT id, completion, time, model, data
54+
SELECT id, prompt, completion, time, model, data
5555
FROM prompt
5656
WHERE (COALESCE(data->>'linkedin_url', data->>'linkedinUrl') = %s OR prompt ILIKE %s)
5757
ORDER BY id DESC
@@ -68,10 +68,11 @@ def linkedin_prompt_success(payload: dict, api_key: str = Depends(get_api_key))
6868
"cached": True,
6969
"id": row[0],
7070
"linkedin_url": linkedin_url,
71-
"completion": row[1],
72-
"time": row[2].isoformat() if row[2] else None,
73-
"model": row[3],
74-
"record_data": row[4],
71+
"prompt": row[1],
72+
"completion": row[2],
73+
"time": row[3].isoformat() if row[3] else None,
74+
"model": row[4],
75+
"record_data": row[5],
7576
},
7677
}
7778

@@ -80,6 +81,7 @@ def linkedin_prompt_success(payload: dict, api_key: str = Depends(get_api_key))
8081
"data": {
8182
"cached": False,
8283
"linkedin_url": linkedin_url,
84+
"prompt": None,
8385
"completion": None,
8486
},
8587
}

0 commit comments

Comments
 (0)