Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce generateContent task #1174

Merged
merged 3 commits into from
May 17, 2023
Merged

introduce generateContent task #1174

merged 3 commits into from
May 17, 2023

Conversation

PacoVK
Copy link
Collaborator

@PacoVK PacoVK commented May 12, 2023

What this PR is about

It introduces a new task called generateContent. It's basically an integration to openAI. You can put comment blocks into your input file like

////
AI: write something short about habits
////

which will then be fully replaced by the text provided through openAI.

Disclaimer: You'll need an API key from openAI in order to make this task work

All Submissions:

  • Did you update the changelog.adoc?
  • Does your PR affect the documentation?
  • If yes, did you update the documentation or create an issue for updating it?

@netlify
Copy link

netlify bot commented May 12, 2023

Deploy Preview for dtc-docs-preview ready!

Name Link
🔨 Latest commit 597a9d9
🔍 Latest deploy log https://app.netlify.com/sites/dtc-docs-preview/deploys/6463dff7745e510008b96b42
😎 Deploy Preview https://deploy-preview-1174--dtc-docs-preview.netlify.app/015_tasks/03_task_generatecontent
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

Copy link
Member

@rdmueller rdmueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I like the idea to use openAI as writing buddy. I also think this is an interesting start.
I wonder if we could make it more interactive and use more priming.

For instance, it could make sense to add some primer to the config like this (which I often use):

when you create AsciiDoc output
- format it as code (so I can copy and paste it)
- use '=' for headlines
- start with level '==' as headline
- write each sentence or half-sentence in a new line
- use attributes for URLs and define them at the start of the document

It could also make sense to use the AI-statements in a dialog/session, so that one generated text block build upon the last ones... (or maybe is this already implemented? Didn't check the source)

Config.groovy Show resolved Hide resolved
@PacoVK
Copy link
Collaborator Author

PacoVK commented May 14, 2023

Yes, indeed i also thought about having a more interactive implementation, but was not really sure about the capabilities with Gradle here.
The current task is quite bare-bones but if we know how the "writing buddy" could look like, we can improve the user experience here.
It would also be awesome to let the user decide whether the openAI suggestion is acceptable or if the user wants to tweak the given input.

@mh182
Copy link
Collaborator

mh182 commented May 15, 2023

What I really would need is the feature to rephrase existing paragraphs. Would this also work with this task?

If yes, could you add an example how this could be done?

Checking the task documentation, I asked myself, "Why do we show the task's source code?". The target group of the task documentation is a user who usually doesn't need to know about the internals.

IMHO it makes the page unnecessarily long and harder to digest.

@rdmueller
Copy link
Member

@mh182

IMHO it makes the page unnecessarily long and harder to digest.

yes, but another topic. My goal is to remove the source code and hide it behind a link or tab

@rdmueller
Copy link
Member

rdmueller commented May 15, 2023

What I really would need is the feature to...

I think we should consider this as experimental and I guess we soon will have plugins for our IDEs etc. to solve these feature problems. Let's give it a try and see how this feature evolves...

Copy link
Member

@rdmueller rdmueller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to see this in action...

scripts/generateContent.gradle Outdated Show resolved Hide resolved
Copy link
Collaborator

@mh182 mh182 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. I like it.

Apart from passing all configuration parameters through to the command line.

scripts/generateContent.gradle Outdated Show resolved Hide resolved
@PacoVK
Copy link
Collaborator Author

PacoVK commented May 15, 2023

Concerning the implementation details as part of the docs, i started a discussion, to find out how we can handle this in the future #1175

@PacoVK
Copy link
Collaborator Author

PacoVK commented May 15, 2023

Hm, somehow the DtcwOnPowershellSpec is broken on Java 17... i have no glue tbh it just stopped working :D Does this Test run intentionally on Linux environment?

@rdmueller
Copy link
Member

Yes, it intentionally runs on linux with powershell installed

@PacoVK
Copy link
Collaborator Author

PacoVK commented May 15, 2023

Yes, it intentionally runs on linux with powershell installed

Ah, then there is this part missing in the default-build.yml right?
In the dtcw.ps1-tests.yaml there is

      - name: install powershell
        shell: bash
        run: |
          if [ "$RUNNER_OS" == "Windows" ]; then
            echo "pwsh already installed"
          else  
            sudo apt-get install -y wget apt-transport-https software-properties-common
            wget -q "https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/packages-microsoft-prod.deb"
            sudo dpkg -i packages-microsoft-prod.deb
            rm packages-microsoft-prod.deb
            sudo apt-get update
            sudo apt-get install -y powershell
          fi

@PacoVK
Copy link
Collaborator Author

PacoVK commented May 15, 2023

i am super confused about the behaviour of the test suite and how it is breaking

@rdmueller
Copy link
Member

I guess you are right. let me fix this...

@rdmueller
Copy link
Member

seems to work now

@mh182
Copy link
Collaborator

mh182 commented May 16, 2023

The patch is fine.

I have one "minor concern" about the configuration option openAI.token. As far as I understood this would be the user's personal OpenAI token.

Do we really want to nudge the user to put this in the configuration file which will end up in the revision control system?

When collaborating in a team, most probably each user has its own API key.

My suggestion would be to make the openAI.token a parameter which is provided by the command line only. Not within the configuration template.

@mh182
Copy link
Collaborator

mh182 commented May 17, 2023

@PacoVK Would it make sense to write a test for this task?

The problem I see here is which API key do we use to run the test. Or the test would mock out the call to the OpenAI API and test the rest.

@PacoVK
Copy link
Collaborator Author

PacoVK commented May 17, 2023

Would it make sense to write a test for this task?

Yes, it always makes sense to test :D But as you figured out this would mean to have a test token and i did not yet discover a open source program on openAI site.
Mocking would mean implementation refactoring into groovy files. I would not open this box as well here, but should definitely be a follow-up.

@mh182 mh182 merged commit 5204a76 into docToolchain:ng May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants