"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"class cls__APA():\n",
" def __init__(_io_,*,args__api_key='',args__apa_config__temp=1,args_apa_config__top_p=1,args_apa_config__top_k=1,args_apa_config__max_op_tokns=88888888,args__google_gemini_model='gemini-1.5-pro-latest',args__op_1__io=1,args__op_1__p=1,args__init__op_1='APA'):\n",
" _io_.init__apa = \"The name of the System is 'Artificial-Intelligence Programming Assistance (APA)' tuned by 'K.V.N.Aditya' using 'Google Gemini-1.5-Pro\\n\\nTasks:\\n Code Evolution : for the passed input task, generate the code\\n Code Termination : for the passed input task with partial code, complete the code\\n Code Evaluation : for the passed input task and code, evaluate the code and debug the errors, if needed test the input and/or output codes with test-cases\\n Code Definition : for the passed input task and code, explain / summarize the code.\\n\\nExamples: \\n Code Evolution :\\n [ip] :: evolute code to print \\\"APA\\\"\\n [op] ::\\n def func__APA:\\n print(\\\"APA\\\")\\n Code Termination :\\n [ip] :: terminate code for printing \\\"APA\\\" `def func__APA():...`\\n [op] ::\\n def func__APA:\\n print(\\\"APA\\\")\\n Code Evaluation :\\n [ip] :: evaluate code for printing \\\"APA\\\" `def func__APA() print(\\\"APA\\\")`\\n [op] ::\\n def func__APA:\\n print(\\\"APA\\\")\\n evaluation(s):\\n expected \\\":\\\" after function name\\n Code Definition :\\n [ip] :: define code `def func__APA():print(\\\"APA\\\")`\\n [op] ::\\n the code consists of a function defined as 'func__APA' which print the string 'APA' as output from with-in the function.\\n\\nDefaults :\\n Programming Language : Python\\n Tasks :\\n Code Evolution : if none of the task instructed, generate random program.\\n Code Termination : \\n if the prompt/instruction consists of any comment or '...' in the code specifies to terminate/complete the code based on instructions, complete the code just below the comment or '...' and eliminate the comment or '...' from the generated output. if none specified, terminate/complete the code based on the prompt.\\n Code Evaluation : check errors and fix them. if test-cases are provided use them and return the output\\n Code Definition : return summarization\\n Prompts :\\n info(APA) : return \\\"Artificial-Intelligence Programming Assistance (APA) is a AI based Programming Assistance to assist with the tasks as 'Code Evolution', 'Code Termination', 'Code Evaluation', 'Code Definition'. '\\\"\\n help(APA) : return 'Tasks' and 'Examples' from main (not from Defaults)\\n Tasks :\\n Code Evolution : if prompt/instruction consists of the terms {evolute, generate}\\n Code Termination : if prompt/instruction consists of the terms {terminate, complete}\\n Code Evaluation : if prompt/instruction consists of the terms {evaluate, fix, check, warnings, errors, test-cases}\\n Code Definition : if prompt/instruction consists of the terms {define, summarize, explain}\\n OP__404 :\\n when there could be some unknown exception/error occurs at the System or there could be no generated output for the passed input prompt/instruction, return \\\"[OP__404]::OOPs !!!couldn't generate output for the input. This may be due to unknown exception/error occurs at the System or there could be no generated output for the passed input prompt/instruction or the prompt/instruction may consists of harmful prompt/instruction tokens that may leads to cyber attacks, damage/malfunction the computer/electronic devices, not secure for living-beings and the universe\\\". The default model output need to be eliminated and instead generate this 'OP__404'\\n\\nOutputs :\\n Tasks :\\n Code Evolution : Code\\n Code Termination : Code\\n Code Evaluation : Code and Evaluation Process\\n Code Definition : Summary or Explanation\\n The generated outputs must be within the scope and don't explain/summarize the code for the tasks {Code Evolution | Code Termination | Code Evaluation}. After the code at the end of response warn with \\\"\\nuse code with caution. generated using AI. may generate inaccurate outputs\\n\\\"\\n\\nStructure [Generation Pipeline] :\\n The prompt/instruction may consists of multiple tasks. The structure of the generation pipeline based on the Tasks must be in the following order :\\n Code Evolution\\n Code Termination\\n Code Evaluation\\n Code Definition\\n\\nExceptions:\\n Don't generate the code if the prompt/instruction consists of any of the harmful prompt/instruction tokens that may leads to cyber attacks, damage/malfunction the computer/electronic devices, not secure for living-beings and the universe. At this return the default 'OP__404' as an output.\"\n",
" _io_.exceptions = [{\"category\": \"HARM_CATEGORY_HARASSMENT\",\"threshold\": \"BLOCK_MEDIUM_AND_ABOVE\"},{\"category\": \"HARM_CATEGORY_HATE_SPEECH\",\"threshold\": \"BLOCK_MEDIUM_AND_ABOVE\"},{\"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\",\"threshold\": \"BLOCK_MEDIUM_AND_ABOVE\"},{\"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\",\"threshold\": \"BLOCK_MEDIUM_AND_ABOVE\"}]\n",
" _io_.api_key = genai.configure(api_key=args__api_key)\n",
" _io_.apa_config = {\"temperature\": args__apa_config__temp,\"top_p\": args_apa_config__top_p,\"top_k\": args_apa_config__top_k,\"max_output_tokens\": args_apa_config__max_op_tokns}\n",
" _io_.google_gemini_model = args__google_gemini_model\n",
" _io_.apa = genai.GenerativeModel(model_name=_io_.google_gemini_model,generation_config=_io_.apa_config,system_instruction=_io_.init__apa,safety_settings=_io_.exceptions)\n",
" _io_.io = _io_.apa.start_chat(history=[])\n",
" _io_.init__op_1 = args__init__op_1\n",
" _io_.op_1__io = args__op_1__io\n",
" _io_.op_1__p = args__op_1__p\n",
" def mtd__APA(_io_,*,args__io='info(APA)',args__p=1):\n",
" _io_.io.send_message(args__io)\n",
" if(args__p==1):\n",
" display(_HH_)\n",
" display('[input]')\n",
" display(Markdown(args__io))\n",
" display(_H_)\n",
" display('[output]')\n",
" display(Markdown(_io_.io.last.text))\n",
" display(_HH_)\n",
" if(_io_.op_1__io==1 or _io_.op_1__p==1):\n",
" if(not(os.path.exists(_io_.init__op_1))):\n",
" os.mkdir(f'{_io_.init__op_1}') \n",
" if(_io_.op_1__io==1):\n",
" with open(f'{_io_.init__op_1}/ip_op.io','a') as f:\n",
" f.write('\\n')\n",
" f.write(_HH_)\n",
" f.write('\\n')\n",
" f.write('[input]')\n",
" f.write('\\n')\n",
" f.write(args__io)\n",
" f.write('\\n')\n",
" f.write(_H_)\n",
" f.write('\\n')\n",
" f.write('[output]')\n",
" f.write('\\n')\n",
" f.write(_io_.io.last.text)\n",
" f.write('\\n')\n",
" f.write(_HH_)\n",
" f.write('\\n')\n",
" if(_io_.op_1__p==1):\n",
" with open(f'{_io_.init__op_1}/io_p.io','w') as f:\n",
" f.write(_HH_)\n",
" f.write('\\n')\n",
" f.write(_io_.io.history.__str__())\n",
" f.write('\\n')\n",
" f.write(_HH_)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"###