# Moderation tool for formatting code with AI

**URL:** https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980
**Category:** Feature
**Tags:** ai
**Created:** [January 20, 2025, 8:35am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980 "2025-01-20T08:35:38Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 20, 2025, 8:35am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/1 "2025-01-20T08:35:38Z")

</div>

OpenAI forum is struggling with the volume of users who don’t format their code. One of the community’s Regulars has raised this in the Lounge.

> [@Diet](#):
>
> A lot of users don’t know how to use the triple ticks properly, which makes reading code in the forum a pain in the butt.
> 
> I was thinking it would be nice if you allowed (trusted) TL-3s to edit user posts explicitly to fix code blocks. But that comes with a rat’s tail of problems that you may not wanna deal with.
> 
> However, TL-3s already have the privilege to trigger AI tools in the forum. One would think it wouldn’t be that difficult to implement a button that only TL-3s+ (maybe TL-2+?) had access to, that sends the post to a model that just fixes the backticks, and applies that change.
> 
> My suggestion would be to give privileged users a button in the post menu (or maybe in the flag menu?) that gets the post sent to a model for backtick fixing, and perhaps another button that allows the reversion of that change if something went wrong.
> 
> Thanks for coming to my ted talk!

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [January 20, 2025, 8:53am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/2 "2025-01-20T08:53:45Z")

</div>

There is already possibility to publish AI explains, change times, proofread… sure, none of those happens exacly right on published text, but still. This is just a modification of same principle 😏

A plugin that allows a group to add three ticks before and after chosen area.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 20, 2025, 8:54am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/3 "2025-01-20T08:54:32Z")

</div>

I would have a crack at this myself, but it’s hosted.

---

<div class="post-metadata">

### Author: ![Jagster](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jagster/32/192154_2.png) [@Jagster](https://meta.discourse.org/u/Jagster)
#### Post date: [January 20, 2025, 8:55am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/4 "2025-01-20T08:55:06Z")

</div>

Yeah… no happiness to install plugins.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 20, 2025, 10:28am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/5 "2025-01-20T10:28:18Z")

</div>

We could make an automation that just does this

Something like if you have 8/10 confidence that source code needs formatting, just format it

There is also the theme component that asks people to format code which we could install

---

<div class="post-metadata">

### Author: ![diet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/diet/32/482280_2.png) [@diet](https://meta.discourse.org/u/diet)
#### Post date: [January 20, 2025, 11:07am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/6 "2025-01-20T11:07:58Z")

</div>

> [@sam](#):
>
> There is also the theme component that asks people to format code which we could install

We have a lot of people that seem to be new to coding in general, and some of them make a good effort.

Sometimes it’s little things, like the user forgetting (or not knowing how to) set the language

```xml
<hello>

```

```plaintext
<hello>

```

sometimes they paste code that contains backticks that end up not escaping properly, so they just give up I suppose (I couldn’t find the example I was thinking of rn)

In these cases, it’s probably not super helpful, and IMO onboarding new users should be as easy as possible (it’s likely already overwhelming as it is)

* * *

> [@sam](#):
>
> Something like if you have 8/10 confidence that source code needs formatting, just format it

The idea of giving senior users a button would be to control inference cost/usage with a more powerful model if that’s an issue or concern.

Anyways, thanks for considering this!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 20, 2025, 10:20pm UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/7 "2025-01-20T22:20:33Z")

</div>

An interesting thing we could quite easily do is allow certain groups access to certain “AI Helper” features on posts.

Then we could add an “AI Helper” task here and unlock it to TL3 on your forum.

 ![The image shows a formatting toolbar with an option to "fix source code" highlighted by an arrow. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/c/f/9/cf9d6ee72229d2928257c805a004edd6dff63b4b.png)

This can work quite well, downside though is that it has to generate a lot of tokens so it can be extremely slow.

Ideally we would need to teach helper to trade in “diffs” so it can generate significantly less tokens in cases where there is a lot of source.

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 20, 2025, 11:41pm UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/8 "2025-01-20T23:41:20Z")

</div>

Well. OpenAI have “Predicted Outputs” feature which would be perfect for this use case, I believe:

> **[Introducing Predicted Outputs](https://community.openai.com/t/introducing-predicted-outputs/1004502?u=merefield)**
>
> Dramatically decrease latency for gpt-4o and gpt-4o-mini by providing a reference string. Speed up: Updating a blog post in a document Iterating on previous model responses Rewriting code in an existing file, like with Exponent in this video,...

(I suspect this is how their Canvas tooling works)

I appreciate that may be somewhat OpenAI specific atm, but no doubt others will follow.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [January 22, 2025, 1:38am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/9 "2025-01-22T01:38:49Z")

</div>

Not quite, I tested it out and it is expensive and is certainly not perfect:

> **[Using predicted outputs for proofreading](https://community.openai.com/t/using-predicted-outputs-for-proofreading/1098128)**
>
> I decided to give predicted outputs a quick test run for “text proofreading”. It seems like a good fit because the majority of the text is unchanged. However: It increases costs Speed benefit is good but not earth-shattering It has an...

I would say a “diff” based approach probably has the most chance of working.

Something like this may work (JSON output looking for markers) [Crafting Concise Prompts for Markdown Formatting - AI Conversation - Discourse Meta](https://meta.discourse.org/discourse-ai/ai-bot/shared-ai-conversations/0qF2fpDR-we8Dr2EEmjwdQ)

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [January 22, 2025, 9:17am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/10 "2025-01-22T09:17:59Z")

</div>

That’s unfortunate. I see you’ve shared your feedback with OpenAI 👍. Definitely seems like an immature feature that is not yet living up to billing (ahem)

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [April 3, 2025, 6:08am UTC](https://meta.discourse.org/t/moderation-tool-for-formatting-code-with-ai/347980/11 "2025-04-03T06:08:16Z")

</div>

We could swing something like this with persona triage and a custom tool

Persona triage (gpt 4o mini) → custom tool → llm to fix (gpt 4o) → api to submit edit

The challenge though is how comfortable are we allowing the llm to apply the edit with zero hallucinations?

A possibility could be having the llm to fix call return 2 line numbers (where code starts and where it ends) and then use that information to add backticks, that way there is a lot less risk of destruction.

Will have a further think about this, but I do think something is workable here.
