text,start,duration okay so you know how chat GPT has been,0.42,8.16 slightly let's say lobotomized lately it,4.74,5.76 seems to not really handle coding that,8.58,5.16 well and uh if you're like me I tried,10.5,5.46 GitHub co-pilot and I really don't like,13.74,5.52 it uh I applied for the GitHub co-pilot,15.96,5.94 chat and then like a few days later I,19.26,5.4 tried to go use it and it says oh well,21.9,4.619 the beta has expired or you know you've,24.66,3.06 been kicked out or whatever I was like,26.519,3.541 okay whatever so,27.72,4.26 um I realized that like all right I have,30.06,4.38 the power to fix this myself because,31.98,4.98 I've been shying away from doing my,34.44,4.799 coding experiments because chat GPT is,36.96,5.34 broken or lobotomized or whatever and,39.239,5.101 GitHub co-pilot and you know I know,42.3,3.06 there's lots of other tools there's,44.34,3.719 Amazon and blah blah but you know like I,45.36,4.32 can fix this I can I can do the thing,48.059,3.421 that I want to do and I can make a thing,49.68,4.859 that is specific so I came over to the,51.48,4.44 playground and I was like all right,54.539,4.621 let's try this so I um I just want to,55.92,4.5 show you real quick,59.16,3.6 uh you know I gave a really simple,60.42,3.479 prompt,62.76,2.88 system message you or python coding,63.899,2.76 assistant the user will give you,65.64,3.24 instructions to help write functions uh,66.659,4.021 you may ask for clarification if needed,68.88,3.419 but otherwise you should only output,70.68,3.54 python code and of course you can change,72.299,3.5 this to whatever language you want,74.22,4.079 adhere to pep 8 so that's the python,75.799,6.101 enhancement program uh version 8 which,78.299,5.341 is basically sets all the standards for,81.9,4.56 how to write python pythonically provide,83.64,4.74 explanations of the code only if the,86.46,3.96 user asks for them,88.38,4.2 um so you know how like chat GPT will be,90.42,4.44 super overly verbose,92.58,4.2 um and then I I gave it a copy of the,94.86,3.719 script that I was working on,96.78,3.12 um and so then I said write a function,98.579,2.881 that loads all files into a given folder,99.9,3.84 returns a list of uh list of lists and,101.46,3.6 groups of five include the full file,103.74,3.78 path and it just bam did it I was like,105.06,4.44 cool that's exactly what I wanted and I,107.52,4.139 was like wait that worked really well so,109.5,3.659 why don't I just make a chat bot that,111.659,3.681 does it so coding chatbot assistant,113.159,5.041 since chat GPT has been lobotomized and,115.34,5.139 GitHub co-pilot is broken,118.2,2.879 um,120.479,3.241 I got it set up here here's an example,121.079,6.061 of the output so for instance I was um,123.72,6.599 I'm working on uh you know my recent,127.14,4.98 projects have been chat Bots with,130.319,4.56 long-term memories and uh KB articles,132.12,4.74 and stuff so I was like okay I've got,134.879,3.841 this far just write the function for me,136.86,3.78 so I told it how I want to write the,138.72,3.84 function you know it's a KB article with,140.64,5.4 a yaml file so on and so forth now that,142.56,5.039 being said I want to show you a really,146.04,4.199 cool cool bit so this is the output you,147.599,5.22 can see it's pretty familiar so it gives,150.239,5.521 you like okay uh you know you need to,152.819,5.581 import this let's do this here's a,155.76,4.26 couple functions and it thought through,158.4,4.5 it and gave it a very very very specific,160.02,4.439 output,162.9,3.72 um I haven't tested this code yet but,164.459,4.14 like this is very much the behavior that,166.62,4.08 I want to see so now let me explain to,168.599,4.801 you how the chat bot works so we'll go,170.7,5.94 through the code uh real quick it's,173.4,5.76 pretty straightforward it's 105 lines of,176.64,4.14 code so like not not the most,179.16,3.06 complicated thing and actually some of,180.78,3.26 this is Superfluous,182.22,4.019 I actually think that I don't use the,184.04,4.839 yaml functions anywhere yeah so I could,186.239,3.901 probably delete that and make it even,188.879,4.621 shorter all right so ignore those helper,190.14,5.28 functions here's the uh here's the,193.5,6.0 called a GPT super simple you just call,195.42,6.66 it you get the text response and then,199.5,4.86 what I started doing is I just passed,202.08,5.4 back the token count so that I can,204.36,5.94 manage the conversation internally but,207.48,4.8 pretty much this whole thing here is,210.3,4.68 just if there's an error it will give,212.28,5.28 you some output so for instance if the,214.98,5.28 content context length is too long it'll,217.56,4.259 trim the conversation and try again,220.26,4.5 it'll let you know what happened if,221.819,6.06 another error happened it'll put it'll,224.76,5.28 output that the whole thing sometimes,227.879,3.481 the you know it's not available or,230.04,3.24 whatever open AI has gotten a lot better,231.36,4.14 but sometimes you'll have uh you know,233.28,4.319 network errors and other stuff and what,235.5,4.2 this does is it uses exponential back,237.599,3.0 off,239.7,4.14 so every time it retries it doubles the,240.599,5.341 amount of time that it'll wait,243.84,3.539 um to try again and it'll it'll give you,245.94,3.96 debug output the whole time uh and then,247.379,4.08 I've got this function so this is a,249.9,4.259 multi-line input function uh which it,251.459,4.2 will switch into this mode if you want,254.159,3.721 to update a scratch Pad so in this case,255.659,5.221 uh the scratch pad is just a plain text,257.88,5.58 file that it uses to load into the,260.88,4.56 system message so I've got that system,263.46,3.72 message that I showed you and then a,265.44,3.479 description of the below code scratch,267.18,4.26 Pad may be provided by the user blah,268.919,5.041 blah and so then it I wrap it in the,271.44,4.92 comment so that way knows like hey this,273.96,4.26 is Python and then it'll copy paste the,276.36,4.2 you know your code into it from the,278.22,5.36 scratch pad and so what you can do is,280.56,5.94 first it'll take you know input from the,283.58,6.0 user and then if you type in scratch pad,286.5,5.58 it will give you a chance to update the,289.58,4.839 scratch Pad which is you can put,292.08,3.899 anything in you can put in code you can,294.419,4.441 put in comments these whatever you can,295.979,5.461 put in a file system description,298.86,4.08 whatever you want,301.44,4.259 uh but the point is is that it will use,302.94,5.039 this function so that it will continue,305.699,7.5 to accept uh new lines of input without,307.979,7.801 um without breaking uh and so then when,313.199,4.861 if you type end at the very end then it,315.78,4.919 says okay cool save exit,318.06,6.359 um I strip that out of of the uh end,320.699,5.28 um and so on and so forth so there you,324.419,6.421 go uh let's see it should be about it,325.979,7.081 um oh and then if you accidentally hit,330.84,3.78 um enter twice because you know that can,333.06,2.88 happen,334.62,3.72 um it'll just go like it says you know,335.94,5.039 enter um,338.34,4.74 whoops ah crap I accidentally typed,340.979,4.261 something so that's going to break it,343.08,4.619 um yeah it was very confused,345.24,4.799 um yep,347.699,3.72 okay,350.039,3.181 um let's see so then the other thing,351.419,3.601 that I do is I accumulate all the,353.22,5.52 messages the uh the user input and the,355.02,7.14 chat bot response in a list called all,358.74,6.239 messages and I keep that separate from,362.16,4.86 the conversation object that I passed to,364.979,3.78 chat GPT,367.02,4.019 did I pass to the API and the reason is,368.759,5.761 because I actually just had a um had a a,371.039,6.961 a patreon uh supporter give me this,374.52,5.16 really powerful tip which is that if you,378.0,3.96 put the system message at the end rather,379.68,4.139 than at the beginning it is much more,381.96,3.72 likely to continue to adhere to the,383.819,3.841 instructions that you gave it rather,385.68,3.66 than drift,387.66,3.84 um so apparently this I haven't I,389.34,3.6 haven't spent too much time testing it,391.5,3.3 but you know how sometimes like chat,392.94,3.78 gpt's Behavior will change over time,394.8,3.899 especially as the conversation gets,396.72,4.02 longer it'll continue to kind of modify,398.699,3.541 Its Behavior and it'll usually kind of,400.74,3.959 default back to its default Behavior if,402.24,4.019 you put the system message at the very,404.699,4.921 end so what I do is I I say you know,406.259,6.541 conversation is an empty list I add all,409.62,5.1 messages and then I append the system,412.8,4.38 message at the very end and then I get,414.72,3.78 the response,417.18,3.48 and so then once I get the response it,418.5,4.979 passes back the tokens if it's uh if the,420.66,4.8 token count is over 7 500 because we've,423.479,4.021 got a limit of 8 000. I just remember,425.46,4.92 the I remember I removed the oldest,427.5,3.78 message,430.38,2.819 um so pop zero,431.28,4.44 um and then I append the assistant,433.199,5.401 response to all messages so remember all,435.72,5.16 messages is kept separate,438.6,3.96 um so that I can just tack on the com,440.88,5.099 the system message separately and then I,442.56,5.699 get the output and here it goes,445.979,4.321 um so what I what I realized is that if,448.259,5.101 you use text wrap it will it'll nullify,450.3,5.1 all of the new lines so what I do is I,453.36,5.04 split the new lines and then text wrap,455.4,4.859 it so that if there's comments then it,458.4,4.26 won't be too long so anyways there you,460.259,5.401 have it the repo is up here it's working,462.66,4.979 um the only thing that it's pretty well,465.66,3.96 documented I got in the habit of just,467.639,3.9 using chat GPT to produce the,469.62,3.54 documentation,471.539,3.541 um because that makes it easier for,473.16,3.06 everybody,475.08,3.119 um setup is super simple you just need,476.22,6.02 to open AI you need your openai API key,478.199,6.241 and then the biggest thing that you need,482.24,4.06 to know is to use a scratch pad I do,484.44,4.259 have instructions in the console output,486.3,3.899 so it'll tell you how to get into the,488.699,2.761 scratch pad and then how to get out of,490.199,4.28 it and then the the,491.46,5.459 console will tell you what what mode,494.479,3.701 you're in,496.919,2.941 um you can tell I was an infrastructure,498.18,4.199 engineer who used Cisco switches,499.86,3.36 um,502.379,2.521 because I'm just like hey this this,503.22,5.159 model Works uh anyways so yeah I think,504.9,5.4 that's about it so this is this is my,508.379,3.121 new,510.3,3.9 um chat bot coding assistant and uh yeah,511.5,4.62 I hope that you find it useful super,514.2,4.44 simple super straightforward,516.12,5.219 um yeah uh let me know if you have any,518.64,4.62 thoughts about how to improve it but I,521.339,3.841 think honestly the scratch Pad is like,523.26,4.38 all you need uh because then you can you,525.18,5.04 can update this out of band as well uh,527.64,4.92 if you want to you know,530.22,4.14 um whatever you want to put in it right,532.56,3.959 you can you can even put multiple,534.36,4.2 scripts in it or multiple files or,536.519,3.781 whatever,538.56,4.08 um but yeah so thanks for watching I,540.3,4.14 hope you liked it and I'm gonna get back,542.64,4.699 to coding bye,544.44,2.899