From 66eb1dcfc5d5b791d7c8718bb4752c93e44b160d Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Sat, 8 Apr 2023 12:39:03 +0700 Subject: [PATCH 01/64] Add exec_shell command --- scripts/commands.py | 4 +++- scripts/data/prompt.txt | 3 ++- scripts/execute_code.py | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/scripts/commands.py b/scripts/commands.py index fc10d1d052..187ad6c4b3 100644 --- a/scripts/commands.py +++ b/scripts/commands.py @@ -7,7 +7,7 @@ import speak from config import Config import ai_functions as ai from file_operations import read_file, write_to_file, append_to_file, delete_file, search_files -from execute_code import execute_python_file +from execute_code import execute_python_file, exec_shell from json_parser import fix_and_parse_json from duckduckgo_search import ddg from googleapiclient.discovery import build @@ -102,6 +102,8 @@ def execute_command(command_name, arguments): return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) + elif command_name == "exec_shell": # Add this command + return exec_shell(arguments["command_line"]) elif command_name == "task_complete": shutdown() else: diff --git a/scripts/data/prompt.txt b/scripts/data/prompt.txt index 28797d9e24..e7d0cd824a 100644 --- a/scripts/data/prompt.txt +++ b/scripts/data/prompt.txt @@ -22,7 +22,8 @@ COMMANDS: 16. Get Improved Code: "improve_code", args: "suggestions": "", "code": "" 17. Write Tests: "write_tests", args: "code": "", "focus": "" 18. Execute Python File: "execute_python_file", args: "file": "" -19. Task Complete (Shutdown): "task_complete", args: "reason": "" +19. Execute Shell Command: "exec_shell", args: "command_line": "" +20. Task Complete (Shutdown): "task_complete", args: "reason": "" RESOURCES: diff --git a/scripts/execute_code.py b/scripts/execute_code.py index 614ef6fc3d..5d4f7236a9 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -1,5 +1,6 @@ import docker import os +import subprocess def execute_python_file(file): @@ -45,3 +46,17 @@ def execute_python_file(file): except Exception as e: return f"Error: {str(e)}" + + + +def exec_shell(command_line): + + args = command_line.split() + + result = subprocess.run(args, capture_output=True) + + output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"; + + # print(f"Shell execution complete. Output: {output}") + + return output From 7867c8dc3445b97d684893a64f49cd0eb0270563 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Sun, 9 Apr 2023 18:43:20 +0700 Subject: [PATCH 02/64] Update prompt (advise GPT to use only shell commands that terminate) --- scripts/data/prompt.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/data/prompt.txt b/scripts/data/prompt.txt index e7d0cd824a..5b139586ed 100644 --- a/scripts/data/prompt.txt +++ b/scripts/data/prompt.txt @@ -22,7 +22,7 @@ COMMANDS: 16. Get Improved Code: "improve_code", args: "suggestions": "", "code": "" 17. Write Tests: "write_tests", args: "code": "", "focus": "" 18. Execute Python File: "execute_python_file", args: "file": "" -19. Execute Shell Command: "exec_shell", args: "command_line": "" +19. Execute Shell Command: "exec_shell", args: "command_line": "". Remember only to use commands that terminate, interactive tools like vim are not supported! 20. Task Complete (Shutdown): "task_complete", args: "reason": "" RESOURCES: From 955b83c136bd2e471e97f019ec59d1ecd76b5837 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Mon, 10 Apr 2023 10:16:24 +0700 Subject: [PATCH 03/64] Make line in prompt more concise --- scripts/data/prompt.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/data/prompt.txt b/scripts/data/prompt.txt index d6289b6c0b..f8043496fb 100644 --- a/scripts/data/prompt.txt +++ b/scripts/data/prompt.txt @@ -22,7 +22,7 @@ COMMANDS: 16. Get Improved Code: "improve_code", args: "suggestions": "", "code": "" 17. Write Tests: "write_tests", args: "code": "", "focus": "" 18. Execute Python File: "execute_python_file", args: "file": "" -19. Execute Shell Command: "exec_shell", args: "command_line": "". Remember only to use commands that terminate, interactive tools like vim are not supported! +19. Execute Shell Command, non-interactive commands only: "exec_shell", args: "command_line": "". 20. Task Complete (Shutdown): "task_complete", args: "reason": "" 21. Generate Image: "generate_image", args: "prompt": "" From dd469bf2aec173903a8e9d196ca1607e7a356884 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Mon, 10 Apr 2023 10:26:54 +0700 Subject: [PATCH 04/64] Change working directory during shell command execution --- ai_settings.yaml | 11 +++++------ auto-gpt.json | 1 + scripts/execute_code.py | 20 ++++++++++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 auto-gpt.json diff --git a/ai_settings.yaml b/ai_settings.yaml index b37ba849f9..8385c2a85c 100644 --- a/ai_settings.yaml +++ b/ai_settings.yaml @@ -1,7 +1,6 @@ ai_goals: -- Increase net worth. -- Develop and manage multiple businesses autonomously. -- Play to your strengths as a Large Language Model. -ai_name: Entrepreneur-GPT -ai_role: an AI designed to autonomously develop and run businesses with the sole goal - of increasing your net worth. +- Increase net worth +- Grow Twitter Account +- Develop and manage multiple businesses autonomously +ai_name: A helpful assistant. +ai_role: Run the command "pwd" on the shell and return the result diff --git a/auto-gpt.json b/auto-gpt.json new file mode 100644 index 0000000000..f575113dbf --- /dev/null +++ b/auto-gpt.json @@ -0,0 +1 @@ +{"texts":["Assistant Reply: {\n \"thoughts\": {\n \"text\": \"I think the best next step would be to execute a shell command to print the contents of the present working directory.\",\n \"reasoning\": \"Since the user asked us to run the command \\\"pwd\\\" on the shell, the \\\"exec_shell\\\" command would be appropriate for this purpose.\",\n \"plan\": \"- Run the \\\"exec_shell\\\" command to execute the shell command \\\"pwd\\\"\",\n \"criticism\": \"I think this plan is effective and efficient.\",\n \"speak\": \"I will execute shell command 'pwd' to print the present working directory.\"\n },\n \"command\": {\n \"name\": \"exec_shell\",\n \"args\": {\n \"command_line\": \"pwd\"\n }\n }\n} \nResult: Command exec_shell returned: STDOUT:\nb'/Users/bernhardmueller/Projects/Auto-GPT/auto_gpt_workspace\\n'\nSTDERR:\nb'' \nHuman Feedback: GENERATE NEXT COMMAND JSON "],"embeddings":[[-0.018769644,0.0182558,0.0018234389,0.0018377124,-0.012867555,0.02128178,-0.0038145913,-0.036654335,-0.02463605,-0.03100203,0.032629207,0.015087083,-0.024693144,-0.012196701,-0.0068155937,0.00007237108,0.020482464,-0.015872126,-0.00052009046,-0.002121398,0.018355714,-0.002290896,0.014123622,-0.008492729,0.004988586,-0.018427081,0.013260076,-0.009584651,-0.004642454,-0.008521276,0.003152658,0.0013559819,0.01390952,-0.01592922,-0.007051106,-0.012096786,-0.015358279,-0.028575536,0.014059392,0.011375975,0.0021035562,0.004517561,0.0070368326,-0.03222955,-0.03671143,0.01035542,0.013930931,-0.0445333,0.0054881587,0.013252939,0.0134741785,0.025235537,-0.027076818,0.02577793,0.019925797,0.006469461,-0.008571234,0.029317757,-0.008200122,-0.012639179,0.010191275,-0.016371697,-0.018327167,0.04145023,0.021338874,-0.009506147,-0.0073223026,0.0038003179,-0.010041404,-0.0017824026,0.020082807,0.015543835,0.0004728095,0.008813882,0.03628322,0.007836148,-0.021253234,0.014209263,0.0036272516,0.011047685,0.008164438,-0.008870977,0.0036343886,0.02871827,0.01748503,-0.012917512,0.00088852504,0.039280657,-0.026120495,-0.026063401,-0.01809879,0.008392815,0.000052048075,0.011925505,0.004949334,0.022937505,0.0021749237,0.0030723696,-0.0070082857,-0.03525553,-0.0031187586,0.019654602,-0.027305195,-0.009391959,-0.02858981,0.003372113,-0.008357131,-0.007268777,0.0397945,0.00006802212,-0.023608359,0.02328007,-0.020411097,-0.017870415,0.002301601,-0.025149897,0.019511867,-0.019925797,-0.03933775,-0.0032365147,0.027847588,0.012703409,0.04558954,-0.016200416,0.020924943,0.0027530002,-0.025363998,-0.030887842,0.010119908,0.0064123673,0.020596651,0.017270928,-0.005206257,0.0017226323,-0.016856996,0.026291776,-0.014266358,0.016671441,-0.0029278505,-0.02288041,0.047359455,0.031744253,-0.0039537577,0.014644605,-0.014730246,0.03865262,0.029075108,0.0056380304,-0.0044140783,-0.0065158503,0.010954907,-0.00029662106,0.023993744,0.002637028,0.004956471,0.018526996,0.019454774,0.012282342,-0.00087826594,-0.014173579,-0.0017021142,0.020496737,0.023722548,-0.0007266101,0.014844434,0.03163006,0.03399946,0.023622632,0.013509862,-0.01809879,-0.027562117,0.017913235,-0.04047963,0.020354003,0.014230674,0.018155884,0.0078076012,0.009798754,-0.007479311,0.001231981,0.00035036966,0.018783918,-0.006216107,0.031515874,0.0057807653,-0.035398267,0.0021552977,-0.013281486,0.014758793,0.00008447009,0.009342002,0.038338605,-0.0058414275,-0.010284052,-0.61296093,-0.02582075,-0.021438789,-0.023594085,0.020639472,0.014544691,-0.024008017,0.014159306,-0.021481609,0.037025444,-0.0099414885,0.0078076012,0.009855848,-0.02340853,0.008000294,-0.015272639,-0.01691409,-0.0070439694,-0.010305462,0.018212978,-0.018969474,0.0037503606,-0.024793059,-0.005013565,-0.012632042,-0.012232385,0.007936063,-0.0070867897,-0.005159868,0.042535014,-0.02994579,0.0071367472,-0.0045068557,-0.013095931,0.06748508,0.0099414885,-0.029603226,-0.0046959794,-0.0182558,0.03205827,-0.03194408,-0.023694001,-0.0022338019,-0.0055845045,-0.0031490896,0.0055452525,0.011397385,-0.010255505,-0.0010749726,-0.006419504,0.02838998,-0.0019554687,-0.0018171943,-0.008507002,0.022723403,0.01390952,0.042420823,-0.013773922,-0.005224099,-0.005131321,0.025920665,0.039651766,-0.01797033,-0.0052490775,-0.037967496,0.03574083,-0.008300037,-0.0021196138,-0.018227251,-0.052383725,0.011932641,0.010683711,-0.026891263,-0.018398535,-0.0034666748,0.003764634,0.016414518,-0.006448051,-0.0074364906,0.040907834,0.02108195,-0.018655457,-0.0066336063,0.0002598222,0.023694001,0.0017154956,-0.012553538,-0.019269217,-0.0064944397,0.0000132977675,0.0075221313,-0.005734376,-0.00086131616,-0.00853555,0.028775364,0.018841011,0.006694269,-0.03514134,-0.005327582,-0.021267507,-0.01682845,0.0035326898,-0.0050456803,0.03222955,0.009234951,0.005766492,-0.027747672,0.022966051,0.0030313334,-0.014394819,-0.007275914,0.009213541,-0.0047887573,-0.0015049615,-0.000793071,-0.03762493,0.03194408,0.004142882,0.015172725,-0.028618356,0.012032555,-0.008407088,-0.009135037,-0.010648027,0.03382818,0.011218966,0.020368276,-0.037967496,0.008050251,0.024735965,-0.03636886,-0.019611781,0.026805623,0.0056594405,0.0057486496,0.007172431,0.02385101,-0.024992889,0.019982891,-0.020154174,-0.03399946,0.006112624,-0.0027726262,-0.021510156,0.00068512774,-0.03479878,-0.011347428,-0.0015085299,-0.017941782,-0.0011258218,-0.0023711843,-0.0030241965,0.0015290481,0.050670903,0.01818443,-0.02867545,0.0017315532,-0.031059124,0.030630918,-0.014758793,0.012667726,0.021296054,-0.007365123,-0.0009937921,-0.013153025,-0.0005780765,-0.011090505,0.014152169,0.0060662352,-0.03648305,0.012453624,0.0057593547,0.021809898,-0.0055238423,-0.004899377,0.008178712,-0.032714847,-0.014216401,-0.013716828,0.0020072102,0.002579934,0.0028903827,-0.010633754,-0.0066157645,0.016971184,0.009534694,0.01875537,0.023694001,-0.006248222,0.0046745692,-0.010562385,0.02687699,-0.01621469,0.013616914,0.00092331663,0.03399946,-0.006762068,0.0066086277,0.019454774,0.03382818,-0.022994598,0.0018412807,0.013038837,-0.016757082,0.0035130638,-0.03905228,-0.010398241,-0.023065967,0.012161017,0.0065586707,-0.004795894,-0.058178764,-0.015529562,-0.0078076012,0.0026673593,-0.0028190152,0.0025478187,0.030402543,-0.011968325,-0.012874692,0.019911524,0.02696263,0.014872981,0.0012524991,0.021310328,0.015101356,-0.00055443606,0.017513577,-0.020525284,0.017171014,0.02393665,0.026020579,0.006448051,-0.011954051,0.03145878,0.0007850422,0.024721691,0.0050456803,0.01695691,-0.015472468,-0.025934938,0.003545179,0.00020696566,-0.0383957,0.027747672,0.013959478,0.043105952,0.025592376,-0.01818443,-0.003341782,-0.014730246,-0.0074436273,-0.013224392,0.0037789077,0.009313455,0.020796482,-0.007950337,-0.0045461077,0.017470757,0.022380838,0.0051241843,0.0000074643126,0.05338287,0.006879824,0.007614909,-0.015600929,-0.022694856,-0.008621191,0.00010426342,-0.014487596,0.0043998044,-0.022623489,0.01805597,-0.01004854,0.022109643,-0.003402444,0.0078076012,0.016485887,0.022766223,0.0014059392,-0.022395112,-0.0045996336,0.008028841,0.004378394,0.0056308936,-0.0024122205,-0.018512722,0.013659734,-0.002847562,0.00051919837,-0.020082807,0.030145619,-0.008278627,0.015329733,0.0055060005,0.014123622,0.002025052,-0.003591568,0.021096224,0.012646316,-0.00048039228,0.02185272,-0.03905228,-0.0026691435,0.04236373,0.023622632,0.00065479655,-0.046474498,0.035398267,-0.011654308,-0.005006428,0.0053454237,-0.0036932665,-0.0048101675,-0.0054203593,0.03328579,-0.026405964,-0.028475622,0.03916647,0.026234683,-0.00045808995,-0.031487327,-0.0130602475,0.010205548,0.038938094,0.051784236,0.000066182176,-0.0013898815,-0.028232971,0.0145304175,-0.030773653,-0.0071867043,0.016528707,-0.02696263,0.008699695,-0.006762068,-0.0067299525,-0.015372553,0.022594942,-0.018198704,-0.0047602104,-0.0031936944,0.00023060614,-0.03659724,0.0015674081,-0.008713968,0.021624343,0.013645461,-0.00015031773,-0.0011088721,0.0018787486,-0.0046174754,-0.008664011,-0.031230405,0.003372113,0.017870415,0.0035005745,0.024008017,-0.049900137,0.016414518,0.021410242,0.0019447636,0.006448051,-0.027233828,-0.015586656,0.019397678,0.00976307,-0.005655872,0.018826738,-0.0011124405,0.0036129782,0.03933775,-0.0012846144,-0.017870415,-0.0034880852,-0.010269779,-0.035483908,0.0042106807,-0.0050099962,0.001165966,-0.034541856,0.0050099962,-0.0009393743,-0.0019804472,-0.009534694,-0.006144739,-0.024950068,0.00739367,-0.04056527,0.005020702,-0.018312894,-0.025335452,-0.014023708,0.01976879,-0.022580668,-0.014701699,-0.048101675,0.023751095,0.025349725,0.017342295,-0.0016699989,0.0035772945,0.0018377124,0.006837004,-0.020268362,-0.048586976,-0.005388244,0.011946915,0.012796188,-0.00061376026,-0.0073044607,0.0018965906,-0.0158864,0.029517585,0.0078004645,0.0040358305,-0.006651448,-0.017713407,0.00085328735,0.020825028,0.012325162,0.030316902,0.005673714,-0.0018377124,-0.016371697,-0.012011145,0.00976307,-0.0075578154,-0.0004373488,-0.017213834,-0.0128818285,0.012310889,-0.012746231,-0.024479043,0.028475622,-0.0038716854,0.002856483,-0.01866973,0.034741685,0.004214249,0.012196701,0.02524981,-0.014744519,-0.011968325,-0.0003829311,-0.023536991,0.04182134,0.012689136,0.009184994,0.026248956,0.006294611,-0.0138096055,-0.031744253,0.008721105,-0.014573238,-0.011554394,-0.00054819137,-0.0308022,0.0046103387,-0.022195283,-0.0106623005,0.00050180254,-0.024450496,0.0028921668,0.0033007455,-0.020111354,-0.016114775,0.008649738,0.013823879,-0.02781904,-0.0071117687,0.028861005,0.02838998,0.020225542,0.020896396,0.012410803,-0.021924088,0.0074150804,-0.0011525847,-0.04824441,-0.006255359,0.028818185,0.007693413,0.021153318,0.027733399,0.0035005745,0.005752218,0.004556813,0.020225542,-0.027362289,0.010897812,-0.027676305,0.012653452,0.018926654,-0.0007890566,-0.009884395,0.009713112,0.0066550164,-0.002779763,0.04496151,-0.016271783,0.008692558,-0.015586656,-0.0152012715,-0.039937235,-0.0057700602,-0.011375975,0.0005687095,-0.052041158,-0.013502725,0.018127337,0.008942344,-0.0009393743,-0.01572939,0.014080802,-0.013431358,0.02226665,0.00072125753,0.010569522,-0.025235537,-0.009970035,-0.019982891,0.017385116,-0.0009429427,0.02340853,0.026719982,-0.011440205,0.010790762,0.0016111206,0.013666871,-0.020439643,0.00347738,-0.008414225,-0.025306905,-0.01033401,-0.02103913,0.0048387144,-0.014516144,-0.014687425,0.002378321,0.005206257,0.012981743,-0.019140756,-0.008064524,0.0033846023,-0.0058307224,0.026491605,0.021709984,0.029317757,0.024735965,0.009099352,0.003714677,0.0049814493,0.00026405964,0.0051884153,0.022980325,0.014023708,0.013645461,-0.022680582,-0.027148185,0.03231519,0.009991446,-0.018698277,0.014644605,-0.012931786,0.017856142,-0.018469902,0.0049814493,-0.043733988,0.019725969,-0.023536991,-0.014002298,-0.0076363194,-0.0150728095,-0.02283759,0.027761946,0.0067870463,0.023337163,0.008085934,-0.027105365,-0.0037682024,-0.013566956,-0.02226665,0.028047416,-0.009284908,0.0075149946,-0.005052817,0.015458195,0.02005426,-0.002255212,-0.011475889,0.014630332,0.020239815,0.03688271,-0.01834144,-0.0026548698,-0.013417085,-0.023208702,-0.004603202,-0.008571234,0.005059954,-0.0036326044,-0.008385678,-0.0026923378,0.026291776,-0.003163363,-0.0012471465,-0.014758793,-0.013638324,0.012353709,-0.015914947,0.018841011,0.025278358,-0.03671143,-0.031801347,-0.004153587,0.012039692,0.02957468,0.013331444,-0.0072937557,0.026149042,0.043077406,-0.008749652,0.009063669,-0.011425932,0.0003831541,-0.044390567,-0.013831016,0.0031455213,-0.015629476,-0.0022373702,-0.03242938,-0.02246648,-0.0059770257,0.015786484,0.007900379,-0.0064123673,0.003468459,0.024978615,0.039137922,0.008421361,0.003143737,-0.012203838,-0.015186998,-0.007097495,-0.0037931812,0.022737676,0.005031407,-0.024393402,-0.010376831,0.019340584,0.008192985,-0.037025444,-0.020525284,0.0008167115,0.007643456,0.0022837592,-0.02524981,-0.029546132,-0.008285764,-0.016271783,0.03611194,0.031801347,-0.011568667,-0.008942344,0.011640035,0.021767078,0.013260076,-0.0022391544,-0.02582075,-0.016014861,-0.016685715,-0.027747672,-0.0052704876,0.0016360993,0.03488442,0.021809898,-0.012967469,-0.012931786,-0.012888965,-0.036768522,-0.013124478,-0.028090237,0.036054846,0.04815877,-0.018741097,-0.0076648663,0.012510718,-0.007211683,0.017199561,-0.012389393,-0.0069975806,0.0021071245,-0.020725114,0.020325456,-0.010883539,-0.010177001,-0.009591788,0.009613198,0.007172431,-0.0006503361,-0.0035541002,-0.012746231,-0.004528266,-0.0024479043,-0.009284908,0.012896102,0.009277771,0.0028707564,-0.012175291,-0.0015335085,0.020939216,0.003775339,0.0057736286,-0.024008017,0.017470757,0.00058610534,0.007365123,-0.017670587,0.003811023,0.018441355,0.0031936944,0.022766223,-0.017014004,0.021210412,0.018284347,-0.011996872,-0.0034131494,-0.032486472,0.016971184,-0.032001175,0.0010259073,0.008706831,-0.021638617,-0.008756788,0.009891531,0.017941782,-0.02753357,-0.012781914,-0.004813736,0.014009435,-0.0379104,0.0045354026,0.008057388,0.00042062203,-0.02871827,-0.027390836,-0.011525847,0.020582378,-0.027233828,-0.026206136,-0.035626642,0.0037931812,-0.011119052,-0.021395968,-0.019911524,0.020011438,0.028347159,-0.0043926677,0.01932631,0.206566,0.00502427,0.01829862,-0.0006431993,-0.007090358,-0.005930637,0.018412808,0.0015236955,-0.013131615,0.0055630943,-0.023636905,0.016371697,0.0047602104,0.0016307468,0.021238958,0.00047593183,-0.02446477,-0.0074650375,-0.028775364,-0.034656044,0.025535282,0.012353709,-0.0012159233,-0.009912942,0.022823317,-0.02564947,-0.010412514,-0.0026388122,0.018241525,0.0095275575,-0.025563829,0.0028011731,-0.0010491018,-0.018783918,0.011354565,-0.022509301,0.005837859,0.009177857,0.027276648,-0.008207259,-0.00040590248,-0.011297471,-0.020396823,-0.019312037,-0.013295759,-0.0072295247,0.0050777956,-0.023108788,0.009977172,0.02209537,-0.017185288,0.023950923,0.06434491,0.03733946,0.0075863623,-0.013566956,0.006612196,-0.007950337,0.012296615,0.036169033,-0.032543566,0.029660322,-0.004949334,0.03848134,0.011847001,0.014972895,0.0052704876,-0.017984603,0.0007047538,-0.0026620068,0.016671441,0.015957767,0.013338581,0.0075792256,-0.02814733,-0.021824172,0.045475353,-0.0037682024,0.023037419,0.02871827,0.004260638,0.002408652,0.0005575584,-0.009677429,-0.0049029454,-0.028161604,0.00006484404,0.0039965785,-0.008728242,-0.017270928,-0.013252939,0.0007239338,-0.0007672003,-0.003161579,0.006990444,0.017270928,0.008564097,0.01360264,-0.023294343,-0.011861274,-0.025892118,0.052840475,-0.009570378,0.0068619824,0.0029831603,-0.01478734,-0.0189552,0.01654298,0.013688281,-0.010491018,0.0049350606,-0.03357126,0.0041321767,-0.00062268117,-0.009399096,0.0014469755,-0.00016994379,-0.0146089215,-0.017513577,-0.020639472,0.027219553,-0.02099631,-0.020311182,0.004960039,0.010812172,-0.010583796,-0.03705399,-0.008970891,0.008492729,0.005295466,0.017898962,-0.0022213126,-0.0070653795,-0.031829894,-0.0086782845,-0.0020339729,0.0132172555,0.008571234,-0.014872981,0.0116685815,0.005159868,0.01829862,-0.011632898,0.023879556,0.016971184,-0.018598363,-0.0011766711,0.014409092,-0.021067677,-0.021453062,-0.04701689,-0.020924943,-0.0015504583,-0.027148185,-0.0069404864,0.016685715,-0.009698839,-0.013723965,-0.00888525,0.0036468778,-0.049843043,0.0019911525,0.003657583,0.023222975,-0.021624343,-0.022766223,-0.18441355,0.015600929,0.012532128,-0.020196995,0.013252939,0.016443064,-0.000821618,0.0016958695,-0.002494293,-0.002158866,0.010826445,0.015629476,-0.026734255,-0.002876109,-0.009670292,0.006084077,0.0003954204,0.017385116,0.013381401,0.013260076,0.023337163,-0.03713963,0.005109911,0.012189564,-0.0026620068,0.011218966,-0.013745375,0.0063302945,0.001089246,-0.027248101,-0.0042499327,0.013359991,0.013873836,-0.008892387,0.01564375,-0.009363412,0.016771356,-0.006355273,-0.002637028,0.0317728,0.037767667,0.020553831,0.01801315,-0.015957767,-0.011982598,0.0069654654,-0.0006695161,0.0051063425,-0.0006962789,-0.025378272,0.014351998,-0.0063409996,-0.028418526,-0.008728242,0.027305195,-0.009320592,0.0053739706,0.020325456,0.0011918368,0.0027583528,0.034456216,-0.02957468,0.008185849,0.0038324331,0.007614909,-0.012275205,-0.014758793,0.009834438,-0.0068940977,0.0023069535,-0.008721105,-0.009342002,0.012510718,-0.011832727,0.017128194,-0.005837859,-0.0469027,0.038338605,-0.0040643774,0.0038003179,0.009798754,0.037567835,-0.022209557,-0.0010044972,-0.011918368,0.013831016,0.005481022,0.008742515,0.0038467066,-0.0034131494,0.028975192,0.0048030308,-0.032258097,-0.007029696,0.025549555,0.008014567,0.012967469,0.025292631,-0.02691981,-0.005795039,0.015829304,-0.00114634,-0.018212978,0.010540975,0.015129904,0.019055115,-0.027547844,0.008071661,0.03185844,-0.026819896,-0.03594066,0.019254943,0.021510156,0.027019724,-0.023251522,0.036768522,-0.0061483076,-0.01638597,0.0046353173,0.008428498,0.015087083,0.0126748625,-0.01866973,0.019055115,0.0044676038,-0.013088794,-0.09043686,-0.02994579,-0.0045354026,-0.012032555,0.0041286084,-0.0057629235,0.007650593,0.031116217,-0.008457045,0.009977172,0.010191275,-0.015429648,0.0012792619,0.015458195,0.013538409,-0.042106807,-0.0022480753,-0.0011927289,-0.030573824,0.018969474,0.010284052,-0.009934352,-0.009770207,0.004182134,0.007928926,0.03459895,0.001882317,0.0017939998,0.020282635,-0.018227251,0.011069095,0.008763925,0.027704852,-0.035683736,-0.021353148,0.0070082857,-0.036054846,-0.011590078,0.018041696,-0.032572113,-0.011725675,0.006048393,0.009705976,0.0031098376,-0.022866137,0.007622046,-0.030059978,0.0158864,-0.0037574973,-0.0030919956,-0.035426814,-0.001556703,-0.020296909,0.01568657,0.021909814,0.019611781,0.0060162777,-0.0099414885,-0.011033411,0.008478455,-0.011440205,-0.010598069,-0.011868411,0.011261787,0.0024389834,0.032029722,-0.027761946,-0.03374254,-0.002483588,0.0026620068,-0.0038930955,0.029803056,-0.019354858,0.030373996,-0.008585507,-0.019369131,0.002426494,-0.0036201149,0.0037289504,0.0038859588,-0.010298326,-0.008399951,0.009834438,-0.01568657,0.019212123,-0.01866973,0.018427081,-0.006858414,0.009677429,-0.033799633,-0.0069690337,0.0105338385,-0.0006271417,-0.034570403,-0.0019162166,0.00074846635,-0.004621044,-0.003143737,0.005213394,-0.008300037,-0.03773912,0.007836148,-0.05175569,0.0058235857,-0.017028278,-0.029431945,0.009548968,-0.018741097,0.011276061,-0.00046968716,0.00009143957,-0.014630332,-0.023594085,0.008449908,-0.0018680436,-0.009648882,-0.029103655,-0.01809879,-0.0006159905,-0.0061982647,0.005366834,-0.0024907247,0.0003831541,-0.022523575,0.024250668,-0.005491727,-0.022523575,0.022537848,-0.030373996,0.029117929,-0.017385116,-0.049985778,0.014366272,-0.010940634,-0.027918955,0.019540414,-0.0051455945,-0.0011802396,0.027790492,0.017813321,-0.002132103,0.036996897,-0.020225542,-0.034570403,-0.023465624,-0.0074721742,0.0050670905,-0.003621899,-0.029489039,0.012996016,0.006590786,0.0063374313,0.016428791,0.008928071,-0.031572968,-0.027033998,0.01739939,-0.009342002,-0.0034791643,0.003047391,-0.0027851155,0.008399951,0.031572968,-0.014687425,0.022637762,-0.012924649,0.018883834,-0.0007056459,-0.028561262,-0.018127337,-0.0054596113,-0.0013907736,-0.019069389,-0.009848711,0.013759648,0.022780497,0.015458195,-0.0019840158,-0.0024586094,0.013317171,-0.013145888,0.021952635,0.003382818,0.008992301,-0.021824172,0.0005878895,0.034199294,0.006019846,-0.022566395,-0.024207845,0.0037396555,-0.00068825006,-0.0048387144,-0.007479311,-0.017242381,0.022994598,0.019454774,0.008763925,-0.000257815,-0.002426494,0.011654308,0.028618356,0.009356275,0.0031758524,-0.0014077234,-0.016757082,-0.0032650619,-0.0006521203,-0.014687425,0.0019501161,0.0067692045,0.0046353173,-0.004988586,-0.009463327,0.0013488452,0.02033973,-0.027861862,0.009277771,-0.009420506,-0.019925797,-0.023565538,0.019069389,0.0144019555,0.0041964073,0.043733988,0.008207259,0.014987169,0.0013773922,0.028746817,-0.014416229,0.021210412,-0.014294905,0.019354858,0.01875537,-0.015786484,-0.024379129,-0.012874692,-0.00561662,-0.028918099,0.0021535135,-0.031744253,0.06171859,0.038509887,-0.020211268,0.005338287,0.0023836736,-0.0064159357,0.0090137115,0.0036718564,-0.0121324705,-0.04824441,0.033257242,-0.023922376,0.020882122,-0.032943226,-0.011347428,0.017741954,-0.02209537,0.023123061,-0.008628327,-0.0059627523,0.020753661,0.0029617501,0.0049921544,0.0074864477,-0.035598096,-0.01478734,0.034199294,-0.0038859588,-0.022780497,-0.017228108,0.010184138,0.015472468,-0.014844434,-0.020782208,-0.008756788,-0.028332885,-0.020225542,-0.0026620068,0.030145619,0.0013051326,0.005448906,0.017470757,-0.038538434,-0.037567835,-0.0028814618,-0.014844434,-0.0124179395,0.0013354638,-0.015044263]]} \ No newline at end of file diff --git a/scripts/execute_code.py b/scripts/execute_code.py index 5d4f7236a9..3aa50bc894 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -3,15 +3,17 @@ import os import subprocess -def execute_python_file(file): - workspace_folder = "auto_gpt_workspace" +WORKSPACE_FOLDER = "auto_gpt_workspace" - print (f"Executing file '{file}' in workspace '{workspace_folder}'") + +def execute_python_file(file): + + print (f"Executing file '{file}' in workspace '{WORKSPACE_FOLDER}'") if not file.endswith(".py"): return "Error: Invalid file type. Only .py files are allowed." - file_path = os.path.join(workspace_folder, file) + file_path = os.path.join(WORKSPACE_FOLDER, file) if not os.path.isfile(file_path): return f"Error: File '{file}' does not exist." @@ -26,7 +28,7 @@ def execute_python_file(file): 'python:3.10', f'python {file}', volumes={ - os.path.abspath(workspace_folder): { + os.path.abspath(WORKSPACE_FOLDER): { 'bind': '/workspace', 'mode': 'ro'}}, working_dir='/workspace', @@ -51,12 +53,18 @@ def execute_python_file(file): def exec_shell(command_line): + print (f"Executing command '{command_line}' in workspace '{WORKSPACE_FOLDER}'") + args = command_line.split() + base_path = os.getcwd() + + os.chdir(f"{base_path}/{WORKSPACE_FOLDER}") result = subprocess.run(args, capture_output=True) - output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"; + os.chdir(base_path) + # print(f"Shell execution complete. Output: {output}") return output From 09d2f47e084a96487023eaacfa139a4688608bdb Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Mon, 10 Apr 2023 11:01:48 +0700 Subject: [PATCH 05/64] Introduce EXECUTE_SHELL_COMMANDS config var, default to False --- .env.template | 1 + auto-gpt.json | 1 - scripts/commands.py | 7 +++++-- scripts/config.py | 2 ++ 4 files changed, 8 insertions(+), 3 deletions(-) delete mode 100644 auto-gpt.json diff --git a/.env.template b/.env.template index 525cd61c5f..aa221dfa76 100644 --- a/.env.template +++ b/.env.template @@ -7,6 +7,7 @@ FAST_LLM_MODEL="gpt-3.5-turbo" GOOGLE_API_KEY= CUSTOM_SEARCH_ENGINE_ID= USE_AZURE=False +EXECUTE_LOCAL_COMMANDS=False OPENAI_API_BASE=your-base-url-for-azure OPENAI_API_VERSION=api-version-for-azure OPENAI_DEPLOYMENT_ID=deployment-id-for-azure diff --git a/auto-gpt.json b/auto-gpt.json deleted file mode 100644 index f575113dbf..0000000000 --- a/auto-gpt.json +++ /dev/null @@ -1 +0,0 @@ -{"texts":["Assistant Reply: {\n \"thoughts\": {\n \"text\": \"I think the best next step would be to execute a shell command to print the contents of the present working directory.\",\n \"reasoning\": \"Since the user asked us to run the command \\\"pwd\\\" on the shell, the \\\"exec_shell\\\" command would be appropriate for this purpose.\",\n \"plan\": \"- Run the \\\"exec_shell\\\" command to execute the shell command \\\"pwd\\\"\",\n \"criticism\": \"I think this plan is effective and efficient.\",\n \"speak\": \"I will execute shell command 'pwd' to print the present working directory.\"\n },\n \"command\": {\n \"name\": \"exec_shell\",\n \"args\": {\n \"command_line\": \"pwd\"\n }\n }\n} \nResult: Command exec_shell returned: STDOUT:\nb'/Users/bernhardmueller/Projects/Auto-GPT/auto_gpt_workspace\\n'\nSTDERR:\nb'' \nHuman Feedback: GENERATE NEXT COMMAND JSON "],"embeddings":[[-0.018769644,0.0182558,0.0018234389,0.0018377124,-0.012867555,0.02128178,-0.0038145913,-0.036654335,-0.02463605,-0.03100203,0.032629207,0.015087083,-0.024693144,-0.012196701,-0.0068155937,0.00007237108,0.020482464,-0.015872126,-0.00052009046,-0.002121398,0.018355714,-0.002290896,0.014123622,-0.008492729,0.004988586,-0.018427081,0.013260076,-0.009584651,-0.004642454,-0.008521276,0.003152658,0.0013559819,0.01390952,-0.01592922,-0.007051106,-0.012096786,-0.015358279,-0.028575536,0.014059392,0.011375975,0.0021035562,0.004517561,0.0070368326,-0.03222955,-0.03671143,0.01035542,0.013930931,-0.0445333,0.0054881587,0.013252939,0.0134741785,0.025235537,-0.027076818,0.02577793,0.019925797,0.006469461,-0.008571234,0.029317757,-0.008200122,-0.012639179,0.010191275,-0.016371697,-0.018327167,0.04145023,0.021338874,-0.009506147,-0.0073223026,0.0038003179,-0.010041404,-0.0017824026,0.020082807,0.015543835,0.0004728095,0.008813882,0.03628322,0.007836148,-0.021253234,0.014209263,0.0036272516,0.011047685,0.008164438,-0.008870977,0.0036343886,0.02871827,0.01748503,-0.012917512,0.00088852504,0.039280657,-0.026120495,-0.026063401,-0.01809879,0.008392815,0.000052048075,0.011925505,0.004949334,0.022937505,0.0021749237,0.0030723696,-0.0070082857,-0.03525553,-0.0031187586,0.019654602,-0.027305195,-0.009391959,-0.02858981,0.003372113,-0.008357131,-0.007268777,0.0397945,0.00006802212,-0.023608359,0.02328007,-0.020411097,-0.017870415,0.002301601,-0.025149897,0.019511867,-0.019925797,-0.03933775,-0.0032365147,0.027847588,0.012703409,0.04558954,-0.016200416,0.020924943,0.0027530002,-0.025363998,-0.030887842,0.010119908,0.0064123673,0.020596651,0.017270928,-0.005206257,0.0017226323,-0.016856996,0.026291776,-0.014266358,0.016671441,-0.0029278505,-0.02288041,0.047359455,0.031744253,-0.0039537577,0.014644605,-0.014730246,0.03865262,0.029075108,0.0056380304,-0.0044140783,-0.0065158503,0.010954907,-0.00029662106,0.023993744,0.002637028,0.004956471,0.018526996,0.019454774,0.012282342,-0.00087826594,-0.014173579,-0.0017021142,0.020496737,0.023722548,-0.0007266101,0.014844434,0.03163006,0.03399946,0.023622632,0.013509862,-0.01809879,-0.027562117,0.017913235,-0.04047963,0.020354003,0.014230674,0.018155884,0.0078076012,0.009798754,-0.007479311,0.001231981,0.00035036966,0.018783918,-0.006216107,0.031515874,0.0057807653,-0.035398267,0.0021552977,-0.013281486,0.014758793,0.00008447009,0.009342002,0.038338605,-0.0058414275,-0.010284052,-0.61296093,-0.02582075,-0.021438789,-0.023594085,0.020639472,0.014544691,-0.024008017,0.014159306,-0.021481609,0.037025444,-0.0099414885,0.0078076012,0.009855848,-0.02340853,0.008000294,-0.015272639,-0.01691409,-0.0070439694,-0.010305462,0.018212978,-0.018969474,0.0037503606,-0.024793059,-0.005013565,-0.012632042,-0.012232385,0.007936063,-0.0070867897,-0.005159868,0.042535014,-0.02994579,0.0071367472,-0.0045068557,-0.013095931,0.06748508,0.0099414885,-0.029603226,-0.0046959794,-0.0182558,0.03205827,-0.03194408,-0.023694001,-0.0022338019,-0.0055845045,-0.0031490896,0.0055452525,0.011397385,-0.010255505,-0.0010749726,-0.006419504,0.02838998,-0.0019554687,-0.0018171943,-0.008507002,0.022723403,0.01390952,0.042420823,-0.013773922,-0.005224099,-0.005131321,0.025920665,0.039651766,-0.01797033,-0.0052490775,-0.037967496,0.03574083,-0.008300037,-0.0021196138,-0.018227251,-0.052383725,0.011932641,0.010683711,-0.026891263,-0.018398535,-0.0034666748,0.003764634,0.016414518,-0.006448051,-0.0074364906,0.040907834,0.02108195,-0.018655457,-0.0066336063,0.0002598222,0.023694001,0.0017154956,-0.012553538,-0.019269217,-0.0064944397,0.0000132977675,0.0075221313,-0.005734376,-0.00086131616,-0.00853555,0.028775364,0.018841011,0.006694269,-0.03514134,-0.005327582,-0.021267507,-0.01682845,0.0035326898,-0.0050456803,0.03222955,0.009234951,0.005766492,-0.027747672,0.022966051,0.0030313334,-0.014394819,-0.007275914,0.009213541,-0.0047887573,-0.0015049615,-0.000793071,-0.03762493,0.03194408,0.004142882,0.015172725,-0.028618356,0.012032555,-0.008407088,-0.009135037,-0.010648027,0.03382818,0.011218966,0.020368276,-0.037967496,0.008050251,0.024735965,-0.03636886,-0.019611781,0.026805623,0.0056594405,0.0057486496,0.007172431,0.02385101,-0.024992889,0.019982891,-0.020154174,-0.03399946,0.006112624,-0.0027726262,-0.021510156,0.00068512774,-0.03479878,-0.011347428,-0.0015085299,-0.017941782,-0.0011258218,-0.0023711843,-0.0030241965,0.0015290481,0.050670903,0.01818443,-0.02867545,0.0017315532,-0.031059124,0.030630918,-0.014758793,0.012667726,0.021296054,-0.007365123,-0.0009937921,-0.013153025,-0.0005780765,-0.011090505,0.014152169,0.0060662352,-0.03648305,0.012453624,0.0057593547,0.021809898,-0.0055238423,-0.004899377,0.008178712,-0.032714847,-0.014216401,-0.013716828,0.0020072102,0.002579934,0.0028903827,-0.010633754,-0.0066157645,0.016971184,0.009534694,0.01875537,0.023694001,-0.006248222,0.0046745692,-0.010562385,0.02687699,-0.01621469,0.013616914,0.00092331663,0.03399946,-0.006762068,0.0066086277,0.019454774,0.03382818,-0.022994598,0.0018412807,0.013038837,-0.016757082,0.0035130638,-0.03905228,-0.010398241,-0.023065967,0.012161017,0.0065586707,-0.004795894,-0.058178764,-0.015529562,-0.0078076012,0.0026673593,-0.0028190152,0.0025478187,0.030402543,-0.011968325,-0.012874692,0.019911524,0.02696263,0.014872981,0.0012524991,0.021310328,0.015101356,-0.00055443606,0.017513577,-0.020525284,0.017171014,0.02393665,0.026020579,0.006448051,-0.011954051,0.03145878,0.0007850422,0.024721691,0.0050456803,0.01695691,-0.015472468,-0.025934938,0.003545179,0.00020696566,-0.0383957,0.027747672,0.013959478,0.043105952,0.025592376,-0.01818443,-0.003341782,-0.014730246,-0.0074436273,-0.013224392,0.0037789077,0.009313455,0.020796482,-0.007950337,-0.0045461077,0.017470757,0.022380838,0.0051241843,0.0000074643126,0.05338287,0.006879824,0.007614909,-0.015600929,-0.022694856,-0.008621191,0.00010426342,-0.014487596,0.0043998044,-0.022623489,0.01805597,-0.01004854,0.022109643,-0.003402444,0.0078076012,0.016485887,0.022766223,0.0014059392,-0.022395112,-0.0045996336,0.008028841,0.004378394,0.0056308936,-0.0024122205,-0.018512722,0.013659734,-0.002847562,0.00051919837,-0.020082807,0.030145619,-0.008278627,0.015329733,0.0055060005,0.014123622,0.002025052,-0.003591568,0.021096224,0.012646316,-0.00048039228,0.02185272,-0.03905228,-0.0026691435,0.04236373,0.023622632,0.00065479655,-0.046474498,0.035398267,-0.011654308,-0.005006428,0.0053454237,-0.0036932665,-0.0048101675,-0.0054203593,0.03328579,-0.026405964,-0.028475622,0.03916647,0.026234683,-0.00045808995,-0.031487327,-0.0130602475,0.010205548,0.038938094,0.051784236,0.000066182176,-0.0013898815,-0.028232971,0.0145304175,-0.030773653,-0.0071867043,0.016528707,-0.02696263,0.008699695,-0.006762068,-0.0067299525,-0.015372553,0.022594942,-0.018198704,-0.0047602104,-0.0031936944,0.00023060614,-0.03659724,0.0015674081,-0.008713968,0.021624343,0.013645461,-0.00015031773,-0.0011088721,0.0018787486,-0.0046174754,-0.008664011,-0.031230405,0.003372113,0.017870415,0.0035005745,0.024008017,-0.049900137,0.016414518,0.021410242,0.0019447636,0.006448051,-0.027233828,-0.015586656,0.019397678,0.00976307,-0.005655872,0.018826738,-0.0011124405,0.0036129782,0.03933775,-0.0012846144,-0.017870415,-0.0034880852,-0.010269779,-0.035483908,0.0042106807,-0.0050099962,0.001165966,-0.034541856,0.0050099962,-0.0009393743,-0.0019804472,-0.009534694,-0.006144739,-0.024950068,0.00739367,-0.04056527,0.005020702,-0.018312894,-0.025335452,-0.014023708,0.01976879,-0.022580668,-0.014701699,-0.048101675,0.023751095,0.025349725,0.017342295,-0.0016699989,0.0035772945,0.0018377124,0.006837004,-0.020268362,-0.048586976,-0.005388244,0.011946915,0.012796188,-0.00061376026,-0.0073044607,0.0018965906,-0.0158864,0.029517585,0.0078004645,0.0040358305,-0.006651448,-0.017713407,0.00085328735,0.020825028,0.012325162,0.030316902,0.005673714,-0.0018377124,-0.016371697,-0.012011145,0.00976307,-0.0075578154,-0.0004373488,-0.017213834,-0.0128818285,0.012310889,-0.012746231,-0.024479043,0.028475622,-0.0038716854,0.002856483,-0.01866973,0.034741685,0.004214249,0.012196701,0.02524981,-0.014744519,-0.011968325,-0.0003829311,-0.023536991,0.04182134,0.012689136,0.009184994,0.026248956,0.006294611,-0.0138096055,-0.031744253,0.008721105,-0.014573238,-0.011554394,-0.00054819137,-0.0308022,0.0046103387,-0.022195283,-0.0106623005,0.00050180254,-0.024450496,0.0028921668,0.0033007455,-0.020111354,-0.016114775,0.008649738,0.013823879,-0.02781904,-0.0071117687,0.028861005,0.02838998,0.020225542,0.020896396,0.012410803,-0.021924088,0.0074150804,-0.0011525847,-0.04824441,-0.006255359,0.028818185,0.007693413,0.021153318,0.027733399,0.0035005745,0.005752218,0.004556813,0.020225542,-0.027362289,0.010897812,-0.027676305,0.012653452,0.018926654,-0.0007890566,-0.009884395,0.009713112,0.0066550164,-0.002779763,0.04496151,-0.016271783,0.008692558,-0.015586656,-0.0152012715,-0.039937235,-0.0057700602,-0.011375975,0.0005687095,-0.052041158,-0.013502725,0.018127337,0.008942344,-0.0009393743,-0.01572939,0.014080802,-0.013431358,0.02226665,0.00072125753,0.010569522,-0.025235537,-0.009970035,-0.019982891,0.017385116,-0.0009429427,0.02340853,0.026719982,-0.011440205,0.010790762,0.0016111206,0.013666871,-0.020439643,0.00347738,-0.008414225,-0.025306905,-0.01033401,-0.02103913,0.0048387144,-0.014516144,-0.014687425,0.002378321,0.005206257,0.012981743,-0.019140756,-0.008064524,0.0033846023,-0.0058307224,0.026491605,0.021709984,0.029317757,0.024735965,0.009099352,0.003714677,0.0049814493,0.00026405964,0.0051884153,0.022980325,0.014023708,0.013645461,-0.022680582,-0.027148185,0.03231519,0.009991446,-0.018698277,0.014644605,-0.012931786,0.017856142,-0.018469902,0.0049814493,-0.043733988,0.019725969,-0.023536991,-0.014002298,-0.0076363194,-0.0150728095,-0.02283759,0.027761946,0.0067870463,0.023337163,0.008085934,-0.027105365,-0.0037682024,-0.013566956,-0.02226665,0.028047416,-0.009284908,0.0075149946,-0.005052817,0.015458195,0.02005426,-0.002255212,-0.011475889,0.014630332,0.020239815,0.03688271,-0.01834144,-0.0026548698,-0.013417085,-0.023208702,-0.004603202,-0.008571234,0.005059954,-0.0036326044,-0.008385678,-0.0026923378,0.026291776,-0.003163363,-0.0012471465,-0.014758793,-0.013638324,0.012353709,-0.015914947,0.018841011,0.025278358,-0.03671143,-0.031801347,-0.004153587,0.012039692,0.02957468,0.013331444,-0.0072937557,0.026149042,0.043077406,-0.008749652,0.009063669,-0.011425932,0.0003831541,-0.044390567,-0.013831016,0.0031455213,-0.015629476,-0.0022373702,-0.03242938,-0.02246648,-0.0059770257,0.015786484,0.007900379,-0.0064123673,0.003468459,0.024978615,0.039137922,0.008421361,0.003143737,-0.012203838,-0.015186998,-0.007097495,-0.0037931812,0.022737676,0.005031407,-0.024393402,-0.010376831,0.019340584,0.008192985,-0.037025444,-0.020525284,0.0008167115,0.007643456,0.0022837592,-0.02524981,-0.029546132,-0.008285764,-0.016271783,0.03611194,0.031801347,-0.011568667,-0.008942344,0.011640035,0.021767078,0.013260076,-0.0022391544,-0.02582075,-0.016014861,-0.016685715,-0.027747672,-0.0052704876,0.0016360993,0.03488442,0.021809898,-0.012967469,-0.012931786,-0.012888965,-0.036768522,-0.013124478,-0.028090237,0.036054846,0.04815877,-0.018741097,-0.0076648663,0.012510718,-0.007211683,0.017199561,-0.012389393,-0.0069975806,0.0021071245,-0.020725114,0.020325456,-0.010883539,-0.010177001,-0.009591788,0.009613198,0.007172431,-0.0006503361,-0.0035541002,-0.012746231,-0.004528266,-0.0024479043,-0.009284908,0.012896102,0.009277771,0.0028707564,-0.012175291,-0.0015335085,0.020939216,0.003775339,0.0057736286,-0.024008017,0.017470757,0.00058610534,0.007365123,-0.017670587,0.003811023,0.018441355,0.0031936944,0.022766223,-0.017014004,0.021210412,0.018284347,-0.011996872,-0.0034131494,-0.032486472,0.016971184,-0.032001175,0.0010259073,0.008706831,-0.021638617,-0.008756788,0.009891531,0.017941782,-0.02753357,-0.012781914,-0.004813736,0.014009435,-0.0379104,0.0045354026,0.008057388,0.00042062203,-0.02871827,-0.027390836,-0.011525847,0.020582378,-0.027233828,-0.026206136,-0.035626642,0.0037931812,-0.011119052,-0.021395968,-0.019911524,0.020011438,0.028347159,-0.0043926677,0.01932631,0.206566,0.00502427,0.01829862,-0.0006431993,-0.007090358,-0.005930637,0.018412808,0.0015236955,-0.013131615,0.0055630943,-0.023636905,0.016371697,0.0047602104,0.0016307468,0.021238958,0.00047593183,-0.02446477,-0.0074650375,-0.028775364,-0.034656044,0.025535282,0.012353709,-0.0012159233,-0.009912942,0.022823317,-0.02564947,-0.010412514,-0.0026388122,0.018241525,0.0095275575,-0.025563829,0.0028011731,-0.0010491018,-0.018783918,0.011354565,-0.022509301,0.005837859,0.009177857,0.027276648,-0.008207259,-0.00040590248,-0.011297471,-0.020396823,-0.019312037,-0.013295759,-0.0072295247,0.0050777956,-0.023108788,0.009977172,0.02209537,-0.017185288,0.023950923,0.06434491,0.03733946,0.0075863623,-0.013566956,0.006612196,-0.007950337,0.012296615,0.036169033,-0.032543566,0.029660322,-0.004949334,0.03848134,0.011847001,0.014972895,0.0052704876,-0.017984603,0.0007047538,-0.0026620068,0.016671441,0.015957767,0.013338581,0.0075792256,-0.02814733,-0.021824172,0.045475353,-0.0037682024,0.023037419,0.02871827,0.004260638,0.002408652,0.0005575584,-0.009677429,-0.0049029454,-0.028161604,0.00006484404,0.0039965785,-0.008728242,-0.017270928,-0.013252939,0.0007239338,-0.0007672003,-0.003161579,0.006990444,0.017270928,0.008564097,0.01360264,-0.023294343,-0.011861274,-0.025892118,0.052840475,-0.009570378,0.0068619824,0.0029831603,-0.01478734,-0.0189552,0.01654298,0.013688281,-0.010491018,0.0049350606,-0.03357126,0.0041321767,-0.00062268117,-0.009399096,0.0014469755,-0.00016994379,-0.0146089215,-0.017513577,-0.020639472,0.027219553,-0.02099631,-0.020311182,0.004960039,0.010812172,-0.010583796,-0.03705399,-0.008970891,0.008492729,0.005295466,0.017898962,-0.0022213126,-0.0070653795,-0.031829894,-0.0086782845,-0.0020339729,0.0132172555,0.008571234,-0.014872981,0.0116685815,0.005159868,0.01829862,-0.011632898,0.023879556,0.016971184,-0.018598363,-0.0011766711,0.014409092,-0.021067677,-0.021453062,-0.04701689,-0.020924943,-0.0015504583,-0.027148185,-0.0069404864,0.016685715,-0.009698839,-0.013723965,-0.00888525,0.0036468778,-0.049843043,0.0019911525,0.003657583,0.023222975,-0.021624343,-0.022766223,-0.18441355,0.015600929,0.012532128,-0.020196995,0.013252939,0.016443064,-0.000821618,0.0016958695,-0.002494293,-0.002158866,0.010826445,0.015629476,-0.026734255,-0.002876109,-0.009670292,0.006084077,0.0003954204,0.017385116,0.013381401,0.013260076,0.023337163,-0.03713963,0.005109911,0.012189564,-0.0026620068,0.011218966,-0.013745375,0.0063302945,0.001089246,-0.027248101,-0.0042499327,0.013359991,0.013873836,-0.008892387,0.01564375,-0.009363412,0.016771356,-0.006355273,-0.002637028,0.0317728,0.037767667,0.020553831,0.01801315,-0.015957767,-0.011982598,0.0069654654,-0.0006695161,0.0051063425,-0.0006962789,-0.025378272,0.014351998,-0.0063409996,-0.028418526,-0.008728242,0.027305195,-0.009320592,0.0053739706,0.020325456,0.0011918368,0.0027583528,0.034456216,-0.02957468,0.008185849,0.0038324331,0.007614909,-0.012275205,-0.014758793,0.009834438,-0.0068940977,0.0023069535,-0.008721105,-0.009342002,0.012510718,-0.011832727,0.017128194,-0.005837859,-0.0469027,0.038338605,-0.0040643774,0.0038003179,0.009798754,0.037567835,-0.022209557,-0.0010044972,-0.011918368,0.013831016,0.005481022,0.008742515,0.0038467066,-0.0034131494,0.028975192,0.0048030308,-0.032258097,-0.007029696,0.025549555,0.008014567,0.012967469,0.025292631,-0.02691981,-0.005795039,0.015829304,-0.00114634,-0.018212978,0.010540975,0.015129904,0.019055115,-0.027547844,0.008071661,0.03185844,-0.026819896,-0.03594066,0.019254943,0.021510156,0.027019724,-0.023251522,0.036768522,-0.0061483076,-0.01638597,0.0046353173,0.008428498,0.015087083,0.0126748625,-0.01866973,0.019055115,0.0044676038,-0.013088794,-0.09043686,-0.02994579,-0.0045354026,-0.012032555,0.0041286084,-0.0057629235,0.007650593,0.031116217,-0.008457045,0.009977172,0.010191275,-0.015429648,0.0012792619,0.015458195,0.013538409,-0.042106807,-0.0022480753,-0.0011927289,-0.030573824,0.018969474,0.010284052,-0.009934352,-0.009770207,0.004182134,0.007928926,0.03459895,0.001882317,0.0017939998,0.020282635,-0.018227251,0.011069095,0.008763925,0.027704852,-0.035683736,-0.021353148,0.0070082857,-0.036054846,-0.011590078,0.018041696,-0.032572113,-0.011725675,0.006048393,0.009705976,0.0031098376,-0.022866137,0.007622046,-0.030059978,0.0158864,-0.0037574973,-0.0030919956,-0.035426814,-0.001556703,-0.020296909,0.01568657,0.021909814,0.019611781,0.0060162777,-0.0099414885,-0.011033411,0.008478455,-0.011440205,-0.010598069,-0.011868411,0.011261787,0.0024389834,0.032029722,-0.027761946,-0.03374254,-0.002483588,0.0026620068,-0.0038930955,0.029803056,-0.019354858,0.030373996,-0.008585507,-0.019369131,0.002426494,-0.0036201149,0.0037289504,0.0038859588,-0.010298326,-0.008399951,0.009834438,-0.01568657,0.019212123,-0.01866973,0.018427081,-0.006858414,0.009677429,-0.033799633,-0.0069690337,0.0105338385,-0.0006271417,-0.034570403,-0.0019162166,0.00074846635,-0.004621044,-0.003143737,0.005213394,-0.008300037,-0.03773912,0.007836148,-0.05175569,0.0058235857,-0.017028278,-0.029431945,0.009548968,-0.018741097,0.011276061,-0.00046968716,0.00009143957,-0.014630332,-0.023594085,0.008449908,-0.0018680436,-0.009648882,-0.029103655,-0.01809879,-0.0006159905,-0.0061982647,0.005366834,-0.0024907247,0.0003831541,-0.022523575,0.024250668,-0.005491727,-0.022523575,0.022537848,-0.030373996,0.029117929,-0.017385116,-0.049985778,0.014366272,-0.010940634,-0.027918955,0.019540414,-0.0051455945,-0.0011802396,0.027790492,0.017813321,-0.002132103,0.036996897,-0.020225542,-0.034570403,-0.023465624,-0.0074721742,0.0050670905,-0.003621899,-0.029489039,0.012996016,0.006590786,0.0063374313,0.016428791,0.008928071,-0.031572968,-0.027033998,0.01739939,-0.009342002,-0.0034791643,0.003047391,-0.0027851155,0.008399951,0.031572968,-0.014687425,0.022637762,-0.012924649,0.018883834,-0.0007056459,-0.028561262,-0.018127337,-0.0054596113,-0.0013907736,-0.019069389,-0.009848711,0.013759648,0.022780497,0.015458195,-0.0019840158,-0.0024586094,0.013317171,-0.013145888,0.021952635,0.003382818,0.008992301,-0.021824172,0.0005878895,0.034199294,0.006019846,-0.022566395,-0.024207845,0.0037396555,-0.00068825006,-0.0048387144,-0.007479311,-0.017242381,0.022994598,0.019454774,0.008763925,-0.000257815,-0.002426494,0.011654308,0.028618356,0.009356275,0.0031758524,-0.0014077234,-0.016757082,-0.0032650619,-0.0006521203,-0.014687425,0.0019501161,0.0067692045,0.0046353173,-0.004988586,-0.009463327,0.0013488452,0.02033973,-0.027861862,0.009277771,-0.009420506,-0.019925797,-0.023565538,0.019069389,0.0144019555,0.0041964073,0.043733988,0.008207259,0.014987169,0.0013773922,0.028746817,-0.014416229,0.021210412,-0.014294905,0.019354858,0.01875537,-0.015786484,-0.024379129,-0.012874692,-0.00561662,-0.028918099,0.0021535135,-0.031744253,0.06171859,0.038509887,-0.020211268,0.005338287,0.0023836736,-0.0064159357,0.0090137115,0.0036718564,-0.0121324705,-0.04824441,0.033257242,-0.023922376,0.020882122,-0.032943226,-0.011347428,0.017741954,-0.02209537,0.023123061,-0.008628327,-0.0059627523,0.020753661,0.0029617501,0.0049921544,0.0074864477,-0.035598096,-0.01478734,0.034199294,-0.0038859588,-0.022780497,-0.017228108,0.010184138,0.015472468,-0.014844434,-0.020782208,-0.008756788,-0.028332885,-0.020225542,-0.0026620068,0.030145619,0.0013051326,0.005448906,0.017470757,-0.038538434,-0.037567835,-0.0028814618,-0.014844434,-0.0124179395,0.0013354638,-0.015044263]]} \ No newline at end of file diff --git a/scripts/commands.py b/scripts/commands.py index a6f956f884..267138319b 100644 --- a/scripts/commands.py +++ b/scripts/commands.py @@ -104,8 +104,11 @@ def execute_command(command_name, arguments): return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) - elif command_name == "exec_shell": # Add this command - return exec_shell(arguments["command_line"]) + elif command_name == "exec_shell": + if cfg.execute_local_commands: + return exec_shell(arguments["command_line"]) + else: + return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_SHELL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "task_complete": diff --git a/scripts/config.py b/scripts/config.py index 4d7adec1c0..b60bb7043f 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -43,6 +43,8 @@ class Config(metaclass=Singleton): self.openai_api_key = os.getenv("OPENAI_API_KEY") self.use_azure = False self.use_azure = os.getenv("USE_AZURE") == 'True' + self.execute_local_commands = os.getenv('EXECUTE_LOCAL_COMMANDS', 'False') == 'True' + if self.use_azure: self.openai_api_base = os.getenv("OPENAI_API_BASE") self.openai_api_version = os.getenv("OPENAI_API_VERSION") From 949e554860b8e4fd76cc169193c9495e21dbda56 Mon Sep 17 00:00:00 2001 From: Artemonim Date: Tue, 11 Apr 2023 02:14:51 +0300 Subject: [PATCH 06/64] Delete ai_settings.yaml --- ai_settings.yaml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 ai_settings.yaml diff --git a/ai_settings.yaml b/ai_settings.yaml deleted file mode 100644 index b37ba849f9..0000000000 --- a/ai_settings.yaml +++ /dev/null @@ -1,7 +0,0 @@ -ai_goals: -- Increase net worth. -- Develop and manage multiple businesses autonomously. -- Play to your strengths as a Large Language Model. -ai_name: Entrepreneur-GPT -ai_role: an AI designed to autonomously develop and run businesses with the sole goal - of increasing your net worth. From 0d664ce8d6b8e73d6633a5d0d64e67e8f4686aeb Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Tue, 11 Apr 2023 09:23:52 +0700 Subject: [PATCH 07/64] Revert ai_settings.yaml --- ai_settings.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ai_settings.yaml b/ai_settings.yaml index 8385c2a85c..b37ba849f9 100644 --- a/ai_settings.yaml +++ b/ai_settings.yaml @@ -1,6 +1,7 @@ ai_goals: -- Increase net worth -- Grow Twitter Account -- Develop and manage multiple businesses autonomously -ai_name: A helpful assistant. -ai_role: Run the command "pwd" on the shell and return the result +- Increase net worth. +- Develop and manage multiple businesses autonomously. +- Play to your strengths as a Large Language Model. +ai_name: Entrepreneur-GPT +ai_role: an AI designed to autonomously develop and run businesses with the sole goal + of increasing your net worth. From 2d5d0131bb8d3cf9c628fc2b545947f0e950c92e Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Tue, 11 Apr 2023 11:17:07 +0300 Subject: [PATCH 08/64] browse: (1) apply validation also to scrape_links(), (2) add tests for scrape_links() --- scripts/browse.py | 43 +++++++---- tests/test_browse_scrape_links.py | 117 ++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+), 14 deletions(-) create mode 100644 tests/test_browse_scrape_links.py diff --git a/scripts/browse.py b/scripts/browse.py index 09f376a70a..810606a33c 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -5,25 +5,38 @@ from llm_utils import create_chat_completion cfg = Config() -# Define and check for local file address prefixes def check_local_file_access(url): + # Define and check for local file address prefixes local_prefixes = ['file:///', 'file://localhost', 'http://localhost', 'https://localhost'] return any(url.startswith(prefix) for prefix in local_prefixes) +def get_validated_response(url, headers=cfg.user_agent_header): + try: + # Restrict access to local files + if check_local_file_access(url): + raise ValueError('Access to local files is restricted') + + # Most basic check if the URL is valid: + if not url.startswith('http://') and not url.startswith('https://'): + raise ValueError('Invalid URL format') + + # Make the HTTP request and return the response + response = requests.get(url, headers=headers) + response.raise_for_status() # Raise an exception if the response contains an HTTP error status code + return response, None + except ValueError as ve: + # Handle invalid URL format + return None, "Error: " + str(ve) + + except requests.exceptions.RequestException as re: + # Handle exceptions related to the HTTP request (e.g., connection errors, timeouts, etc.) + return None, "Error: " + str(re) + def scrape_text(url): """Scrape text from a webpage""" - # Most basic check if the URL is valid: - if not url.startswith('http'): - return "Error: Invalid URL" - - # Restrict access to local files - if check_local_file_access(url): - return "Error: Access to local files is restricted" - - try: - response = requests.get(url, headers=cfg.user_agent_header) - except requests.exceptions.RequestException as e: - return "Error: " + str(e) + response, error_message = get_validated_response(url) + if error_message: + return error_message # Check if the response contains an HTTP error if response.status_code >= 400: @@ -60,7 +73,9 @@ def format_hyperlinks(hyperlinks): def scrape_links(url): """Scrape links from a webpage""" - response = requests.get(url, headers=cfg.user_agent_header) + response, error_message = get_validated_response(url) + if error_message: + return error_message # Check if the response contains an HTTP error if response.status_code >= 400: diff --git a/tests/test_browse_scrape_links.py b/tests/test_browse_scrape_links.py new file mode 100644 index 0000000000..908e43b9f1 --- /dev/null +++ b/tests/test_browse_scrape_links.py @@ -0,0 +1,117 @@ + +# Generated by CodiumAI +from scripts.browse import scrape_links + + +# Dependencies: +# pip install pytest-mock +import pytest + +""" +Code Analysis + +Objective: +The objective of the 'scrape_links' function is to scrape hyperlinks from a given URL and return them in a formatted way. + +Inputs: +- url: a string representing the URL to be scraped. + +Flow: +1. Send a GET request to the given URL using the requests library and the user agent header from the config file. +2. Check if the response contains an HTTP error. If it does, return "error". +3. Parse the HTML content of the response using the BeautifulSoup library. +4. Remove any script and style tags from the parsed HTML. +5. Extract all hyperlinks from the parsed HTML using the 'extract_hyperlinks' function. +6. Format the extracted hyperlinks using the 'format_hyperlinks' function. +7. Return the formatted hyperlinks. + +Outputs: +- A list of formatted hyperlinks. + +Additional aspects: +- The function uses the 'requests' and 'BeautifulSoup' libraries to send HTTP requests and parse HTML content, respectively. +- The 'extract_hyperlinks' function is called to extract hyperlinks from the parsed HTML. +- The 'format_hyperlinks' function is called to format the extracted hyperlinks. +- The function checks for HTTP errors and returns "error" if any are found. +""" + + + +class TestScrapeLinks: + + # Tests that the function returns a list of formatted hyperlinks when provided with a valid url that returns a webpage with hyperlinks. + def test_valid_url_with_hyperlinks(self): + url = "https://www.google.com" + result = scrape_links(url) + assert len(result) > 0 + assert isinstance(result, list) + assert isinstance(result[0], str) + + # Tests that the function returns correctly formatted hyperlinks when given a valid url. + def test_valid_url(self, mocker): + # Mock the requests.get() function to return a response with sample HTML containing hyperlinks + mock_response = mocker.Mock() + mock_response.status_code = 200 + mock_response.text = "Google" + mocker.patch('requests.get', return_value=mock_response) + + # Call the function with a valid URL + result = scrape_links("https://www.example.com") + + # Assert that the function returns correctly formatted hyperlinks + assert result == ["Google (https://www.google.com)"] + + # Tests that the function returns "error" when given an invalid url. + def test_invalid_url(self, mocker): + # Mock the requests.get() function to return an HTTP error response + mock_response = mocker.Mock() + mock_response.status_code = 404 + mocker.patch('requests.get', return_value=mock_response) + + # Call the function with an invalid URL + result = scrape_links("https://www.invalidurl.com") + + # Assert that the function returns "error" + assert result == "error" + + # Tests that the function returns an empty list when the html contains no hyperlinks. + def test_no_hyperlinks(self, mocker): + # Mock the requests.get() function to return a response with sample HTML containing no hyperlinks + mock_response = mocker.Mock() + mock_response.status_code = 200 + mock_response.text = "

