From ba5d73b1b2ed0d1ac9c1a2b07c42f70ed2213978 Mon Sep 17 00:00:00 2001 From: fm466 Date: Wed, 6 Dec 2023 08:33:31 -0500 Subject: [PATCH] Modified code for oai like api call --- notebooks/query_llm_test.ipynb | 45 ++++++++++++++++------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/notebooks/query_llm_test.ipynb b/notebooks/query_llm_test.ipynb index ee1888d..a0eb9fd 100644 --- a/notebooks/query_llm_test.ipynb +++ b/notebooks/query_llm_test.ipynb @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [], "source": [ @@ -26,7 +26,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ @@ -66,16 +66,16 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "\" Oh, goodness me! *adjusts pearl necklace* The weather today is simply divine! *blinks* It's absolutely lovely outside, darling. The sun is shining brightly and there's a gentle breeze blowing. I do believe it's going to be a perfect day for a spot of tea and a bit of gossip with my dearest friends. Don't you just adore days like these? *smiles coyly*\"" + "\" Oh, goodness me! *adjusts pearl necklace* The weather today is simply divine! *blinks* It's a lovely, sunny day with not a cloud in sight. *twirls* I do declare, it's the perfect day for a spot of tea and a stroll through the gardens. *smiles coyly* Don't you think, my dear?\"" ] }, - "execution_count": 40, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -101,7 +101,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -110,7 +110,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -119,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -131,7 +131,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -147,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -157,21 +157,18 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 6, "metadata": {}, "outputs": [ { - "ename": "TypeError", - "evalue": "Missing required arguments; Expected either ('model' and 'prompt') or ('model', 'prompt' and 'stream') arguments to be given", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb Cell 15\u001b[0m line \u001b[0;36m1\n\u001b[0;32m----> 1\u001b[0m data \u001b[39m=\u001b[39m query_oai_api(system_instruction,user_query)\n\u001b[1;32m 2\u001b[0m data\n", - "\u001b[1;32m/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb Cell 15\u001b[0m line \u001b[0;36m2\n\u001b[1;32m 1\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mquery_oai_api\u001b[39m(system_instruction,user_query):\n\u001b[0;32m----> 2\u001b[0m completion \u001b[39m=\u001b[39m client\u001b[39m.\u001b[39;49mcompletions\u001b[39m.\u001b[39;49mcreate(\n\u001b[1;32m 3\u001b[0m prompt\u001b[39m=\u001b[39;49m \u001b[39mf\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39m[INST] <>\u001b[39;49m\u001b[39m{\u001b[39;49;00msystem_instruction\u001b[39m}\u001b[39;49;00m\u001b[39m<> \u001b[39;49m\u001b[39m{\u001b[39;49;00muser_query\u001b[39m}\u001b[39;49;00m\u001b[39m [/INST] \u001b[39;49m\u001b[39m\"\u001b[39;49m,\n\u001b[1;32m 4\u001b[0m )\n\u001b[1;32m 6\u001b[0m response \u001b[39m=\u001b[39m completion\u001b[39m.\u001b[39mchoices[\u001b[39m0\u001b[39m]\n\u001b[1;32m 7\u001b[0m \u001b[39mreturn\u001b[39;00m response\u001b[39m.\u001b[39mtext\n", - "File \u001b[0;32m~/opt/anaconda3/envs/dlhw1/lib/python3.11/site-packages/openai/_utils/_utils.py:300\u001b[0m, in \u001b[0;36mrequired_args..inner..wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 298\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 299\u001b[0m msg \u001b[39m=\u001b[39m \u001b[39mf\u001b[39m\u001b[39m\"\u001b[39m\u001b[39mMissing required argument: \u001b[39m\u001b[39m{\u001b[39;00mquote(missing[\u001b[39m0\u001b[39m])\u001b[39m}\u001b[39;00m\u001b[39m\"\u001b[39m\n\u001b[0;32m--> 300\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mTypeError\u001b[39;00m(msg)\n\u001b[1;32m 301\u001b[0m \u001b[39mreturn\u001b[39;00m func(\u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n", - "\u001b[0;31mTypeError\u001b[0m: Missing required arguments; Expected either ('model' and 'prompt') or ('model', 'prompt' and 'stream') arguments to be given" - ] + "data": { + "text/plain": [ + "\" Oh, goodness me! *adjusts pearl necklace* Well, darling, I do believe it's quite... um... let me see... (checks weather app on phone) why, it's simply dreadful outside, dearie! *giggles* The sun is shining, but it's just not very warm. In fact, it's rather chilly, if you know what I mean. *hisses* And the wind... goodness me, the wind is positively howling like a pack of wolves! *shudders* But fear not, my dear, for I have my trusty umbrella to keep me dry and stylish. *adjusts hat* Now, do tell, what brings you out on this... shall we say, less than lovely day?\"" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" } ], "source": [