climate-tech-handbook / data-magic

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

issue with printing output in terminal after adding functions to app.py, content_generator.py and generator_utils.py #21

Open howard989 opened 1 year ago

howard989 commented 1 year ago

I have added some new functions for adding tags, inserting photos, and adding new page sections in three different files: app/app.py, app/models/content_generator.py, and app/utils/generator_utils.py. However, when I run the program using flask run, there is no output printed in the terminal.

I would greatly appreciate it if someone, particularly Wesley, could take a look and help me troubleshoot the issue.

Here is the link to my branch: https://github.com/howard989/data-magic-h/tree/add-functions.

Thank you very much.

bigolboyyo commented 1 year ago

Very nice! looking at code here in min, gonna copy this down and play around with it.

My first thoughts are this: It is setup as an api atm, so I was forcing the creation through a @before_first_request decorator in the app.py.

So you will need to refresh to make that call.

2nd thought is, I'll look to make sure we have print statements in the right places for terminal output.

Are the editing functions actively working at the moment?

futuresoup commented 1 year ago

I want to ask before we go to far:

In reference to #14 - is this the right approach for batch updating content.

For example: how will this solution know which part of the page to update with a Markdown snippet?

bigolboyyo commented 1 year ago

I need a little time to experiment for a definite answer, but my findings so far seem to be postive.

This should allow us to manually insert new content at specific lines. image

@howard989 Are these tags meant for SEO purposes? Or are these the template keys? (I'm just scanning through the code atm) image

Comments make these self explanatory image

bigolboyyo commented 1 year ago

For edit_file we may have issues with the end_line. We need to make sure that if we don't provide one it just auto fills in the correct spacing and doesn't mess with any of the other content. (Testing will confirm this for me)

futuresoup commented 1 year ago

Let's confirm: rather than very specific functions like "adding tags" - the focus ought to be adding any sort of generic block.

For example, in MKDocs, there is an entire block at the top of the page called "front matter" where you can more than just add tags. There are lots of configuration options that would be useful to batch update across many pages.

---
title: My Document
summary: A brief description of my document.
authors:
    - Waylan Limberg
    - Tom Christie
date: 2018-07-10
some_url: https://example.com
---
bigolboyyo commented 1 year ago

template: custom.html

We could write custom html as templates for each page. The rest of that is all metadata. We are using the "Material" theme for MKDocs. So right now we are just directly uploading a bunch of markdown files right? And it takes those markdown files and applies them to our theme.

We could use that metadata to flush out some of the page for sure.

image image

MKDocs allows you to pass custom HTML templates as docs, but if we are using a pre built theme and just uploading markdown, we just don't really need this. Unless you want to focus more on frontend development and designing the front (I think that should come later if at all)

howard989 commented 1 year ago

Thank you! I refreshed it, and I tried running your original code and it printed output in the terminal. However, when I added some functions to the code, it seemed to get stuck in the terminal and didn't print anything, running indefinitely. This makes it difficult to determine if the edited functions are working or not.

bigolboyyo commented 1 year ago

@howard989 It sounds like there's a loop somewhere, or maybe it's trying to call an OpenAI completion at the same time and slowing it down?

howard989 commented 1 year ago

These tags are not related to SEO purposes. The add_tags function takes a file path and a list of tags as input, and inserts them at the top of a markdown file. This function is used to add tags metadata to the markdown file, which can be used by a static site generator or other tools to categorize and organize content.

bigolboyyo commented 1 year ago

@howard989 the prompt_keys are now set based on the actual template.md (always ignoring the {topic} for prompting)

Next step is to add a 'exclude_keywords' param so if you want to use custom templates you just pass the keywords to ignore.

image

image

futuresoup commented 1 year ago

What is the status of this @bigolboyyo @howard989?

Should I put it on the Next Release Board? Or Future Releases Board?

howard989 commented 1 year ago

I am unable to find the codes in those files. Could you please let me know where they are currently located.