Skip to content

Commit

Permalink
Modified code for oai like api call
Browse files Browse the repository at this point in the history
  • Loading branch information
FalgunMalhotra committed Dec 6, 2023
1 parent 5e3cae4 commit ba5d73b
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions notebooks/query_llm_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -35,7 +35,7 @@
},
{
"cell_type": "code",
"execution_count": 38,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -56,7 +56,7 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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"
}
Expand All @@ -101,7 +101,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -110,7 +110,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -119,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -131,7 +131,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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----> <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m data \u001b[39m=\u001b[39m query_oai_api(system_instruction,user_query)\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=1'>2</a>\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 <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mquery_oai_api\u001b[39m(system_instruction,user_query):\n\u001b[0;32m----> <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=1'>2</a>\u001b[0m completion \u001b[39m=\u001b[39m client\u001b[39m.\u001b[39;49mcompletions\u001b[39m.\u001b[39;49mcreate(\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=2'>3</a>\u001b[0m prompt\u001b[39m=\u001b[39;49m \u001b[39mf\u001b[39;49m\u001b[39m\"\u001b[39;49m\u001b[39m[INST] <<SYS>>\u001b[39;49m\u001b[39m{\u001b[39;49;00msystem_instruction\u001b[39m}\u001b[39;49;00m\u001b[39m<<SYS>> \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 <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=3'>4</a>\u001b[0m )\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=5'>6</a>\u001b[0m response \u001b[39m=\u001b[39m completion\u001b[39m.\u001b[39mchoices[\u001b[39m0\u001b[39m]\n\u001b[1;32m <a href='vscode-notebook-cell:/Users/falgunmalhotra/Documents/projects/Persona-LLM-Chatbot-For-QA/notebooks/query_llm_test.ipynb#X20sZmlsZQ%3D%3D?line=6'>7</a>\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.<locals>.inner.<locals>.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": [
Expand Down

0 comments on commit ba5d73b

Please sign in to comment.