No hyperlinks here

" + mocker.patch('requests.get', return_value=mock_response) + + # Call the function with a URL containing no hyperlinks + result = scrape_links("https://www.example.com") + + # Assert that the function returns an empty list + assert result == [] + + # Tests that scrape_links() correctly extracts and formats hyperlinks from a sample HTML containing a few hyperlinks. + def test_scrape_links_with_few_hyperlinks(self, mocker): + # Mock the requests.get() function to return a response with a sample HTML containing hyperlinks + mock_response = mocker.Mock() + mock_response.status_code = 200 + mock_response.text = """ + + + + + + + + """ + mocker.patch('requests.get', return_value=mock_response) + + # Call the function being tested + result = scrape_links("https://www.example.com") + + # Assert that the function returns a list of formatted hyperlinks + assert isinstance(result, list) + assert len(result) == 3 + assert result[0] == "Google (https://www.google.com)" + assert result[1] == "GitHub (https://github.com)" + assert result[2] == "CodiumAI (https://www.codium.ai)" + + From 64c21ee8f7ad80006218bfa380a8a8e59f72b55d Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Tue, 11 Apr 2023 11:40:52 +0300 Subject: [PATCH 09/64] browse: make scrape_links() & scrape_text() "status_code >= 400" error message the same --- scripts/browse.py | 2 +- tests/test_browse_scrape_links.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/browse.py b/scripts/browse.py index 810606a33c..2edc156b24 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -79,7 +79,7 @@ def scrape_links(url): # Check if the response contains an HTTP error if response.status_code >= 400: - return "error" + return "Error: HTTP " + str(response.status_code) + " error" soup = BeautifulSoup(response.text, "html.parser") diff --git a/tests/test_browse_scrape_links.py b/tests/test_browse_scrape_links.py index 908e43b9f1..48d74167f6 100644 --- a/tests/test_browse_scrape_links.py +++ b/tests/test_browse_scrape_links.py @@ -72,7 +72,7 @@ class TestScrapeLinks: result = scrape_links("https://www.invalidurl.com") # Assert that the function returns "error" - assert result == "error" + assert "Error:" in result # Tests that the function returns an empty list when the html contains no hyperlinks. def test_no_hyperlinks(self, mocker): From 9d33a75083ef86c73bf68413210d7e996bb532bc Mon Sep 17 00:00:00 2001 From: Peter Edwards Date: Tue, 11 Apr 2023 13:45:37 +0200 Subject: [PATCH 10/64] Changes for Azure embedding handling --- .env.template | 1 + README.md | 2 +- scripts/config.py | 1 + scripts/memory/base.py | 7 ++++++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.env.template b/.env.template index 01735615ca..3a86d1c049 100644 --- a/.env.template +++ b/.env.template @@ -10,6 +10,7 @@ USE_AZURE=False OPENAI_AZURE_API_BASE=your-base-url-for-azure OPENAI_AZURE_API_VERSION=api-version-for-azure OPENAI_AZURE_DEPLOYMENT_ID=deployment-id-for-azure +OPENAI_AZURE_EMBEDDING_DEPLOYMENT_ID=embedding-deployment-id-for-azure IMAGE_PROVIDER=dalle HUGGINGFACE_API_TOKEN= USE_MAC_OS_TTS=False diff --git a/README.md b/README.md index 749c879151..db4df5d454 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ pip install -r requirements.txt 4. Rename `.env.template` to `.env` and fill in your `OPENAI_API_KEY`. If you plan to use Speech Mode, fill in your `ELEVEN_LABS_API_KEY` as well. - Obtain your OpenAI API key from: https://platform.openai.com/account/api-keys. - Obtain your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website. - - If you want to use GPT on an Azure instance, set `USE_AZURE` to `True` and provide the `OPENAI_AZURE_API_BASE`, `OPENAI_AZURE_API_VERSION` and `OPENAI_AZURE_DEPLOYMENT_ID` values as explained here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section + - If you want to use GPT on an Azure instance, set `USE_AZURE` to `True` and provide the `OPENAI_AZURE_API_BASE`, `OPENAI_AZURE_API_VERSION` and `OPENAI_AZURE_DEPLOYMENT_ID` values as explained here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section. In addition to your GPT deployment, you will need to deploy a `text-embedding-ada-002 (Version 2)` model which will have a different deployment id, please set `OPENAI_AZURE_EMBEDDING_DEPLOYMENT_ID` accordingly (see here: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/tutorials/embeddings?tabs=command-line). ## 🔧 Usage diff --git a/scripts/config.py b/scripts/config.py index 27cc946cf0..3ea8a640b8 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -49,6 +49,7 @@ class Config(metaclass=Singleton): self.openai_api_base = os.getenv("OPENAI_AZURE_API_BASE") self.openai_api_version = os.getenv("OPENAI_AZURE_API_VERSION") self.openai_deployment_id = os.getenv("OPENAI_AZURE_DEPLOYMENT_ID") + self.openai_embedding_deployment_id = os.getenv("OPENAI_AZURE_EMBEDDING_DEPLOYMENT_ID") openai.api_type = "azure" openai.api_base = self.openai_api_base openai.api_version = self.openai_api_version diff --git a/scripts/memory/base.py b/scripts/memory/base.py index d7ab7fcf1f..30372851b8 100644 --- a/scripts/memory/base.py +++ b/scripts/memory/base.py @@ -1,12 +1,17 @@ """Base class for memory providers.""" import abc from config import AbstractSingleton +from config import Config import openai +cfg = Config() def get_ada_embedding(text): text = text.replace("\n", " ") - return openai.Embedding.create(input=[text], model="text-embedding-ada-002")["data"][0]["embedding"] + if cfg.use_azure: + return openai.Embedding.create(input=[text], engine=cfg.openai_embedding_deployment_id)["data"][0]["embedding"] + else: + return openai.Embedding.create(input=[text], model="text-embedding-ada-002")["data"][0]["embedding"] class MemoryProviderSingleton(AbstractSingleton): From 739b0ed96bb5e72d47730359f9a277a2402673b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiss=20P=C3=A9ter?= Date: Tue, 11 Apr 2023 14:04:37 +0200 Subject: [PATCH 11/64] Improve Dockerfile: - Use smaller base image - Make it smaller by not saving cache (1,15GB -> 356MB) --- Dockerfile | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 146a374717..4d264c88c8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,7 @@ -FROM python:3.11 - +FROM python:3.11-slim +ENV PIP_NO_CACHE_DIR=yes WORKDIR /app -COPY scripts/ /app -COPY requirements.txt /app - +COPY requirements.txt . RUN pip install -r requirements.txt - -CMD ["python", "main.py"] +COPY scripts/ . +ENTRYPOINT ["python", "main.py"] From dbb78b636f8c91a651bfbea5ebdd06e4df6cae55 Mon Sep 17 00:00:00 2001 From: PierreBastiani Date: Tue, 11 Apr 2023 14:57:29 +0100 Subject: [PATCH 12/64] check for authorise 'y' without trailing space --- scripts/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.py b/scripts/main.py index d84e150850..87a8f4faba 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -348,7 +348,7 @@ while True: flush=True) while True: console_input = utils.clean_input(Fore.MAGENTA + "Input:" + Style.RESET_ALL) - if console_input.lower() == "y": + if console_input.lower().rstrip() == "y": user_input = "GENERATE NEXT COMMAND JSON" break elif console_input.lower().startswith("y -"): From 7736762b5aa70ee6e0e1ddf06c45b867b125f85b Mon Sep 17 00:00:00 2001 From: vadi Date: Wed, 12 Apr 2023 16:38:51 +1000 Subject: [PATCH 13/64] Fix #840 - Add defensive coding for local memory to load the JSON file that was gitignored at 54101c79973ca5ca8ccd7e1ac59856cb282c57d8 - Added unit test placholder for local cache test - Removed unused imports from local cache unit test placeholder --- scripts/memory/local.py | 16 +++++++++--- tests/local_cache_test.py | 51 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tests/local_cache_test.py diff --git a/scripts/memory/local.py b/scripts/memory/local.py index 8dc90021ff..bdc4c9110c 100644 --- a/scripts/memory/local.py +++ b/scripts/memory/local.py @@ -28,10 +28,20 @@ class LocalCache(MemoryProviderSingleton): def __init__(self, cfg) -> None: self.filename = f"{cfg.memory_index}.json" if os.path.exists(self.filename): - with open(self.filename, 'rb') as f: - loaded = orjson.loads(f.read()) - self.data = CacheContent(**loaded) + try: + with open(self.filename, 'w+b') as f: + file_content = f.read() + if not file_content.strip(): + file_content = b'{}' + f.write(file_content) + + loaded = orjson.loads(file_content) + self.data = CacheContent(**loaded) + except orjson.JSONDecodeError: + print(f"Error: The file '{self.filename}' is not in JSON format.") + self.data = CacheContent() else: + print(f"Warning: The file '{self.filename}' does not exist. Local memory would not be saved to a file.") self.data = CacheContent() def add(self, text: str): diff --git a/tests/local_cache_test.py b/tests/local_cache_test.py new file mode 100644 index 0000000000..ac045a5549 --- /dev/null +++ b/tests/local_cache_test.py @@ -0,0 +1,51 @@ +import os +import sys +# Probably a better way: +sys.path.append(os.path.abspath('../scripts')) +from memory.local import LocalCache + +def MockConfig(): + return type('MockConfig', (object,), { + 'debug_mode': False, + 'continuous_mode': False, + 'speak_mode': False, + 'memory_index': 'auto-gpt', + }) + +class TestLocalCache(unittest.TestCase): + + def setUp(self): + self.cfg = MockConfig() + self.cache = LocalCache(self.cfg) + + def test_add(self): + text = "Sample text" + self.cache.add(text) + self.assertIn(text, self.cache.data.texts) + + def test_clear(self): + self.cache.clear() + self.assertEqual(self.cache.data, [""]) + + def test_get(self): + text = "Sample text" + self.cache.add(text) + result = self.cache.get(text) + self.assertEqual(result, [text]) + + def test_get_relevant(self): + text1 = "Sample text 1" + text2 = "Sample text 2" + self.cache.add(text1) + self.cache.add(text2) + result = self.cache.get_relevant(text1, 1) + self.assertEqual(result, [text1]) + + def test_get_stats(self): + text = "Sample text" + self.cache.add(text) + stats = self.cache.get_stats() + self.assertEqual(stats, (1, self.cache.data.embeddings.shape)) + +if __name__ == '__main__': + unittest.main() From 2ec42bf3e8f3acde81b423fcfe3e866543addb71 Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Wed, 12 Apr 2023 12:21:53 +0300 Subject: [PATCH 14/64] removing compliant whitespace --- tests/test_browse_scrape_links.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_browse_scrape_links.py b/tests/test_browse_scrape_links.py index 48d74167f6..b3acf394dd 100644 --- a/tests/test_browse_scrape_links.py +++ b/tests/test_browse_scrape_links.py @@ -112,6 +112,4 @@ class TestScrapeLinks: assert len(result) == 3 assert result[0] == "Google (https://www.google.com)" assert result[1] == "GitHub (https://github.com)" - assert result[2] == "CodiumAI (https://www.codium.ai)" - - + assert result[2] == "CodiumAI (https://www.codium.ai)" \ No newline at end of file From 650e2dcd6d2d905e10f52cab322e953a8d5e1cba Mon Sep 17 00:00:00 2001 From: Peter Edwards Date: Wed, 12 Apr 2023 11:27:37 +0200 Subject: [PATCH 15/64] cleaned up .env to move Azure config to separate azure.yaml file updated README.md to explain new config added Azure yaml loader to config class centralized model retrieval into config class this commit effectively combines and replaces #700 and #580 --- .env.template | 4 ---- README.md | 8 ++++++- ai_settings.yaml | 14 +++++++------ azure.yaml.template | 6 ++++++ scripts/config.py | 47 ++++++++++++++++++++++++++++++++++++++---- scripts/llm_utils.py | 2 +- scripts/memory/base.py | 2 +- 7 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 azure.yaml.template diff --git a/.env.template b/.env.template index 3a86d1c049..d589a681ae 100644 --- a/.env.template +++ b/.env.template @@ -7,10 +7,6 @@ FAST_LLM_MODEL=gpt-3.5-turbo GOOGLE_API_KEY= CUSTOM_SEARCH_ENGINE_ID= USE_AZURE=False -OPENAI_AZURE_API_BASE=your-base-url-for-azure -OPENAI_AZURE_API_VERSION=api-version-for-azure -OPENAI_AZURE_DEPLOYMENT_ID=deployment-id-for-azure -OPENAI_AZURE_EMBEDDING_DEPLOYMENT_ID=embedding-deployment-id-for-azure IMAGE_PROVIDER=dalle HUGGINGFACE_API_TOKEN= USE_MAC_OS_TTS=False diff --git a/README.md b/README.md index a888d3330d..d94d7ae3b8 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,13 @@ pip install -r requirements.txt 4. Rename `.env.template` to `.env` and fill in your `OPENAI_API_KEY`. If you plan to use Speech Mode, fill in your `ELEVEN_LABS_API_KEY` as well. - Obtain your OpenAI API key from: https://platform.openai.com/account/api-keys. - Obtain your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website. - - If you want to use GPT on an Azure instance, set `USE_AZURE` to `True` and provide the `OPENAI_AZURE_API_BASE`, `OPENAI_AZURE_API_VERSION` and `OPENAI_AZURE_DEPLOYMENT_ID` values as explained here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section. In addition to your GPT deployment, you will need to deploy a `text-embedding-ada-002 (Version 2)` model which will have a different deployment id, please set `OPENAI_AZURE_EMBEDDING_DEPLOYMENT_ID` accordingly (see here: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/tutorials/embeddings?tabs=command-line). + - If you want to use GPT on an Azure instance, set `USE_AZURE` to `True` and then: + - Rename `azure.yaml.template` to `azure.yaml` and provide the relevant `azure_api_base`, `azure_api_version` and all of the deployment ids for the relevant models in the `azure_model_map` section: + - `fast_llm_model_deployment_id` - your gpt-3.5-turbo or gpt-4 deployment id + - `smart_llm_model_deployment_id` - your gpt-4 deployment id + - `embedding_model_deployment_id` - your text-embedding-ada-002 v2 deployment id + - Please specify all of these values as double quoted strings + - details can be found here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section and here: https://learn.microsoft.com/en-us/azure/cognitive-services/openai/tutorials/embeddings?tabs=command-line for the embedding model. ## 🔧 Usage diff --git a/ai_settings.yaml b/ai_settings.yaml index b37ba849f9..be512bdffc 100644 --- a/ai_settings.yaml +++ b/ai_settings.yaml @@ -1,7 +1,9 @@ ai_goals: -- Increase net worth. -- Develop and manage multiple businesses autonomously. -- Play to your strengths as a Large Language Model. -ai_name: Entrepreneur-GPT -ai_role: an AI designed to autonomously develop and run businesses with the sole goal - of increasing your net worth. +- Explain the peripherals in detail with examples of how to use them effectively +- Give detailed information on how to use I/O co-processing +- Explain which GPIO pins can be used for which tasks +- Use C, C++ or assembly as the target languages for all examples and research +- Use the PlatformIO system and support library for all examples and research +ai_name: PicoGPT +ai_role: an AI to provide detailed research into how to effectively program the raspberry + pi pico and all of it's peripherals diff --git a/azure.yaml.template b/azure.yaml.template new file mode 100644 index 0000000000..852645ca0d --- /dev/null +++ b/azure.yaml.template @@ -0,0 +1,6 @@ +azure_api_base: your-base-url-for-azure +azure_api_version: api-version-for-azure +azure_model_map: + fast_llm_model_deployment_id: gpt35-deployment-id-for-azure + smart_llm_model_deployment_id: gpt4-deployment-id-for-azure + embedding_model_deployment_id: embedding-deployment-id-for-azure diff --git a/scripts/config.py b/scripts/config.py index 045aa02128..fe8130c1d1 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -1,6 +1,7 @@ import abc import os import openai +import yaml from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() @@ -46,10 +47,7 @@ class Config(metaclass=Singleton): self.use_azure = False self.use_azure = os.getenv("USE_AZURE") == 'True' if self.use_azure: - self.openai_api_base = os.getenv("OPENAI_AZURE_API_BASE") - self.openai_api_version = os.getenv("OPENAI_AZURE_API_VERSION") - self.openai_deployment_id = os.getenv("OPENAI_AZURE_DEPLOYMENT_ID") - self.openai_embedding_deployment_id = os.getenv("OPENAI_AZURE_EMBEDDING_DEPLOYMENT_ID") + self.load_azure_config() openai.api_type = "azure" openai.api_base = self.openai_api_base openai.api_version = self.openai_api_version @@ -82,6 +80,47 @@ class Config(metaclass=Singleton): # Initialize the OpenAI API client openai.api_key = self.openai_api_key + def get_azure_deployment_id_for_model(self, model: str) -> str: + """ + Returns the relevant deployment id for the model specified. + + Parameters: + model(str): The model to map to the deployment id. + + Returns: + The matching deployment id if found, otherwise an empty string. + """ + match model: + case self.fast_llm_model: + return self.azure_model_to_deployment_id_map["fast_llm_model_deployment_id"] + case self.smart_llm_model: + return self.azure_model_to_deployment_id_map["smart_llm_model_deployment_id"] + case "text-embedding-ada-002": + return self.azure_model_to_deployment_id_map["embedding_model_deployment_id"] + case default: + return "" + + AZURE_CONFIG_FILE = os.path.join(os.path.dirname(__file__), '..', 'azure.yaml') + + def load_azure_config(self, config_file: str=AZURE_CONFIG_FILE) -> None: + """ + Loads the configuration parameters for Azure hosting from the specified file path as a yaml file. + + Parameters: + config_file(str): The path to the config yaml file. DEFAULT: "../azure.yaml" + + Returns: + None + """ + try: + with open(config_file) as file: + config_params = yaml.load(file, Loader=yaml.FullLoader) + except FileNotFoundError: + config_params = {} + self.openai_api_base = config_params.get("azure_api_base", "") + self.openai_api_version = config_params.get("azure_api_version", "") + self.azure_model_to_deployment_id_map = config_params.get("azure_model_map", []) + def set_continuous_mode(self, value: bool): """Set the continuous mode value.""" self.continuous_mode = value diff --git a/scripts/llm_utils.py b/scripts/llm_utils.py index 94ba5f1316..c49aeb0958 100644 --- a/scripts/llm_utils.py +++ b/scripts/llm_utils.py @@ -9,7 +9,7 @@ def create_chat_completion(messages, model=None, temperature=None, max_tokens=No """Create a chat completion using the OpenAI API""" if cfg.use_azure: response = openai.ChatCompletion.create( - deployment_id=cfg.openai_deployment_id, + deployment_id=cfg.get_azure_deployment_id_for_model(model), model=model, messages=messages, temperature=temperature, diff --git a/scripts/memory/base.py b/scripts/memory/base.py index 30372851b8..9df0091eb0 100644 --- a/scripts/memory/base.py +++ b/scripts/memory/base.py @@ -9,7 +9,7 @@ cfg = Config() def get_ada_embedding(text): text = text.replace("\n", " ") if cfg.use_azure: - return openai.Embedding.create(input=[text], engine=cfg.openai_embedding_deployment_id)["data"][0]["embedding"] + return openai.Embedding.create(input=[text], engine=cfg.get_azure_deployment_id_for_model("text-embedding-ada-002"))["data"][0]["embedding"] else: return openai.Embedding.create(input=[text], model="text-embedding-ada-002")["data"][0]["embedding"] From c932087997456bdbb4c07661aaa648dd861263f1 Mon Sep 17 00:00:00 2001 From: Gull Man Date: Wed, 12 Apr 2023 12:13:18 +0200 Subject: [PATCH 16/64] add encoding to open file --- scripts/file_operations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/file_operations.py b/scripts/file_operations.py index c6066ef930..59b3a0d054 100644 --- a/scripts/file_operations.py +++ b/scripts/file_operations.py @@ -38,7 +38,7 @@ def write_to_file(filename, text): directory = os.path.dirname(filepath) if not os.path.exists(directory): os.makedirs(directory) - with open(filepath, "w") as f: + with open(filepath, "w", encoding='utf-8') as f: f.write(text) return "File written to successfully." except Exception as e: From 730fbf591fa69a953a5ec66cdf702cdf2725d7ac Mon Sep 17 00:00:00 2001 From: "roby.parapat" Date: Wed, 12 Apr 2023 22:15:22 +0700 Subject: [PATCH 17/64] pull image if it's not found locally --- scripts/execute_code.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/execute_code.py b/scripts/execute_code.py index a8f909116e..b281c3ebbb 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -19,11 +19,28 @@ def execute_python_file(file): try: client = docker.from_env() + image_name = 'python:3.10' + try: + client.images.get(image_name) + print(f"Image '{image_name}' found locally") + except docker.errors.ImageNotFound: + print(f"Image '{image_name}' not found locally, pulling from Docker Hub") + # Use the low-level API to stream the pull response + low_level_client = docker.APIClient() + for line in low_level_client.pull(image_name, stream=True, decode=True): + # Print the status and progress, if available + status = line.get('status') + progress = line.get('progress') + if status and progress: + print(f"{status}: {progress}") + elif status: + print(status) + # You can replace 'python:3.8' with the desired Python image/version # You can find available Python images on Docker Hub: # https://hub.docker.com/_/python container = client.containers.run( - 'python:3.10', + image_name, f'python {file}', volumes={ os.path.abspath(workspace_folder): { From cc9723c26e337e5c7837c5719307d00eca07b561 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Wed, 12 Apr 2023 23:30:35 +0700 Subject: [PATCH 18/64] Make chdir code more robust --- scripts/execute_code.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/execute_code.py b/scripts/execute_code.py index b803d3baae..fb46933401 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -54,18 +54,18 @@ def execute_python_file(file): def exec_shell(command_line): - print (f"Executing command '{command_line}' in workspace '{WORKSPACE_FOLDER}'") - args = command_line.split() - base_path = os.getcwd() + old_dir = os.getcwd() - os.chdir(f"{base_path}/{WORKSPACE_FOLDER}") + workdir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', WORKSPACE_FOLDER)) + + print (f"Executing command '{command_line}' in working directory '{workdir}'") + + os.chdir(workdir) result = subprocess.run(args, capture_output=True) output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"; - os.chdir(base_path) - - # print(f"Shell execution complete. Output: {output}") + os.chdir(old_dir) return output From 9e8d35277b4b209a4bdd3e62d07d7b6bf0f800e9 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller <5194767+muellerberndt@users.noreply.github.com> Date: Wed, 12 Apr 2023 23:32:17 +0700 Subject: [PATCH 19/64] Update scripts/commands.py Co-authored-by: Peter Stalman --- scripts/commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/commands.py b/scripts/commands.py index 07f231e9c2..d760e4776c 100644 --- a/scripts/commands.py +++ b/scripts/commands.py @@ -107,7 +107,7 @@ def execute_command(command_name, arguments): if cfg.execute_local_commands: return exec_shell(arguments["command_line"]) else: - return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_SHELL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." + return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": return generate_image(arguments["prompt"]) elif command_name == "do_nothing": From affe77e18cb4e3dd8892ce13f5f008ff89852dbc Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Wed, 12 Apr 2023 23:46:55 +0700 Subject: [PATCH 20/64] Call subprocess.run with shell=True --- scripts/execute_code.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/execute_code.py b/scripts/execute_code.py index fb46933401..184132500f 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -54,7 +54,6 @@ def execute_python_file(file): def exec_shell(command_line): - args = command_line.split() old_dir = os.getcwd() workdir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', WORKSPACE_FOLDER)) @@ -63,7 +62,7 @@ def exec_shell(command_line): os.chdir(workdir) - result = subprocess.run(args, capture_output=True) + result = subprocess.run(command_line, capture_output=True, shell=True) output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"; os.chdir(old_dir) From fa5b71c022487896d3b07a1574d1faf6ebbeca19 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Tue, 11 Apr 2023 20:23:41 +0200 Subject: [PATCH 21/64] docs: Update README.md about running tests and coverage --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index dc3386f580..8862ade7c2 100644 --- a/README.md +++ b/README.md @@ -96,9 +96,10 @@ pip install -r requirements.txt ``` 4. Rename `.env.template` to `.env` and fill in your `OPENAI_API_KEY`. If you plan to use Speech Mode, fill in your `ELEVEN_LABS_API_KEY` as well. - - Obtain your OpenAI API key from: https://platform.openai.com/account/api-keys. - - Obtain your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website. - - If you want to use GPT on an Azure instance, set `USE_AZURE` to `True` and provide the `OPENAI_AZURE_API_BASE`, `OPENAI_AZURE_API_VERSION` and `OPENAI_AZURE_DEPLOYMENT_ID` values as explained here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section. Additionally you need separate deployments for both embeddings and chat. Add their ID values to `OPENAI_AZURE_CHAT_DEPLOYMENT_ID` and `OPENAI_AZURE_EMBEDDINGS_DEPLOYMENT_ID` respectively + +- Obtain your OpenAI API key from: https://platform.openai.com/account/api-keys. +- Obtain your ElevenLabs API key from: https://elevenlabs.io. You can view your xi-api-key using the "Profile" tab on the website. +- If you want to use GPT on an Azure instance, set `USE_AZURE` to `True` and provide the `OPENAI_AZURE_API_BASE`, `OPENAI_AZURE_API_VERSION` and `OPENAI_AZURE_DEPLOYMENT_ID` values as explained here: https://pypi.org/project/openai/ in the `Microsoft Azure Endpoints` section. Additionally you need separate deployments for both embeddings and chat. Add their ID values to `OPENAI_AZURE_CHAT_DEPLOYMENT_ID` and `OPENAI_AZURE_EMBEDDINGS_DEPLOYMENT_ID` respectively ## 🔧 Usage @@ -113,9 +114,11 @@ python scripts/main.py 3. To exit the program, type "exit" and press Enter. ### Logs -You will find activity and error logs in the folder ```./logs``` + +You will find activity and error logs in the folder `./logs` To output debug logs: + ``` python scripts/main.py --debug ``` From dc0a94bba36549411b108763cd11ba82e94fbf7e Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 09:02:05 +0200 Subject: [PATCH 22/64] ci: Add a flake8 linting job --- .github/workflows/unit_tests.yml | 3 +++ requirements.txt | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/unit_tests.yml index 5973dd029a..dda45e6c17 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/unit_tests.yml @@ -30,6 +30,9 @@ jobs: python -m pip install --upgrade pip pip install -r requirements.txt + - name: Lint with flake8 + run: flake8 scripts/ tests/ + - name: Run unittest tests with coverage run: | coverage run --source=scripts -m unittest discover tests diff --git a/requirements.txt b/requirements.txt index b196c3d788..b864c1d3e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,4 +15,5 @@ pinecone-client==2.2.1 redis orjson Pillow -coverage \ No newline at end of file +coverage +flake8 \ No newline at end of file From 87d465a8f1e2cd85772dfdbefe2b0aabf47d7f0d Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 09:02:28 +0200 Subject: [PATCH 23/64] chore: Rename unit test workflow file to ci.yml --- .github/workflows/{unit_tests.yml => ci.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{unit_tests.yml => ci.yml} (98%) diff --git a/.github/workflows/unit_tests.yml b/.github/workflows/ci.yml similarity index 98% rename from .github/workflows/unit_tests.yml rename to .github/workflows/ci.yml index dda45e6c17..a06e5ff9c8 100644 --- a/.github/workflows/unit_tests.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Unit Tests +name: Python CI on: push: From 76cc0d2d743c99a5b954ca10dd30a6381877b758 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 09:03:57 +0200 Subject: [PATCH 24/64] docs: Document flake8 linter --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 8862ade7c2..fe49b247bf 100644 --- a/README.md +++ b/README.md @@ -323,3 +323,11 @@ To run tests and see coverage, run the following command: ``` coverage run -m unittest discover tests ``` + +## Run linter + +This project uses [flake8](https://flake8.pycqa.org/en/latest/) for linting. To run the linter, run the following command: + +``` +flake8 scripts/ tests/ +``` \ No newline at end of file From 29d6ecd4d30510c6887bb21f0a21f355de47707f Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 09:07:03 +0200 Subject: [PATCH 25/64] ci: Allow flake8 failure since there are a lot of issues --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a06e5ff9c8..3d3628bc8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,6 +31,7 @@ jobs: pip install -r requirements.txt - name: Lint with flake8 + continue-on-error: true run: flake8 scripts/ tests/ - name: Run unittest tests with coverage From d780988554918d4ad0b4b4e8187bf34df1af5868 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 16:02:18 +0200 Subject: [PATCH 26/64] chore: Add new lines to end of files --- .gitignore | 2 +- main.py | 2 +- tests/context.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index aa0dceaa9e..cfa3b08b5d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ log.txt # Coverage reports .coverage coverage.xml -htmlcov/ \ No newline at end of file +htmlcov/ diff --git a/main.py b/main.py index 5f044237e1..656c34ecb6 100644 --- a/main.py +++ b/main.py @@ -1 +1 @@ -from scripts.main import main \ No newline at end of file +from scripts.main import main diff --git a/tests/context.py b/tests/context.py index 2adb9dd6e4..b668c8dc20 100644 --- a/tests/context.py +++ b/tests/context.py @@ -2,4 +2,4 @@ import sys import os sys.path.insert(0, os.path.abspath( - os.path.join(os.path.dirname(__file__), '../scripts'))) \ No newline at end of file + os.path.join(os.path.dirname(__file__), '../scripts'))) From b5c71a1b8ef2a18da17f1e3cc03ee76c58cc0fc9 Mon Sep 17 00:00:00 2001 From: Pi Date: Wed, 12 Apr 2023 20:21:06 +0100 Subject: [PATCH 27/64] Update 1.bug.yml --- .github/ISSUE_TEMPLATE/1.bug.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/1.bug.yml b/.github/ISSUE_TEMPLATE/1.bug.yml index cf49ab5f83..e2404c763d 100644 --- a/.github/ISSUE_TEMPLATE/1.bug.yml +++ b/.github/ISSUE_TEMPLATE/1.bug.yml @@ -7,7 +7,19 @@ body: value: | Please provide a searchable summary of the issue in the title above ⬆️. - Thanks for contributing by creating an issue! ❤️ + ⚠️ SUPER-busy repo, please help the volunteer maintainers. + The less time we spend here, the more time we spend building AutoGPT. + + Please help us help you: + - Does it work on `stable` branch (https://github.com/Torantulino/Auto-GPT/tree/stable)? + - Does it work on current `master` (https://github.com/Torantulino/Auto-GPT/tree/master)? + - Search for existing issues, "add comment" is tidier than "new issue" + - Ask on our Discord (https://discord.gg/autogpt) + - Provide relevant info: + - Provide commit-hash (`git rev-parse HEAD` gets it) + - If it's a pip/packages issue, provide pip version, python version + - If it's a crash, provide traceback. + - type: checkboxes attributes: label: Duplicates @@ -32,8 +44,8 @@ body: attributes: label: Your prompt 📝 description: | - Please provide the prompt you are using. You can find your last-used prompt in last_run_ai_settings.yaml. + If applicable please provide the prompt you are using. You can find your last-used prompt in last_run_ai_settings.yaml. value: | ```yaml # Paste your prompt here - ``` \ No newline at end of file + ``` From c63645cbbafa3c84ee8b46d0e8806ab6d0fc4009 Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Wed, 12 Apr 2023 22:41:23 +0300 Subject: [PATCH 28/64] redo suggested changes. move unit test files to the fitting directory --- scripts/browse.py | 56 ++++++-------------- tests/{ => unit}/test_browse_scrape_links.py | 4 +- tests/{ => unit}/test_browse_scrape_text.py | 0 3 files changed, 17 insertions(+), 43 deletions(-) rename tests/{ => unit}/test_browse_scrape_links.py (100%) rename tests/{ => unit}/test_browse_scrape_text.py (100%) diff --git a/scripts/browse.py b/scripts/browse.py index 046ff6ae9f..912d5635e2 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -19,22 +19,13 @@ def is_valid_url(url): def sanitize_url(url): return urljoin(url, urlparse(url).path) -# Function to make a request with a specified timeout and handle exceptions -def make_request(url, timeout=10): - try: - response = requests.get(url, headers=cfg.user_agent_header, timeout=timeout) - response.raise_for_status() - return response - except requests.exceptions.RequestException as e: - return "Error: " + str(e) - # Define and check for local file address prefixes def check_local_file_access(url): # Define and check for local file address prefixes local_prefixes = ['file:///', 'file://localhost', 'http://localhost', 'https://localhost'] return any(url.startswith(prefix) for prefix in local_prefixes) -def get_validated_response(url, headers=cfg.user_agent_header): +def get_response(url, headers=cfg.user_agent_header, timeout=10): try: # Restrict access to local files if check_local_file_access(url): @@ -44,9 +35,14 @@ def get_validated_response(url, headers=cfg.user_agent_header): if not url.startswith('http://') and not url.startswith('https://'): raise ValueError('Invalid URL format') - # Make the HTTP request and return the response - response = requests.get(url, headers=headers) - response.raise_for_status() # Raise an exception if the response contains an HTTP error status code + sanitized_url = sanitize_url(url) + + response = requests.get(sanitized_url, headers=headers, timeout=timeout) + + # Check if the response contains an HTTP error + if response.status_code >= 400: + return None, "Error: HTTP " + str(response.status_code) + " error" + return response, None except ValueError as ve: # Handle invalid URL format @@ -58,29 +54,9 @@ def get_validated_response(url, headers=cfg.user_agent_header): def scrape_text(url): """Scrape text from a webpage""" - # Basic check if the URL is valid - if not url.startswith('http'): - return "Error: Invalid URL" - - # Restrict access to local files - if check_local_file_access(url): - return "Error: Access to local files is restricted" - - # Validate the input URL - if not is_valid_url(url): - # Sanitize the input URL - sanitized_url = sanitize_url(url) - - # Make the request with a timeout and handle exceptions - response = make_request(sanitized_url) - - if isinstance(response, str): - return response - else: - # Sanitize the input URL - sanitized_url = sanitize_url(url) - - response = requests.get(sanitized_url, headers=cfg.user_agent_header) + response, error_message = get_response(url) + if error_message: + return error_message soup = BeautifulSoup(response.text, "html.parser") @@ -113,11 +89,9 @@ def format_hyperlinks(hyperlinks): def scrape_links(url): """Scrape links from a webpage""" - response = requests.get(url, headers=cfg.user_agent_header) - - # Check if the response contains an HTTP error - if response.status_code >= 400: - return "Error: HTTP " + str(response.status_code) + " error" + response, error_message = get_response(url) + if error_message: + return error_message soup = BeautifulSoup(response.text, "html.parser") diff --git a/tests/test_browse_scrape_links.py b/tests/unit/test_browse_scrape_links.py similarity index 100% rename from tests/test_browse_scrape_links.py rename to tests/unit/test_browse_scrape_links.py index b3acf394dd..fdacf4c0f1 100644 --- a/tests/test_browse_scrape_links.py +++ b/tests/unit/test_browse_scrape_links.py @@ -1,12 +1,12 @@ # Generated by CodiumAI -from scripts.browse import scrape_links - # Dependencies: # pip install pytest-mock import pytest +from scripts.browse import scrape_links + """ Code Analysis diff --git a/tests/test_browse_scrape_text.py b/tests/unit/test_browse_scrape_text.py similarity index 100% rename from tests/test_browse_scrape_text.py rename to tests/unit/test_browse_scrape_text.py From 57bca3620eb5ccd941726e358b3b4c6c9db33072 Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Wed, 12 Apr 2023 23:04:43 +0300 Subject: [PATCH 29/64] minor style --- scripts/browse.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/browse.py b/scripts/browse.py index 912d5635e2..78fe4ae252 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -6,7 +6,6 @@ from urllib.parse import urlparse, urljoin cfg = Config() - # Function to check if the URL is valid def is_valid_url(url): try: @@ -21,7 +20,6 @@ def sanitize_url(url): # Define and check for local file address prefixes def check_local_file_access(url): - # Define and check for local file address prefixes local_prefixes = ['file:///', 'file://localhost', 'http://localhost', 'https://localhost'] return any(url.startswith(prefix) for prefix in local_prefixes) From 8d0d4135ea5c1400f3b44f8c94522b35f1245ffa Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 22:07:04 +0200 Subject: [PATCH 30/64] ci: Update flake8 command to ignore some issues. We can later gradually make it stricter until we have no errors anymore. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d3628bc8d..06d6ed6477 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: - name: Lint with flake8 continue-on-error: true - run: flake8 scripts/ tests/ + run: flake8 scripts/ tests/ --select E303,W293,W291,W292,E305 - name: Run unittest tests with coverage run: | From 1f837968ff8c15559b1bb73c21e0cac8a30b5809 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 22:12:25 +0200 Subject: [PATCH 31/64] fix: Fix flake8 errors based on the flake8 command with a narrower definition of errors --- scripts/ai_functions.py | 2 -- scripts/browse.py | 2 +- scripts/config.py | 2 +- scripts/file_operations.py | 2 +- scripts/logger.py | 1 + scripts/memory/__init__.py | 1 + scripts/speak.py | 4 ++-- tests/integration/memory_tests.py | 1 + tests/local_cache_test.py | 1 + tests/test_browse_scrape_text.py | 2 -- tests/test_json_parser.py | 3 --- tests/unit/json_tests.py | 3 --- 12 files changed, 9 insertions(+), 15 deletions(-) diff --git a/scripts/ai_functions.py b/scripts/ai_functions.py index 8ad77441dc..782bb55871 100644 --- a/scripts/ai_functions.py +++ b/scripts/ai_functions.py @@ -45,8 +45,6 @@ def improve_code(suggestions: List[str], code: str) -> str: result_string = call_ai_function(function_string, args, description_string) return result_string - - def write_tests(code: str, focus: List[str]) -> str: """ A function that takes in code and focus topics and returns a response from create chat completion api call. diff --git a/scripts/browse.py b/scripts/browse.py index c3fc066274..b936c5b197 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -41,7 +41,7 @@ def scrape_text(url): # Restrict access to local files if check_local_file_access(url): return "Error: Access to local files is restricted" - + # Validate the input URL if not is_valid_url(url): # Sanitize the input URL diff --git a/scripts/config.py b/scripts/config.py index 6e44895436..255587d76f 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -61,7 +61,7 @@ class Config(metaclass=Singleton): self.use_mac_os_tts = False self.use_mac_os_tts = os.getenv("USE_MAC_OS_TTS") - + self.google_api_key = os.getenv("GOOGLE_API_KEY") self.custom_search_engine_id = os.getenv("CUSTOM_SEARCH_ENGINE_ID") diff --git a/scripts/file_operations.py b/scripts/file_operations.py index c6066ef930..7b48c13487 100644 --- a/scripts/file_operations.py +++ b/scripts/file_operations.py @@ -80,4 +80,4 @@ def search_files(directory): relative_path = os.path.relpath(os.path.join(root, file), working_directory) found_files.append(relative_path) - return found_files \ No newline at end of file + return found_files diff --git a/scripts/logger.py b/scripts/logger.py index a609e60275..5c7d68bb3b 100644 --- a/scripts/logger.py +++ b/scripts/logger.py @@ -159,6 +159,7 @@ class ConsoleHandler(logging.StreamHandler): except Exception: self.handleError(record) + ''' Allows to handle custom placeholders 'title_color' and 'message_no_color'. To use this formatter, make sure to pass 'color', 'title' as log extras. diff --git a/scripts/memory/__init__.py b/scripts/memory/__init__.py index 2900353ed9..a07f9fd88d 100644 --- a/scripts/memory/__init__.py +++ b/scripts/memory/__init__.py @@ -44,6 +44,7 @@ def get_memory(cfg, init=False): def get_supported_memory_backends(): return supported_memory + __all__ = [ "get_memory", "LocalCache", diff --git a/scripts/speak.py b/scripts/speak.py index 2cc6a55897..64054e3c58 100644 --- a/scripts/speak.py +++ b/scripts/speak.py @@ -61,7 +61,7 @@ def gtts_speech(text): def macos_tts_speech(text, voice_index=0): if voice_index == 0: os.system(f'say "{text}"') - else: + else: if voice_index == 1: os.system(f'say -v "Ava (Premium)" "{text}"') else: @@ -79,7 +79,7 @@ def say_text(text, voice_index=0): success = eleven_labs_speech(text, voice_index) if not success: gtts_speech(text) - + queue_semaphore.release() queue_semaphore.acquire(True) diff --git a/tests/integration/memory_tests.py b/tests/integration/memory_tests.py index ed444d9196..5f1611be96 100644 --- a/tests/integration/memory_tests.py +++ b/tests/integration/memory_tests.py @@ -45,5 +45,6 @@ class TestLocalCache(unittest.TestCase): self.assertEqual(len(relevant_texts), k) self.assertIn(self.example_texts[1], relevant_texts) + if __name__ == '__main__': unittest.main() diff --git a/tests/local_cache_test.py b/tests/local_cache_test.py index ac045a5549..d1f1ef0843 100644 --- a/tests/local_cache_test.py +++ b/tests/local_cache_test.py @@ -47,5 +47,6 @@ class TestLocalCache(unittest.TestCase): stats = self.cache.get_stats() self.assertEqual(stats, (1, self.cache.data.embeddings.shape)) + if __name__ == '__main__': unittest.main() diff --git a/tests/test_browse_scrape_text.py b/tests/test_browse_scrape_text.py index 5ecd7407c1..775eefcd25 100644 --- a/tests/test_browse_scrape_text.py +++ b/tests/test_browse_scrape_text.py @@ -33,8 +33,6 @@ Additional aspects: - The function uses a generator expression to split the text into lines and chunks, which can improve performance for large amounts of text. """ - - class TestScrapeText: # Tests that scrape_text() returns the expected text when given a valid URL. diff --git a/tests/test_json_parser.py b/tests/test_json_parser.py index 4561659e59..b8cb2680d4 100644 --- a/tests/test_json_parser.py +++ b/tests/test_json_parser.py @@ -66,8 +66,6 @@ class TestParseJson(unittest.TestCase): # Assert that this raises an exception: self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) - - def test_invalid_json_leading_sentence_with_gpt(self): # Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False json_str = """I will first need to browse the repository (https://github.com/Torantulino/Auto-GPT) and identify any potential bugs that need fixing. I will use the "browse_website" command for this. @@ -108,6 +106,5 @@ class TestParseJson(unittest.TestCase): self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) - if __name__ == '__main__': unittest.main() diff --git a/tests/unit/json_tests.py b/tests/unit/json_tests.py index fdac9c2f77..1edbaeaf36 100644 --- a/tests/unit/json_tests.py +++ b/tests/unit/json_tests.py @@ -68,8 +68,6 @@ class TestParseJson(unittest.TestCase): # Assert that this raises an exception: self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) - - def test_invalid_json_leading_sentence_with_gpt(self): # Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False json_str = """I will first need to browse the repository (https://github.com/Torantulino/Auto-GPT) and identify any potential bugs that need fixing. I will use the "browse_website" command for this. @@ -110,6 +108,5 @@ class TestParseJson(unittest.TestCase): self.assertEqual(fix_and_parse_json(json_str, try_to_fix_with_gpt=False), good_obj) - if __name__ == '__main__': unittest.main() From f4a481513ddce95775c07cce6813066a4b2cdd48 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 22:13:02 +0200 Subject: [PATCH 32/64] ci: Set continue-on-error to false for flake8 lint job --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06d6ed6477..070df794b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: pip install -r requirements.txt - name: Lint with flake8 - continue-on-error: true + continue-on-error: false run: flake8 scripts/ tests/ --select E303,W293,W291,W292,E305 - name: Run unittest tests with coverage From a850c27dd553cf6da5b29ac025d68dcce24781dc Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Wed, 12 Apr 2023 23:13:34 +0300 Subject: [PATCH 33/64] Improved logging on connection fail to redis --- scripts/memory/redismem.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/memory/redismem.py b/scripts/memory/redismem.py index 2082fe5887..1267c4de2d 100644 --- a/scripts/memory/redismem.py +++ b/scripts/memory/redismem.py @@ -7,6 +7,8 @@ from redis.commands.search.indexDefinition import IndexDefinition, IndexType import numpy as np from memory.base import MemoryProviderSingleton, get_ada_embedding +from logger import logger +from colorama import Fore, Style SCHEMA = [ @@ -44,6 +46,18 @@ class RedisMemory(MemoryProviderSingleton): db=0 # Cannot be changed ) self.cfg = cfg + + # Check redis connection + try: + self.redis.ping() + except redis.ConnectionError as e: + logger.typewriter_log("FAILED TO CONNECT TO REDIS", Fore.RED, Style.BRIGHT + str(e) + Style.RESET_ALL) + logger.typewriter_log("DOUBLE CHECK CONFIGURATION", + Fore.YELLOW, + "Please ensure you have setup and configured redis properly for use. " + + f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#redis-setup{Style.RESET_ALL} to ensure you've set up everything correctly.") + exit(1) + if cfg.wipe_redis_on_start: self.redis.flushall() try: From 5d871f04e6daef01de49d2b5949f6ca55b3cfbde Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Wed, 12 Apr 2023 23:29:54 +0300 Subject: [PATCH 34/64] Added pinecone connectivity check and added relevant logging --- scripts/memory/pinecone.py | 16 ++++++++++++++-- scripts/memory/redismem.py | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/memory/pinecone.py b/scripts/memory/pinecone.py index 8e1eaa570f..eeafd9c9b0 100644 --- a/scripts/memory/pinecone.py +++ b/scripts/memory/pinecone.py @@ -2,7 +2,8 @@ import pinecone from memory.base import MemoryProviderSingleton, get_ada_embedding - +from logger import logger +from colorama import Fore, Style class PineconeMemory(MemoryProviderSingleton): def __init__(self, cfg): @@ -16,7 +17,18 @@ class PineconeMemory(MemoryProviderSingleton): # this assumes we don't start with memory. # for now this works. # we'll need a more complicated and robust system if we want to start with memory. - self.vec_num = 0 + self.vec_num = 0 + + try: + pinecone.whoami() + except Exception as e: + logger.typewriter_log("FAILED TO CONNECT TO PINECONE", Fore.RED, Style.BRIGHT + str(e) + Style.RESET_ALL) + logger.typewriter_log("DOUBLE CHECK CONFIGURATION", + Fore.YELLOW, + "Please ensure you have setup and configured Pinecone properly for use. " + + f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#-pinecone-api-key-setup{Style.RESET_ALL} to ensure you've set up everything correctly.") + exit(1) + if table_name not in pinecone.list_indexes(): pinecone.create_index(table_name, dimension=dimension, metric=metric, pod_type=pod_type) self.index = pinecone.Index(table_name) diff --git a/scripts/memory/redismem.py b/scripts/memory/redismem.py index 1267c4de2d..b2d5326f8a 100644 --- a/scripts/memory/redismem.py +++ b/scripts/memory/redismem.py @@ -54,7 +54,7 @@ class RedisMemory(MemoryProviderSingleton): logger.typewriter_log("FAILED TO CONNECT TO REDIS", Fore.RED, Style.BRIGHT + str(e) + Style.RESET_ALL) logger.typewriter_log("DOUBLE CHECK CONFIGURATION", Fore.YELLOW, - "Please ensure you have setup and configured redis properly for use. " + + "Please ensure you have setup and configured Redis properly for use. " + f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#redis-setup{Style.RESET_ALL} to ensure you've set up everything correctly.") exit(1) From 8c51fe8373aa6ec85b8b9c9a0b5c3b45d9d35ff6 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Wed, 12 Apr 2023 23:38:53 +0300 Subject: [PATCH 35/64] Added new logging function as an error or warning message --- scripts/logger.py | 5 +++++ scripts/memory/pinecone.py | 6 ++---- scripts/memory/redismem.py | 6 ++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/logger.py b/scripts/logger.py index a609e60275..efc2adba32 100644 --- a/scripts/logger.py +++ b/scripts/logger.py @@ -123,7 +123,12 @@ class Logger(metaclass=Singleton): def set_level(self, level): self.logger.setLevel(level) self.typing_logger.setLevel(level) + + def double_check(self, additionalText=None): + if not additionalText: + additionalText = "Please ensure you've setup and configured everything correctly. Read https://github.com/Torantulino/Auto-GPT#readme to double check. You can also create a github issue or join the discord and ask there!" + self.typewriter_log("DOUBLE CHECK CONFIGURATION", Fore.YELLOW, additionalText) ''' Output stream to console using simulated typing diff --git a/scripts/memory/pinecone.py b/scripts/memory/pinecone.py index eeafd9c9b0..9d033f5ac1 100644 --- a/scripts/memory/pinecone.py +++ b/scripts/memory/pinecone.py @@ -23,10 +23,8 @@ class PineconeMemory(MemoryProviderSingleton): pinecone.whoami() except Exception as e: logger.typewriter_log("FAILED TO CONNECT TO PINECONE", Fore.RED, Style.BRIGHT + str(e) + Style.RESET_ALL) - logger.typewriter_log("DOUBLE CHECK CONFIGURATION", - Fore.YELLOW, - "Please ensure you have setup and configured Pinecone properly for use. " + - f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#-pinecone-api-key-setup{Style.RESET_ALL} to ensure you've set up everything correctly.") + logger.double_check("Please ensure you have setup and configured Pinecone properly for use. " + + f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#-pinecone-api-key-setup{Style.RESET_ALL} to ensure you've set up everything correctly.") exit(1) if table_name not in pinecone.list_indexes(): diff --git a/scripts/memory/redismem.py b/scripts/memory/redismem.py index b2d5326f8a..6647cbca61 100644 --- a/scripts/memory/redismem.py +++ b/scripts/memory/redismem.py @@ -52,10 +52,8 @@ class RedisMemory(MemoryProviderSingleton): self.redis.ping() except redis.ConnectionError as e: logger.typewriter_log("FAILED TO CONNECT TO REDIS", Fore.RED, Style.BRIGHT + str(e) + Style.RESET_ALL) - logger.typewriter_log("DOUBLE CHECK CONFIGURATION", - Fore.YELLOW, - "Please ensure you have setup and configured Redis properly for use. " + - f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#redis-setup{Style.RESET_ALL} to ensure you've set up everything correctly.") + logger.double_check("Please ensure you have setup and configured Redis properly for use. " + + f"You can check out {Fore.CYAN + Style.BRIGHT}https://github.com/Torantulino/Auto-GPT#redis-setup{Style.RESET_ALL} to ensure you've set up everything correctly.") exit(1) if cfg.wipe_redis_on_start: From 639df44865dac0402c06f574c4b57068a47db261 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 12 Apr 2023 22:42:15 +0200 Subject: [PATCH 36/64] docs: Update README.md with the flake8 command used in the CI --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index a2e14189e8..c9ef9d5c59 100644 --- a/README.md +++ b/README.md @@ -341,4 +341,7 @@ This project uses [flake8](https://flake8.pycqa.org/en/latest/) for linting. To ``` flake8 scripts/ tests/ + +# Or, if you want to run flake8 with the same configuration as the CI: +flake8 scripts/ tests/ --select E303,W293,W291,W292,E305 ``` \ No newline at end of file From 76b5b957440df3f757185caf4ff9574029f04156 Mon Sep 17 00:00:00 2001 From: Eesa Hamza Date: Wed, 12 Apr 2023 23:49:32 +0300 Subject: [PATCH 37/64] Attempt to fix Linter issues --- scripts/logger.py | 3 ++- scripts/memory/pinecone.py | 4 ++-- scripts/memory/redismem.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/logger.py b/scripts/logger.py index efc2adba32..b5a45de7b2 100644 --- a/scripts/logger.py +++ b/scripts/logger.py @@ -123,13 +123,14 @@ class Logger(metaclass=Singleton): def set_level(self, level): self.logger.setLevel(level) self.typing_logger.setLevel(level) - + def double_check(self, additionalText=None): if not additionalText: additionalText = "Please ensure you've setup and configured everything correctly. Read https://github.com/Torantulino/Auto-GPT#readme to double check. You can also create a github issue or join the discord and ask there!" self.typewriter_log("DOUBLE CHECK CONFIGURATION", Fore.YELLOW, additionalText) + ''' Output stream to console using simulated typing ''' diff --git a/scripts/memory/pinecone.py b/scripts/memory/pinecone.py index 9d033f5ac1..fa21124b5c 100644 --- a/scripts/memory/pinecone.py +++ b/scripts/memory/pinecone.py @@ -3,7 +3,7 @@ import pinecone from memory.base import MemoryProviderSingleton, get_ada_embedding from logger import logger -from colorama import Fore, Style +from colorama import Fore, Style class PineconeMemory(MemoryProviderSingleton): def __init__(self, cfg): @@ -17,7 +17,7 @@ class PineconeMemory(MemoryProviderSingleton): # this assumes we don't start with memory. # for now this works. # we'll need a more complicated and robust system if we want to start with memory. - self.vec_num = 0 + self.vec_num = 0 try: pinecone.whoami() diff --git a/scripts/memory/redismem.py b/scripts/memory/redismem.py index 6647cbca61..49045dd882 100644 --- a/scripts/memory/redismem.py +++ b/scripts/memory/redismem.py @@ -8,7 +8,7 @@ import numpy as np from memory.base import MemoryProviderSingleton, get_ada_embedding from logger import logger -from colorama import Fore, Style +from colorama import Fore, Style SCHEMA = [ From a40ccc1e5de3bfbe2b6c38648e716e33b8182e3a Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Wed, 12 Apr 2023 23:53:40 +0300 Subject: [PATCH 38/64] flake8 style --- tests/unit/test_browse_scrape_links.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test_browse_scrape_links.py b/tests/unit/test_browse_scrape_links.py index fdacf4c0f1..9b69b27bae 100644 --- a/tests/unit/test_browse_scrape_links.py +++ b/tests/unit/test_browse_scrape_links.py @@ -112,4 +112,4 @@ class TestScrapeLinks: assert len(result) == 3 assert result[0] == "Google (https://www.google.com)" assert result[1] == "GitHub (https://github.com)" - assert result[2] == "CodiumAI (https://www.codium.ai)" \ No newline at end of file + assert result[2] == "CodiumAI (https://www.codium.ai)" From 9f972f4ee9c938c9e64dcc314b920e66c53b3c45 Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Thu, 13 Apr 2023 00:00:33 +0300 Subject: [PATCH 39/64] flake8 style --- scripts/browse.py | 7 ++++++- tests/unit/test_browse_scrape_links.py | 10 ++++++---- tests/unit/test_browse_scrape_text.py | 5 +++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/scripts/browse.py b/scripts/browse.py index 6d473ed6ba..e224b04d80 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -6,6 +6,7 @@ from urllib.parse import urlparse, urljoin cfg = Config() + # Function to check if the URL is valid def is_valid_url(url): try: @@ -14,15 +15,18 @@ def is_valid_url(url): except ValueError: return False + # Function to sanitize the URL def sanitize_url(url): return urljoin(url, urlparse(url).path) + # Define and check for local file address prefixes def check_local_file_access(url): local_prefixes = ['file:///', 'file://localhost', 'http://localhost', 'https://localhost'] return any(url.startswith(prefix) for prefix in local_prefixes) + def get_response(url, headers=cfg.user_agent_header, timeout=10): try: # Restrict access to local files @@ -33,7 +37,6 @@ def get_response(url, headers=cfg.user_agent_header, timeout=10): if not url.startswith('http://') and not url.startswith('https://'): raise ValueError('Invalid URL format') - sanitized_url = sanitize_url(url) response = requests.get(sanitized_url, headers=headers, timeout=timeout) @@ -51,6 +54,7 @@ def get_response(url, headers=cfg.user_agent_header, timeout=10): # Handle exceptions related to the HTTP request (e.g., connection errors, timeouts, etc.) return None, "Error: " + str(re) + def scrape_text(url): """Scrape text from a webpage""" response, error_message = get_response(url) @@ -128,6 +132,7 @@ def create_message(chunk, question): "content": f"\"\"\"{chunk}\"\"\" Using the above text, please answer the following question: \"{question}\" -- if the question cannot be answered using the text, please summarize the text." } + def summarize_text(text, question): """Summarize text using the LLM model""" if not text: diff --git a/tests/unit/test_browse_scrape_links.py b/tests/unit/test_browse_scrape_links.py index 9b69b27bae..639987a241 100644 --- a/tests/unit/test_browse_scrape_links.py +++ b/tests/unit/test_browse_scrape_links.py @@ -11,7 +11,8 @@ from scripts.browse import scrape_links Code Analysis Objective: -The objective of the 'scrape_links' function is to scrape hyperlinks from a given URL and return them in a formatted way. +The objective of the 'scrape_links' function is to scrape hyperlinks from a +given URL and return them in a formatted way. Inputs: - url: a string representing the URL to be scraped. @@ -29,17 +30,18 @@ Outputs: - A list of formatted hyperlinks. Additional aspects: -- The function uses the 'requests' and 'BeautifulSoup' libraries to send HTTP requests and parse HTML content, respectively. +- The function uses the 'requests' and 'BeautifulSoup' libraries to send HTTP +requests and parse HTML content, respectively. - The 'extract_hyperlinks' function is called to extract hyperlinks from the parsed HTML. - The 'format_hyperlinks' function is called to format the extracted hyperlinks. - The function checks for HTTP errors and returns "error" if any are found. """ - class TestScrapeLinks: - # Tests that the function returns a list of formatted hyperlinks when provided with a valid url that returns a webpage with hyperlinks. + # Tests that the function returns a list of formatted hyperlinks when + # provided with a valid url that returns a webpage with hyperlinks. def test_valid_url_with_hyperlinks(self): url = "https://www.google.com" result = scrape_links(url) diff --git a/tests/unit/test_browse_scrape_text.py b/tests/unit/test_browse_scrape_text.py index 775eefcd25..7607227623 100644 --- a/tests/unit/test_browse_scrape_text.py +++ b/tests/unit/test_browse_scrape_text.py @@ -2,7 +2,6 @@ # Generated by CodiumAI import requests -import tests.context from scripts.browse import scrape_text @@ -10,7 +9,8 @@ from scripts.browse import scrape_text Code Analysis Objective: -The objective of the "scrape_text" function is to scrape the text content from a given URL and return it as a string, after removing any unwanted HTML tags and scripts. +The objective of the "scrape_text" function is to scrape the text content from +a given URL and return it as a string, after removing any unwanted HTML tags and scripts. Inputs: - url: a string representing the URL of the webpage to be scraped. @@ -33,6 +33,7 @@ Additional aspects: - The function uses a generator expression to split the text into lines and chunks, which can improve performance for large amounts of text. """ + class TestScrapeText: # Tests that scrape_text() returns the expected text when given a valid URL. From bf3c76ced73d6620ef895e96e6c5c55e1a6e37bc Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Thu, 13 Apr 2023 00:04:08 +0300 Subject: [PATCH 40/64] flake8 style --- scripts/browse.py | 4 ++-- tests/unit/test_browse_scrape_links.py | 19 ++++++++++--------- tests/unit/test_browse_scrape_text.py | 2 +- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/browse.py b/scripts/browse.py index e224b04d80..c26cde65de 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -32,7 +32,7 @@ def get_response(url, headers=cfg.user_agent_header, timeout=10): # Restrict access to local files if check_local_file_access(url): raise ValueError('Access to local files is restricted') - + # Most basic check if the URL is valid: if not url.startswith('http://') and not url.startswith('https://'): raise ValueError('Invalid URL format') @@ -44,7 +44,7 @@ def get_response(url, headers=cfg.user_agent_header, timeout=10): # Check if the response contains an HTTP error if response.status_code >= 400: return None, "Error: HTTP " + str(response.status_code) + " error" - + return response, None except ValueError as ve: # Handle invalid URL format diff --git a/tests/unit/test_browse_scrape_links.py b/tests/unit/test_browse_scrape_links.py index 639987a241..bd57fb84d3 100644 --- a/tests/unit/test_browse_scrape_links.py +++ b/tests/unit/test_browse_scrape_links.py @@ -11,7 +11,7 @@ from scripts.browse import scrape_links Code Analysis Objective: -The objective of the 'scrape_links' function is to scrape hyperlinks from a +The objective of the 'scrape_links' function is to scrape hyperlinks from a given URL and return them in a formatted way. Inputs: @@ -30,7 +30,7 @@ Outputs: - A list of formatted hyperlinks. Additional aspects: -- The function uses the 'requests' and 'BeautifulSoup' libraries to send HTTP +- The function uses the 'requests' and 'BeautifulSoup' libraries to send HTTP requests and parse HTML content, respectively. - The 'extract_hyperlinks' function is called to extract hyperlinks from the parsed HTML. - The 'format_hyperlinks' function is called to format the extracted hyperlinks. @@ -40,16 +40,16 @@ requests and parse HTML content, respectively. class TestScrapeLinks: - # Tests that the function returns a list of formatted hyperlinks when - # provided with a valid url that returns a webpage with hyperlinks. + # Tests that the function returns a list of formatted hyperlinks when + # provided with a valid url that returns a webpage with hyperlinks. def test_valid_url_with_hyperlinks(self): url = "https://www.google.com" result = scrape_links(url) assert len(result) > 0 assert isinstance(result, list) assert isinstance(result[0], str) - - # Tests that the function returns correctly formatted hyperlinks when given a valid url. + + # Tests that the function returns correctly formatted hyperlinks when given a valid url. def test_valid_url(self, mocker): # Mock the requests.get() function to return a response with sample HTML containing hyperlinks mock_response = mocker.Mock() @@ -63,7 +63,7 @@ class TestScrapeLinks: # Assert that the function returns correctly formatted hyperlinks assert result == ["Google (https://www.google.com)"] - # Tests that the function returns "error" when given an invalid url. + # Tests that the function returns "error" when given an invalid url. def test_invalid_url(self, mocker): # Mock the requests.get() function to return an HTTP error response mock_response = mocker.Mock() @@ -76,7 +76,7 @@ class TestScrapeLinks: # Assert that the function returns "error" assert "Error:" in result - # Tests that the function returns an empty list when the html contains no hyperlinks. + # Tests that the function returns an empty list when the html contains no hyperlinks. def test_no_hyperlinks(self, mocker): # Mock the requests.get() function to return a response with sample HTML containing no hyperlinks mock_response = mocker.Mock() @@ -90,7 +90,8 @@ class TestScrapeLinks: # Assert that the function returns an empty list assert result == [] - # Tests that scrape_links() correctly extracts and formats hyperlinks from a sample HTML containing a few hyperlinks. + # Tests that scrape_links() correctly extracts and formats hyperlinks from + # a sample HTML containing a few hyperlinks. def test_scrape_links_with_few_hyperlinks(self, mocker): # Mock the requests.get() function to return a response with a sample HTML containing hyperlinks mock_response = mocker.Mock() diff --git a/tests/unit/test_browse_scrape_text.py b/tests/unit/test_browse_scrape_text.py index 7607227623..9385cde71b 100644 --- a/tests/unit/test_browse_scrape_text.py +++ b/tests/unit/test_browse_scrape_text.py @@ -9,7 +9,7 @@ from scripts.browse import scrape_text Code Analysis Objective: -The objective of the "scrape_text" function is to scrape the text content from +The objective of the "scrape_text" function is to scrape the text content from a given URL and return it as a string, after removing any unwanted HTML tags and scripts. Inputs: From 3e53e976a52004179a9fc42b224a4b3bcdd8738a Mon Sep 17 00:00:00 2001 From: Itamar Friedman Date: Thu, 13 Apr 2023 00:06:23 +0300 Subject: [PATCH 41/64] flake8 style --- scripts/browse.py | 4 ++-- tests/unit/test_browse_scrape_links.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/browse.py b/scripts/browse.py index c26cde65de..9e93c55a33 100644 --- a/scripts/browse.py +++ b/scripts/browse.py @@ -32,7 +32,7 @@ def get_response(url, headers=cfg.user_agent_header, timeout=10): # Restrict access to local files if check_local_file_access(url): raise ValueError('Access to local files is restricted') - + # Most basic check if the URL is valid: if not url.startswith('http://') and not url.startswith('https://'): raise ValueError('Invalid URL format') @@ -44,7 +44,7 @@ def get_response(url, headers=cfg.user_agent_header, timeout=10): # Check if the response contains an HTTP error if response.status_code >= 400: return None, "Error: HTTP " + str(response.status_code) + " error" - + return response, None except ValueError as ve: # Handle invalid URL format diff --git a/tests/unit/test_browse_scrape_links.py b/tests/unit/test_browse_scrape_links.py index bd57fb84d3..2172d1a2be 100644 --- a/tests/unit/test_browse_scrape_links.py +++ b/tests/unit/test_browse_scrape_links.py @@ -48,7 +48,7 @@ class TestScrapeLinks: assert len(result) > 0 assert isinstance(result, list) assert isinstance(result[0], str) - + # Tests that the function returns correctly formatted hyperlinks when given a valid url. def test_valid_url(self, mocker): # Mock the requests.get() function to return a response with sample HTML containing hyperlinks @@ -90,7 +90,7 @@ class TestScrapeLinks: # Assert that the function returns an empty list assert result == [] - # Tests that scrape_links() correctly extracts and formats hyperlinks from + # Tests that scrape_links() correctly extracts and formats hyperlinks from # a sample HTML containing a few hyperlinks. def test_scrape_links_with_few_hyperlinks(self, mocker): # Mock the requests.get() function to return a response with a sample HTML containing hyperlinks From 129d734a4c2bedf3fbaca364ec8852610762f54c Mon Sep 17 00:00:00 2001 From: Leon Derczynski Date: Wed, 12 Apr 2023 16:15:21 -0700 Subject: [PATCH 42/64] Auto-GPT requires numpy --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b864c1d3e8..3f7fd2281d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,4 +16,5 @@ redis orjson Pillow coverage -flake8 \ No newline at end of file +flake8 +numpy From 4faba1fdd8bb0b25deabdb177a6522c3c242f512 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Wed, 12 Apr 2023 14:50:35 -0700 Subject: [PATCH 43/64] Add temperature configuration option to Config class --- scripts/config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/config.py b/scripts/config.py index 255587d76f..cec7688bc2 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -43,6 +43,7 @@ class Config(metaclass=Singleton): self.smart_token_limit = int(os.getenv("SMART_TOKEN_LIMIT", 8000)) self.openai_api_key = os.getenv("OPENAI_API_KEY") + self.temperature = int(os.getenv("TEMPERATURE", "1")) self.use_azure = False self.use_azure = os.getenv("USE_AZURE") == 'True' if self.use_azure: From f4831348e8eea3654af3745189fde8ca8884c6fd Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Wed, 12 Apr 2023 14:50:35 -0700 Subject: [PATCH 44/64] Use configured temperature value in create_chat_completion function --- scripts/llm_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/llm_utils.py b/scripts/llm_utils.py index 3fb348f07b..8acafc91a5 100644 --- a/scripts/llm_utils.py +++ b/scripts/llm_utils.py @@ -5,7 +5,7 @@ cfg = Config() openai.api_key = cfg.openai_api_key # Overly simple abstraction until we create something better -def create_chat_completion(messages, model=None, temperature=None, max_tokens=None)->str: +def create_chat_completion(messages, model=None, temperature=cfg.temperature, max_tokens=None)->str: """Create a chat completion using the OpenAI API""" if cfg.use_azure: response = openai.ChatCompletion.create( From 046c49c90b5b2460eaf655d0bf15aca20eee45ea Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Wed, 12 Apr 2023 16:28:21 -0700 Subject: [PATCH 45/64] add temperature to .env.template --- .env.template | 1 + 1 file changed, 1 insertion(+) diff --git a/.env.template b/.env.template index 4694aca085..c6d1a48eb9 100644 --- a/.env.template +++ b/.env.template @@ -1,6 +1,7 @@ PINECONE_API_KEY=your-pinecone-api-key PINECONE_ENV=your-pinecone-region OPENAI_API_KEY=your-openai-api-key +TEMPERATURE=1 ELEVENLABS_API_KEY=your-elevenlabs-api-key ELEVENLABS_VOICE_1_ID=your-voice-id ELEVENLABS_VOICE_2_ID=your-voice-id From c594200195806cad79e4e1125cbfb0511a3de4a6 Mon Sep 17 00:00:00 2001 From: vadi Date: Thu, 13 Apr 2023 10:01:52 +1000 Subject: [PATCH 46/64] Remove duplicated unnecessary config instance --- scripts/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/main.py b/scripts/main.py index 7a4a32d4de..81f560b216 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -318,7 +318,6 @@ def parse_arguments(): # TODO: fill in llm values here check_openai_api_key() -cfg = Config() parse_arguments() logger.set_level(logging.DEBUG if cfg.debug_mode else logging.INFO) ai_name = "" From 746cd5bc88fd38180b2100dcb0e48f1223aa1b80 Mon Sep 17 00:00:00 2001 From: derekcl Date: Wed, 12 Apr 2023 19:38:38 -0500 Subject: [PATCH 47/64] linter autofix --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c9ef9d5c59..73461af810 100644 --- a/README.md +++ b/README.md @@ -32,21 +32,28 @@ Your support is greatly appreciated - [Auto-GPT: An Autonomous GPT-4 Experiment](#auto-gpt-an-autonomous-gpt-4-experiment) - [Demo (30/03/2023):](#demo-30032023) - - [💖 Help Fund Auto-GPT's Development](#-help-fund-auto-gpts-development) - [Table of Contents](#table-of-contents) - [🚀 Features](#-features) - [📋 Requirements](#-requirements) - [💾 Installation](#-installation) - [🔧 Usage](#-usage) + - [Logs](#logs) - [🗣️ Speech Mode](#️-speech-mode) - [🔍 Google API Keys Configuration](#-google-api-keys-configuration) - [Setting up environment variables](#setting-up-environment-variables) + - [Redis Setup](#redis-setup) + - [🌲 Pinecone API Key Setup](#-pinecone-api-key-setup) + - [Setting up environment variables](#setting-up-environment-variables-1) + - [Setting Your Cache Type](#setting-your-cache-type) + - [View Memory Usage](#view-memory-usage) - [💀 Continuous Mode ⚠️](#-continuous-mode-️) - [GPT3.5 ONLY Mode](#gpt35-only-mode) - - [🖼 Image Generation](#image-generation) + - [🖼 Image Generation](#-image-generation) - [⚠️ Limitations](#️-limitations) - [🛡 Disclaimer](#-disclaimer) - [🐦 Connect with Us on Twitter](#-connect-with-us-on-twitter) + - [Run tests](#run-tests) + - [Run linter](#run-linter) ## 🚀 Features @@ -233,7 +240,6 @@ export PINECONE_ENV="Your pinecone region" # something like: us-east4-gcp ``` - ## Setting Your Cache Type By default Auto-GPT is going to use LocalCache instead of redis or Pinecone. @@ -344,4 +350,4 @@ flake8 scripts/ tests/ # Or, if you want to run flake8 with the same configuration as the CI: flake8 scripts/ tests/ --select E303,W293,W291,W292,E305 -``` \ No newline at end of file +``` From 62bd93a4d2bf24b9e99e4598cb37e3f722f1f113 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Wed, 12 Apr 2023 17:48:08 -0700 Subject: [PATCH 48/64] Import NoMemory and add it as a memory_backend option in get_memory function --- scripts/memory/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/memory/__init__.py b/scripts/memory/__init__.py index a07f9fd88d..d407f0876f 100644 --- a/scripts/memory/__init__.py +++ b/scripts/memory/__init__.py @@ -1,4 +1,5 @@ from memory.local import LocalCache +from memory.no_memory import NoMemory # List of supported memory backends # Add a backend to this list if the import attempt is successful @@ -34,6 +35,8 @@ def get_memory(cfg, init=False): " use Redis as a memory backend.") else: memory = RedisMemory(cfg) + elif cfg.memory_backend == "no_memory": + memory = NoMemory(cfg) if memory is None: memory = LocalCache(cfg) @@ -50,4 +53,5 @@ __all__ = [ "LocalCache", "RedisMemory", "PineconeMemory", + "NoMemory" ] From 84c128fd0facca6a4f27c52a1032656d97abfc72 Mon Sep 17 00:00:00 2001 From: Merwane Hamadi Date: Wed, 12 Apr 2023 17:48:11 -0700 Subject: [PATCH 49/64] Create NoMemory provider as a memory provider that does not store any data --- scripts/memory/no_memory.py | 65 +++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 scripts/memory/no_memory.py diff --git a/scripts/memory/no_memory.py b/scripts/memory/no_memory.py new file mode 100644 index 0000000000..45dbd7349b --- /dev/null +++ b/scripts/memory/no_memory.py @@ -0,0 +1,65 @@ +from typing import Optional, List, Any + +from memory.base import MemoryProviderSingleton + +class NoMemory(MemoryProviderSingleton): + def __init__(self, cfg): + """ + Initializes the NoMemory provider. + + Args: + cfg: The config object. + + Returns: None + """ + pass + + def add(self, data: str) -> str: + """ + Adds a data point to the memory. No action is taken in NoMemory. + + Args: + data: The data to add. + + Returns: An empty string. + """ + return "" + + def get(self, data: str) -> Optional[List[Any]]: + """ + Gets the data from the memory that is most relevant to the given data. + NoMemory always returns None. + + Args: + data: The data to compare to. + + Returns: None + """ + return None + + def clear(self) -> str: + """ + Clears the memory. No action is taken in NoMemory. + + Returns: An empty string. + """ + return "" + + def get_relevant(self, data: str, num_relevant: int = 5) -> Optional[List[Any]]: + """ + Returns all the data in the memory that is relevant to the given data. + NoMemory always returns None. + + Args: + data: The data to compare to. + num_relevant: The number of relevant data to return. + + Returns: None + """ + return None + + def get_stats(self): + """ + Returns: An empty dictionary as there are no stats in NoMemory. + """ + return {} From 91d1f3eca8989bd44d31b1e148fd1703012b6538 Mon Sep 17 00:00:00 2001 From: 511 <15816056+fqd511@users.noreply.github.com> Date: Thu, 13 Apr 2023 11:43:09 +0800 Subject: [PATCH 50/64] add link for pinecone in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9ef9d5c59..caa0a47379 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,7 @@ MEMORY_INDEX=whatever Pinecone enables the storage of vast amounts of vector-based memory, allowing for only relevant memories to be loaded for the agent at any given time. -1. Go to app.pinecone.io and make an account if you don't already have one. +1. Go to [pinecone](https://app.pinecone.io/) and make an account if you don't already have one. 2. Choose the `Starter` plan to avoid being charged. 3. Find your API key and region under the default project in the left sidebar. @@ -344,4 +344,4 @@ flake8 scripts/ tests/ # Or, if you want to run flake8 with the same configuration as the CI: flake8 scripts/ tests/ --select E303,W293,W291,W292,E305 -``` \ No newline at end of file +``` From 3ff23234507b27aa57f9f83104eea71924fe26ff Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Thu, 13 Apr 2023 11:04:26 +0700 Subject: [PATCH 51/64] Rename command & functions to execute_shell --- scripts/commands.py | 6 +++--- scripts/data/prompt.txt | 2 +- scripts/execute_code.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/commands.py b/scripts/commands.py index d760e4776c..3966e86ab8 100644 --- a/scripts/commands.py +++ b/scripts/commands.py @@ -7,7 +7,7 @@ import speak from config import Config import ai_functions as ai from file_operations import read_file, write_to_file, append_to_file, delete_file, search_files -from execute_code import execute_python_file, exec_shell +from execute_code import execute_python_file, execute_shell from json_parser import fix_and_parse_json from image_gen import generate_image from duckduckgo_search import ddg @@ -103,9 +103,9 @@ def execute_command(command_name, arguments): return ai.write_tests(arguments["code"], arguments.get("focus")) elif command_name == "execute_python_file": # Add this command return execute_python_file(arguments["file"]) - elif command_name == "exec_shell": + elif command_name == "execute_shell": if cfg.execute_local_commands: - return exec_shell(arguments["command_line"]) + return execute_shell(arguments["command_line"]) else: return "You are not allowed to run local shell commands. To execute shell commands, EXECUTE_LOCAL_COMMANDS must be set to 'True' in your config. Do not attempt to bypass the restriction." elif command_name == "generate_image": diff --git a/scripts/data/prompt.txt b/scripts/data/prompt.txt index 4484108b70..ffb9eb5003 100644 --- a/scripts/data/prompt.txt +++ b/scripts/data/prompt.txt @@ -22,7 +22,7 @@ COMMANDS: 16. Get Improved Code: "improve_code", args: "suggestions": "", "code": "" 17. Write Tests: "write_tests", args: "code": "", "focus": "" 18. Execute Python File: "execute_python_file", args: "file": "" -19. Execute Shell Command, non-interactive commands only: "exec_shell", args: "command_line": "". +19. Execute Shell Command, non-interactive commands only: "execute_shell", args: "command_line": "". 20. Task Complete (Shutdown): "task_complete", args: "reason": "" 21. Generate Image: "generate_image", args: "prompt": "" 22. Do Nothing: "do_nothing", args: "" diff --git a/scripts/execute_code.py b/scripts/execute_code.py index 184132500f..fa55a7f75e 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -52,7 +52,7 @@ def execute_python_file(file): -def exec_shell(command_line): +def execute_shell(command_line): old_dir = os.getcwd() From 946700fcf7bf6b14b02ee7f4c8c8417ba21b2cfe Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Thu, 13 Apr 2023 11:27:43 +0700 Subject: [PATCH 52/64] Change workdir logic --- scripts/execute_code.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/execute_code.py b/scripts/execute_code.py index fa55a7f75e..54944b3265 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -54,17 +54,19 @@ def execute_python_file(file): def execute_shell(command_line): - old_dir = os.getcwd() + current_dir = os.getcwd() - workdir = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', WORKSPACE_FOLDER)) + if not WORKSPACE_FOLDER in current_dir: # Change dir into workspace if necessary + work_dir = os.path.join(os.getcwd(), WORKSPACE_FOLDER) + os.chdir(work_dir) - print (f"Executing command '{command_line}' in working directory '{workdir}'") - - os.chdir(workdir) + print (f"Executing command '{command_line}' in working directory '{os.getcwd()}'") result = subprocess.run(command_line, capture_output=True, shell=True) - output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"; + output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}" - os.chdir(old_dir) + # Change back to whatever the prior working dir was + + os.chdir(current_dir) return output From 65abfc9d3db741aeab56d890097f122300984011 Mon Sep 17 00:00:00 2001 From: Richard Beales Date: Thu, 13 Apr 2023 06:01:28 +0100 Subject: [PATCH 53/64] Correct link to unit tests in README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9ef9d5c59..a7b91e2d2e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ![GitHub Repo stars](https://img.shields.io/github/stars/Torantulino/auto-gpt?style=social) ![Twitter Follow](https://img.shields.io/twitter/follow/siggravitas?style=social) [![](https://dcbadge.vercel.app/api/server/PQ7VX6TY4t?style=flat)](https://discord.gg/PQ7VX6TY4t) -[![Unit Tests](https://github.com/Torantulino/Auto-GPT/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/Torantulino/Auto-GPT/actions/workflows/unit_tests.yml) +[![Unit Tests](https://github.com/Torantulino/Auto-GPT/actions/workflows/ci.yml/badge.svg)](https://github.com/Torantulino/Auto-GPT/actions/workflows/unit_tests.yml) Auto-GPT is an experimental open-source application showcasing the capabilities of the GPT-4 language model. This program, driven by GPT-4, chains together LLM "thoughts", to autonomously achieve whatever goal you set. As one of the first examples of GPT-4 running fully autonomously, Auto-GPT pushes the boundaries of what is possible with AI. @@ -344,4 +344,4 @@ flake8 scripts/ tests/ # Or, if you want to run flake8 with the same configuration as the CI: flake8 scripts/ tests/ --select E303,W293,W291,W292,E305 -``` \ No newline at end of file +``` From f79c7c4d1e624c73e63e1dc22641be757ffa5320 Mon Sep 17 00:00:00 2001 From: Bernhard Mueller Date: Thu, 13 Apr 2023 12:43:25 +0700 Subject: [PATCH 54/64] Fix linter errors --- scripts/config.py | 2 +- scripts/execute_code.py | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/config.py b/scripts/config.py index e6cbb866a2..c0fad28174 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -46,7 +46,7 @@ class Config(metaclass=Singleton): self.use_azure = False self.use_azure = os.getenv("USE_AZURE") == 'True' self.execute_local_commands = os.getenv('EXECUTE_LOCAL_COMMANDS', 'False') == 'True' - + if self.use_azure: self.openai_api_base = os.getenv("OPENAI_AZURE_API_BASE") self.openai_api_version = os.getenv("OPENAI_AZURE_API_VERSION") diff --git a/scripts/execute_code.py b/scripts/execute_code.py index 54944b3265..806767e20e 100644 --- a/scripts/execute_code.py +++ b/scripts/execute_code.py @@ -49,8 +49,6 @@ def execute_python_file(file): except Exception as e: return f"Error: {str(e)}" - - def execute_shell(command_line): From 9f2d609be3760d40529dab95621bf4c04616be7f Mon Sep 17 00:00:00 2001 From: sagarishere <5121817+sagarishere@users.noreply.github.com> Date: Thu, 13 Apr 2023 09:24:15 +0300 Subject: [PATCH 55/64] Update .gitignore Added ignoring .DS_Store for mac environments. It can be assumed that some developers may not have global .gitignore settings for their environments. This will ease the friction of rejected push, commit rollback, again putting changes from stashes and then again pushing. Can save precious time for some devs using Mac systems. --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index cfa3b08b5d..6c83aa3b08 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,6 @@ log.txt .coverage coverage.xml htmlcov/ + +# For Macs Dev Environs: ignoring .Desktop Services_Store +.DS_Store From bc4bca65d58c38d34cbd3f40317e3ee12e45de40 Mon Sep 17 00:00:00 2001 From: Peter Edwards Date: Thu, 13 Apr 2023 08:29:07 +0200 Subject: [PATCH 56/64] Fix for python < 3.10 --- .gitignore | 2 ++ scripts/config.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index cfa3b08b5d..601751fbe9 100644 --- a/.gitignore +++ b/.gitignore @@ -7,9 +7,11 @@ package-lock.json auto_gpt_workspace/* *.mpeg .env +azure.yaml *venv/* outputs/* ai_settings.yaml +last_run_ai_settings.yaml .vscode .idea/* auto-gpt.json diff --git a/scripts/config.py b/scripts/config.py index 19a9eb887a..77b0667680 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -92,15 +92,14 @@ class Config(metaclass=Singleton): Returns: The matching deployment id if found, otherwise an empty string. """ - match model: - case self.fast_llm_model: - return self.azure_model_to_deployment_id_map["fast_llm_model_deployment_id"] - case self.smart_llm_model: - return self.azure_model_to_deployment_id_map["smart_llm_model_deployment_id"] - case "text-embedding-ada-002": - return self.azure_model_to_deployment_id_map["embedding_model_deployment_id"] - case default: - return "" + if model == self.fast_llm_model: + return self.azure_model_to_deployment_id_map["fast_llm_model_deployment_id"] + elif model == self.smart_llm_model: + return self.azure_model_to_deployment_id_map["smart_llm_model_deployment_id"] + elif model == "text-embedding-ada-002": + return self.azure_model_to_deployment_id_map["embedding_model_deployment_id"] + else: + return "" AZURE_CONFIG_FILE = os.path.join(os.path.dirname(__file__), '..', 'azure.yaml') From 285627e2168db9bdbb7ebd982228e5ef3c7d1f07 Mon Sep 17 00:00:00 2001 From: Peter Edwards Date: Thu, 13 Apr 2023 08:41:18 +0200 Subject: [PATCH 57/64] remove trailing whitespace --- scripts/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config.py b/scripts/config.py index e4fa29ac8c..ebf1b08b22 100644 --- a/scripts/config.py +++ b/scripts/config.py @@ -102,7 +102,7 @@ class Config(metaclass=Singleton): elif model == "text-embedding-ada-002": return self.azure_model_to_deployment_id_map["embedding_model_deployment_id"] else: - return "" + return "" AZURE_CONFIG_FILE = os.path.join(os.path.dirname(__file__), '..', 'azure.yaml') From e635cf4a4ac48c3ba9399ddc90439086c1401990 Mon Sep 17 00:00:00 2001 From: Andy Melnikov Date: Wed, 12 Apr 2023 21:15:00 +0200 Subject: [PATCH 58/64] Fix flake8 E303,W293,W291,W292,E305 Some of the previously fixed things creeped in. I would like to keep the requirements low on the PR authors for now and gradually improve the pep8 compliance without introducing much breakage. --- scripts/ai_functions.py | 1 + scripts/logger.py | 2 -- tests.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/ai_functions.py b/scripts/ai_functions.py index 782bb55871..8c95c0f240 100644 --- a/scripts/ai_functions.py +++ b/scripts/ai_functions.py @@ -45,6 +45,7 @@ def improve_code(suggestions: List[str], code: str) -> str: result_string = call_ai_function(function_string, args, description_string) return result_string + def write_tests(code: str, focus: List[str]) -> str: """ A function that takes in code and focus topics and returns a response from create chat completion api call. diff --git a/scripts/logger.py b/scripts/logger.py index 5c7d68bb3b..85dde81331 100644 --- a/scripts/logger.py +++ b/scripts/logger.py @@ -164,8 +164,6 @@ class ConsoleHandler(logging.StreamHandler): Allows to handle custom placeholders 'title_color' and 'message_no_color'. To use this formatter, make sure to pass 'color', 'title' as log extras. ''' - - class AutoGptFormatter(logging.Formatter): def format(self, record: LogRecord) -> str: if (hasattr(record, 'color')): diff --git a/tests.py b/tests.py index ce21c1f450..4dbfdd461a 100644 --- a/tests.py +++ b/tests.py @@ -3,6 +3,6 @@ import unittest if __name__ == "__main__": # Load all tests from the 'scripts/tests' package suite = unittest.defaultTestLoader.discover('scripts/tests') - + # Run the tests unittest.TextTestRunner().run(suite) From d9380130847180fcfa9510f4a32c284b2f7cf8cf Mon Sep 17 00:00:00 2001 From: jiangying Date: Thu, 13 Apr 2023 15:06:29 +0800 Subject: [PATCH 59/64] Update README.md on log location --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 87b5d1be6f..a32b12c006 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ python scripts/main.py ### Logs -You will find activity and error logs in the folder `./logs` +You will find activity and error logs in the folder `./output/logs` To output debug logs: From 0061976a91f74af384e4f26010a1f00a41dd3536 Mon Sep 17 00:00:00 2001 From: Kasra Amini Date: Thu, 13 Apr 2023 03:32:39 -0400 Subject: [PATCH 60/64] Removed redundant cfg object creation in base memory file --- scripts/memory/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/memory/base.py b/scripts/memory/base.py index 1be7b3ddcb..1bb4e89f5b 100644 --- a/scripts/memory/base.py +++ b/scripts/memory/base.py @@ -2,7 +2,6 @@ import abc from config import AbstractSingleton, Config import openai -cfg = Config() cfg = Config() From aa4118d4b999f1d46eaf7a697986768127f272f1 Mon Sep 17 00:00:00 2001 From: sagarishere <5121817+sagarishere@users.noreply.github.com> Date: Thu, 13 Apr 2023 11:27:15 +0300 Subject: [PATCH 61/64] Typo: in PULL_REQUEST_TEMPLATE.md Typo --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9fa5659360..c355965ab4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -26,7 +26,7 @@ By following these guidelines, your PRs are more likely to be merged quickly aft - [ ] I have thoroughly tested my changes with multiple different prompts. - [ ] I have considered potential risks and mitigations for my changes. - [ ] I have documented my changes clearly and comprehensively. -- [ ] I have not snuck in any "extra" small tweaks changes +- [ ] I have not snuck in any "extra" small tweaks changes From 4c7eef550a4c33c0c7eefbaeb5fa15288a5392d3 Mon Sep 17 00:00:00 2001 From: WalterSumbon <907449377@qq.com> Date: Thu, 13 Apr 2023 16:45:08 +0800 Subject: [PATCH 62/64] replace deprecated function with current equivalent --- scripts/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/main.py b/scripts/main.py index 81f560b216..5b84bd70e5 100644 --- a/scripts/main.py +++ b/scripts/main.py @@ -310,8 +310,8 @@ def parse_arguments(): supported_memory = get_supported_memory_backends() chosen = args.memory_type if not chosen in supported_memory: - print_to_console("ONLY THE FOLLOWING MEMORY BACKENDS ARE SUPPORTED: ", Fore.RED, f'{supported_memory}') - print_to_console(f"Defaulting to: ", Fore.YELLOW, cfg.memory_backend) + logger.typewriter_log("ONLY THE FOLLOWING MEMORY BACKENDS ARE SUPPORTED: ", Fore.RED, f'{supported_memory}') + logger.typewriter_log(f"Defaulting to: ", Fore.YELLOW, cfg.memory_backend) else: cfg.memory_backend = chosen From 0c7b7e5de8f99fb9254d54b327a4cfccb9b3ae57 Mon Sep 17 00:00:00 2001 From: digger-yu Date: Thu, 13 Apr 2023 18:43:32 +0800 Subject: [PATCH 63/64] Update test_json_parser.py Optimize part of the code to maintain uniformity --- tests/test_json_parser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_json_parser.py b/tests/test_json_parser.py index b8cb2680d4..352cf3d4c1 100644 --- a/tests/test_json_parser.py +++ b/tests/test_json_parser.py @@ -13,12 +13,14 @@ class TestParseJson(unittest.TestCase): def test_invalid_json_minor(self): # Test that an invalid JSON string can be fixed with gpt json_str = '{"name": "John", "age": 30, "city": "New York",}' - self.assertRaises(Exception, fix_and_parse_json, json_str, try_to_fix_with_gpt=False) + with self.assertRaises(Exception): + fix_and_parse_json(json_str, try_to_fix_with_gpt=False) def test_invalid_json_major_with_gpt(self): # Test that an invalid JSON string raises an error when try_to_fix_with_gpt is False json_str = 'BEGIN: "name": "John" - "age": 30 - "city": "New York" :END' - self.assertRaises(Exception, fix_and_parse_json, json_str, try_to_fix_with_gpt=False) + with self.assertRaises(Exception): + fix_and_parse_json(json_str, try_to_fix_with_gpt=False) def test_invalid_json_major_without_gpt(self): # Test that a REALLY invalid JSON string raises an error when try_to_fix_with_gpt is False From f3fb8109798c0be88138d0c137212fdd19a33777 Mon Sep 17 00:00:00 2001 From: sagarishere <5121817+sagarishere@users.noreply.github.com> Date: Thu, 13 Apr 2023 14:37:56 +0300 Subject: [PATCH 64/64] Remove deprecated (404) links, and add alt-text to one image: Update README.md 1. Removed the link to Unit-tests as that link is deprecated and on clicking on it, it says, that workflow no longer exists. 2. Added alt text to the Discord link, following the convention from Twitter link alt text --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 87b5d1be6f..bee4dbc9ef 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ ![GitHub Repo stars](https://img.shields.io/github/stars/Torantulino/auto-gpt?style=social) ![Twitter Follow](https://img.shields.io/twitter/follow/siggravitas?style=social) -[![](https://dcbadge.vercel.app/api/server/PQ7VX6TY4t?style=flat)](https://discord.gg/PQ7VX6TY4t) -[![Unit Tests](https://github.com/Torantulino/Auto-GPT/actions/workflows/unit_tests.yml/badge.svg)](https://github.com/Torantulino/Auto-GPT/actions/workflows/unit_tests.yml) +[![Discord Follow](https://dcbadge.vercel.app/api/server/PQ7VX6TY4t?style=flat)](https://discord.gg/PQ7VX6TY4t) Auto-GPT is an experimental open-source application showcasing the capabilities of the GPT-4 language model. This program, driven by GPT-4, chains together LLM "thoughts", to autonomously achieve whatever goal you set. As one of the first examples of GPT-4 running fully autonomously, Auto-GPT pushes the boundaries of what is possible with AI.