Skip to content

Commit

Permalink
add defense specific notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
LNshuti committed Jun 8, 2024
1 parent b358fec commit 98e1ad8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/compare_evals.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,22 @@
# must be a dict in these formats, depending
# on your database type
# https://github.com/defog-ai/defog-python/blob/63af5e3ded07da356365f20bc94a194c4f7c44fa/defog/__init__.py#L110
)
)

results = defog.run_query(
"how many from San Francisco",
previous_context=results['previous_context']
)
{
'columns': ['num_users'],
'data': [(50,)],
'query_generated': "SELECT COUNT(*) AS num_users FROM users WHERE city ILIKE '%San Francisco%';",
'ran_successfully': True,
'reason_for_query': "The user is asking for the number of users from San Francisco. The city of the user is stored in the 'city' column of the 'users' table. Therefore, we can use a simple COUNT query to count the number of users from San Francisco. We will use the ILIKE operator to perform a case-insensitive match on the city name, as the user may have typed it in different ways. Since the query only requires one table, we do not need to use a JOIN statement. ",
'previous_context': [
'how many users do we have?',
'SELECT COUNT(userid) AS num_users FROM users;',
'how many from San Francisco?',
"SELECT COUNT(*) AS num_users FROM users WHERE city ILIKE '%San Francisco%';"
]
}

0 comments on commit 98e1ad8

Please sign in to comment.