{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "67715ad0-1616-45c7-9135-ecf1ccf1d915",
   "metadata": {},
   "source": [
    "### Data Agent Prompting Template\n",
    "\n",
    "Normally, to overwrite the behavior or data prompt context instructions of a ChatLLM model, you would need to go to the Abacus.AI user interface and change it. That is a cubersome process since you need to wait for re-deployment before doing your testing.\n",
    "\n",
    "Using this script, you will be able to:\n",
    "1. Overwrite the instructions of the model on the fly - without changing them permanently\n",
    "2. Make an API request to the model\n",
    "3. Iterate faster\n",
    "\n",
    "If you comment out the `chat_config`, then the model will just use the instructions that it has been trained on. If you leave it, then we will overwrite instructions."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c411f4d7-14db-40b1-a9a7-0c9c0b69c1e7",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2024-06-20T18:16:20.496172Z",
     "iopub.status.busy": "2024-06-20T18:16:20.495787Z",
     "iopub.status.idle": "2024-06-20T18:16:21.450856Z",
     "shell.execute_reply": "2024-06-20T18:16:21.450190Z",
     "shell.execute_reply.started": "2024-06-20T18:16:20.496140Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "from abacusai import PredictionClient\n",
    "client = PredictionClient()\n",
    "\n",
    "deployment_token = \"\"\n",
    "deployment_id = \"\"\n",
    "\n",
    "behavior = \"\"\" FILL IN YOUR BEHAVIOR INSTRUCTIONS\n",
    "\n",
    "\"\"\"\n",
    "\n",
    "data_prompt = \"\"\"\n",
    "FILL IN YOUR DATA PROMPT INSTRUCTIONS\n",
    "\"\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4e872cb7-6e04-42c5-b657-ff20aa6da716",
   "metadata": {
    "editable": true,
    "execution": {
     "iopub.execute_input": "2024-06-20T18:16:36.762992Z",
     "iopub.status.busy": "2024-06-20T18:16:36.762506Z",
     "iopub.status.idle": "2024-06-20T18:16:36.766605Z",
     "shell.execute_reply": "2024-06-20T18:16:36.765822Z",
     "shell.execute_reply.started": "2024-06-20T18:16:36.762960Z"
    },
    "tags": []
   },
   "outputs": [],
   "source": [
    "question = 'What is the .....'\n",
    "chat_config = {'data_prompt_context': data_prompt, 'behavior_instructions':behavior}\n",
    "\n",
    "r = client.get_chat_response(deployment_token=deployment_token,\n",
    "                         deployment_id=deployment_id,\n",
    "                         messages=[{\"is_user\":True,\"text\":question}],\n",
    "                         chat_config=chat_config\n",
    "                         )\n",
    "\n",
    "print(r['messages'][1]['text'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99dc02ea-968e-414f-b41f-f91c9e607218",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
