Skip to content

Commit

Permalink
Update SQL scripts for dev work.
Browse files Browse the repository at this point in the history
  • Loading branch information
liffiton committed Jul 12, 2024
1 parent 984c21c commit fdd9052
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
15 changes: 0 additions & 15 deletions dev/sql/20230420_average_token_usage_per_query.sql

This file was deleted.

10 changes: 10 additions & 0 deletions dev/sql/20240613_select_testcases.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.mode csv
.headers on

SELECT queries.id, queries.query_time, queries.language, queries.code, queries.error, queries.issue, json_extract(queries.response_text, '$.main') as main_response, json_extract(queries.response_text, '$.insufficient') as insufficient_response
FROM queries
JOIN roles ON queries.role_id = roles.id
WHERE query_time > date("2023-09-30") -- only once it was in use in real classes
AND roles.role = "student" -- only queries from students in a class
ORDER BY RANDOM()
LIMIT 100;
15 changes: 15 additions & 0 deletions dev/sql/avg_tokens_per_query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.mode box
SELECT
AVG(Prompt) AS Prompt_avg,
AVG(Completion) AS Completion_avg
FROM (
SELECT
q.id,
SUM(json_extract(value, '$.usage.prompt_tokens')) AS "Prompt",
SUM(json_extract(value, '$.usage.completion_tokens')) AS "Completion"
FROM queries AS q, json_each(q.response_json, '$')
WHERE json_valid(value)
GROUP BY q.id
ORDER BY q.id DESC
LIMIT 10000
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ SELECT

-- Extract examples w/ code still in
SELECT
id, json_extract(response_json, '$[1].choices[0].message.content')
id, response_text
FROM queries
WHERE id >= 935 AND
json_extract(response_json, '$[2].choices[0].message.content') LIKE "%```%"
response_text LIKE "%```%"
--json_extract(response_json, '$[2].choices[0].message.content') LIKE "%```%"
;

0 comments on commit fdd9052

Please sign in to comment.