Skip to content

Commit

Permalink
ensure english prose
Browse files Browse the repository at this point in the history
  • Loading branch information
lostmygithubaccount committed Feb 13, 2024
1 parent 8e9197f commit d7ae737
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
5 changes: 4 additions & 1 deletion src/ibis_birdbrain/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ def respond(messages: Messages) -> str:

@marvin.fn
def messages_to_text_query(messages: Messages) -> str:
"""Convert the messages to a text query."""
"""Convert the messages to an English text query.
Returns the English prose that concisely describes the desired query.
"""


@marvin.fn
Expand Down
57 changes: 29 additions & 28 deletions untitled.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@
"To: user\n",
"From: birdbrain\n",
"Subject: response\n",
"Sent at: 2024-02-12 20:59:18.917163\n",
"Message: f46a6a5b-7395-4d23-8c35-dd60e8c9203b\n",
"Sent at: 2024-02-12 21:14:13.606857\n",
"Message: 9f35f048-ef48-42c1-bd7c-65ee2ce3da38\n",
"\n",
"The data is a table with mortgage loan information, including fields such as loan and servicer identifiers, loan terms, borrower's credit score, loan status, property details, and financial metrics. Schema provided in the request details the types and names of each column.\n",
"The 'mortgage' table reflects a dataset providing information on mortgage loans. Each row represents a loan with fields describing various attributes such as loan ID, seller and servicer names, interest rates, outstanding balance, loan terms, and borrower information. Additionally, it details loan performance, including payment history, current delinquency status, and any foreclosure proceedings. The table also contains data on loan modifications, property valuation, and recovery proceeds, enabling analysis regarding the mortgage portfolio's health and performance.\n",
"\n",
"Attachments:\n",
"\n"
Expand Down Expand Up @@ -191,7 +191,7 @@
"output_type": "stream",
"text": [
"INFO:httpx:HTTP Request: POST https://api.openai.com/v1/chat/completions \"HTTP/1.1 200 OK\"\n",
"INFO:root:Extracted GUIDs: ['bb0114da-7c18-4fbb-a141-b734133ec4f5']\n"
"INFO:root:Extracted GUIDs: ['e9f1ae72-0693-4a70-adde-9af181c5bf51']\n"
]
},
{
Expand All @@ -209,8 +209,8 @@
"output_type": "stream",
"text": [
"INFO:root:Attachments: TableAttachment\n",
" **guid**: bb0114da-7c18-4fbb-a141-b734133ec4f5\n",
" **time**: 2024-02-12 20:59:11.185707\n",
" **guid**: e9f1ae72-0693-4a70-adde-9af181c5bf51\n",
" **time**: 2024-02-12 21:13:53.864277\n",
" **name**: mortgage\n",
" **desc**: \n",
"ibis.Schema {\n",
Expand Down Expand Up @@ -393,23 +393,23 @@
"To: \n",
"From: \n",
"Subject: SQL code\n",
"Sent at: 2024-02-12 20:59:35.895894\n",
"Message: 0a8b58b5-7399-4074-9245-d2515d9ba77b\n",
"Sent at: 2024-02-12 21:14:37.107152\n",
"Message: 07cef6a7-551b-44e7-9f50-ba9a62f70035\n",
"\n",
"SQL attachted for query: SELECT AVG(original_interest_rate) as average_interest_rate FROM mortgage\n",
"SQL attachted for query: The query is to calculate the average current interest rate across all loans in the 'mortgage' table.\n",
"\n",
"Attachments:\n",
"\n",
"CodeAttachment\n",
" **guid**: 1064f4a2-6533-4058-874e-088e99911aa7\n",
" **time**: 2024-02-12 20:59:35.895868\n",
" **guid**: 9db96d25-afe9-4926-b24a-b3f5d0176ecc\n",
" **time**: 2024-02-12 21:14:37.107135\n",
" **name**: None\n",
" **desc**: None\n",
" **text**:\n",
"SELECT AVG(original_interest_rate) as average_interest_rate FROM mortgage\n",
"SELECT AVG(current_interest_rate) FROM mortgage\n",
" **language**: sql\n",
" **code**:\n",
"SELECT AVG(original_interest_rate) as average_interest_rate FROM mortgage"
"SELECT AVG(current_interest_rate) FROM mortgage"
]
},
"execution_count": 7,
Expand All @@ -429,23 +429,23 @@
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">┏━━━━━━━━━━━━━━━━━━━━━━━┓\n",
"┃<span style=\"font-weight: bold\"> average_interest_rate </span>┃\n",
"┡━━━━━━━━━━━━━━━━━━━━━━━┩\n",
"│ <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">float64</span> │\n",
"├───────────────────────┤\n",
"│ <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7.960559</span> │\n",
"└───────────────────────┘\n",
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"┃<span style=\"font-weight: bold\"> avg(current_interest_rate) </span>┃\n",
"┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"│ <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">float64</span> \n",
"├────────────────────────────\n",
" <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">7.928592</span> │\n",
"└────────────────────────────\n",
"</pre>\n"
],
"text/plain": [
"┏━━━━━━━━━━━━━━━━━━━━━━━┓\n",
"\u001b[1m \u001b[0m\u001b[1maverage_interest_rate\u001b[0m\u001b[1m \u001b[0m┃\n",
"┡━━━━━━━━━━━━━━━━━━━━━━━┩\n",
"\u001b[2mfloat64\u001b[0m │\n",
"├───────────────────────┤\n",
"\u001b[1;36m7.960559\u001b[0m │\n",
"└───────────────────────┘"
"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"\u001b[1m \u001b[0m\u001b[1mavg(current_interest_rate)\u001b[0m\u001b[1m \u001b[0m┃\n",
"┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n",
"\u001b[2mfloat64\u001b[0m \n",
"├────────────────────────────\n",
" \u001b[1;36m7.928592\u001b[0m │\n",
"└────────────────────────────"
]
},
"execution_count": 8,
Expand All @@ -454,7 +454,8 @@
}
],
"source": [
"bot.con.sql(\"SELECT AVG(original_interest_rate) as average_interest_rate FROM mortgage\")"
"#bot.con.sql(\"SELECT AVG(original_interest_rate) as average_interest_rate FROM mortgage\")\n",
"bot.con.sql(\"SELECT AVG(current_interest_rate) FROM mortgage\")"
]
},
{
Expand Down

0 comments on commit d7ae737

Please sign in to comment.