climate-tech-handbook / data-magic

Scripts and other fun tricks to enhance the site
MIT License
10 stars 5 forks source link

Optimize script and "stack guide" #3

Closed futuresoup closed 1 year ago

futuresoup commented 1 year ago

via Slack:

As far as the code goes, the simple pyscript is great for generating the files. My goals for the day is to have a basic "stack" guide for us. Get together a list of all the technologies we are using and plan to use. Just so everyone knows what and where to reference our technologies. And then a simple prompting guide for general knowledge.
After that, for the script I very desperately want to add a little error handling. A "are you sure" you want to run this script? And a check to make sure we don't accidentally overwrite files or loop through more than once.
Then optimizing the requests. Although it may not be a huge issue, if we have to update on a continual basis down the road it'll be costly. Currently we are making 4 separate requests for each section page. by doing something like this can greatly reduce the cost. even if we split this up because we find the data is more accurate in smaller chunks. But the better prompt engineering will help. You can give gpt json objects as templates that it'll return in code blocks as json.
    content = generate_content(prompts, page['Topic'])

    # Split the content by sections
    sections = content.split("\n\n")
    progress_made = sections[0]
    lessons_learned = sections[1]
    challenges_ahead = sections[2]
    best_path_forward = sections[3]
That was a lot, these are just all of my initial findings and observations so far. I'll get to work and be available all day.

https://climatetechhandbook.slack.com/archives/C055U2PTBUY/p1682968864565519)

also I've been writing so much JavaScript recently that switching back to python is gonna be funny

https://climatetechhandbook.slack.com/archives/C055U2PTBUY/p1682968935405669)

def confirm_action():
    response = input("Are you sure you want to generate content for all topics? (yes/no): ")
    return response.lower() == 'yes'

if confirm_action():
    for page in file_info:
        # (Content generation code here)
else:
    print("Aborted.")

https://climatetechhandbook.slack.com/archives/C055U2PTBUY/p1682968948375849)

Just some simple sketching to give an idea
bigolboyyo commented 1 year ago

Pull request: https://github.com/climate-tech-handbook/data-magic/pull/2

futuresoup commented 1 year ago

@bigolboyyo looks great, just need it in the primary repo (via my PR comment)

bigolboyyo commented 1 year ago

On it.

Discussion created: https://github.com/orgs/climate-tech-handbook/discussions/

bigolboyyo commented 1 year ago

I decided on Field guide instead apparently lol. Pull request made to main. https://github.com/climate-tech-handbook/climate-tech-handbook/pull/5

I'll make another here when I add the error handling