#SudoLang in a Nutshell

54 messages Β· Page 1 of 1 (latest)

digital hatch
#

SudoLang in a Nutshell

Roleplay as a tutor teaching SudoLang, following the instructions below:

ConstraintExample1 {
  /*
  Requirements are a special kind of constraint that throw errors when the user tries to perform an invalid action. Requirements are constraints on inputs.

  Imagine you're building a scheduling app for a conference. You have 4 stages. You need to ensure that you don't book more than 4 speakers in the same timeslot. Here's how you might do that:
    */
  State {
      Stages [1,2,3,4]
  }
  Constraints {
        Require the number of overlapping speaker timeslots to be less than the number of available stages.
    }
}

ChatbotConstraintExample {
  /* Output constraints tell the AI how to constrain its output, rather than constraining user inputs. For example, if you want a chatbot to use a young adult vocabulary: */
  Constraints {
    Avoid mentioning constraints.
    Vocabulary: Young adult
    Tone: Playful.
     Use emojis when it's fun.
    Use *emotes* for fun.
  }
}

Scoreboard {
  /* Constraints can also be used to synchronize state */
  State {
    Score
  }
  Constraints {
    Increment score with each correct user answer.
   }
}

SudoLangInANutshell {
  Scoreboard
  Lessons {
    What is SudoLang? {
      SudoLang is a pseudocode programming language that combines the freedom and ease of use of natural language with the sound structure of block scopes, functions, variables, and constraint-based programming. It's easy to learn and use, and all sufficiently advanced language models understand it without any special prompting.
    }
    Features {
      Constraint-based programming using constraints to guide AI outputs (rather than user inputs), and keep state in synch automatically with constraint solvers.
      Pattern matching with semantic matching.
      Function composition with the pipe operator: `|>`
      If expressions
      Supports all common programming language and math operators.
    }
    Anatomy {
      A typical SudoLang program consists of:
        Preamble - The program title followed by a one-paragraph introduction. It usually takes the form "Roleplay as [expertise]. Your job is to [short job description] by following the instructions:"
      Supporting functions or interfaces
      Main interface - Typically consists of state, constraints, methods and/or commands
    Initializer - a first command or action to kick the program off.
    }
    Constraints - Constraint based programming allows you to define relationships between different parts of the state that are automatically kept in-synch by the AI. Think of a constraint as an instruction that guides the output produced by the AI. The best constraints declare what you want rather than spell out step-by-step how to do it. For example, you can make a constraint that says all employees must be paid a minimum salary, and define a solver that automatically awards raises as needed if you raise the minimum salary.
  }
  /v | vocab - Vocabulary review
  /f | flashcards - Play the vocab flashcard game
  /c | challenge - Get a SudoLang coding challenge
  /e | expand [topic] - Get a deeper explanation of the given topic
  /l | lessons - Show lesson list
  /s | score - Show student score
  /h | help - List these commands
}

welcome()

/help
#

If you want this to work even better, paste the SudoLang spec first, then this prompt.

blazing canopy
#

@digital hatch I was actually exploring Sudolang since my previous message. I used the below from the medium page:

Teach Yourself SudoLang
Copy and paste the SudoLang specification into the ChatGPT (GPT-4) prompt.
Copy and paste the teach program into the ChatGPT SudoLang prompt.
Type teach(SudoLang) in the prompt, hit enter, and enjoy!

digital hatch
#

woohoo πŸŽ‰

#

warning: all AI models hallucinate. Sometimes it will teach you about features that aren't needed in SudoLang, or syntax that isn't required (e.g. it just tried to teach me let foo = bar but while that WORKS in SudoLang, it's NOT a SudoLang keyword, and it's not required.

#

If you don't see it in the docs or examples, it's probably hallucinating. πŸ€£πŸ™ˆ

blazing canopy
#

I had one application in mind. I have some very long scripts in R (still within the character limit) that I want to convert into python. I used the below

$R_code = '''
<R Code goes here>
'''

transpiled_python_code = transpile(targetLang="python", source=R_code);

log("Python code:", transpiled_python_code);

Sometimes the response gets stuck halfway of the code, so I combined it with continue(). For some scripts it worked well. But for some others with a lot of functions, it's very inaccurate. Might be a ChatGPT thing.

digital hatch
#

This "In a Nutshell" program will teach you about preambles. I don't think the teach program will.

blazing canopy
#

yes

#

With GPT 3.5 I wouldn't even bother. It's way off even for simple scripts in my exp.

digital hatch
#

you can usually just do:

"""
code to transpile
""" |> transpile(target language, any style hints you want to include)

blazing canopy
#

It's the same thing right? Just smaller code?

digital hatch
#

or even:

Style Guide =
"""
full style guide
"""
}

"""
code to transpile
""" |> transpile(target language, style guide)

digital hatch
blazing canopy
#

ok. Do u have a prompt where I can possibly put code in parts and get output via multiple iterations?

I believe:

  1. It would be more accurate.
  2. I can get around the character limit.
digital hatch
#

also, try just using <space><enter> when it cuts off and you want it to continue

blazing canopy
#

ok

digital hatch
#

if it makes a mistake, try "revise <thing to revise>"

blazing canopy
#

ok

blazing canopy
#

Thanks for the prompt @digital hatch πŸ˜πŸ‘Œ

clever belfry
#

Interesting

spark spear
#

@digital hatch Not a programmer here.... but when looking at the "SudoLang "code" samples you posted it seems as if even noobs like me (digital marketing specialist) can understand how to write code using natural language expressions? Is that what SudoLang does??

blazing canopy
spark spear
blazing canopy
digital hatch
# spark spear Got it - so its more adapted to 'prototyping', not to achieve a final product?

I am a professional software engineer. I have stopped writing code in any other language. For the last month, I have only been writing code in SudoLang, and then if I need Javascript or Python, I use the inferred transpile(target language) function in SudoLang.

Also, a lot of AI-first application features can ONLY be built using things like ChatGPT. For all of those tasks, I use SudoLang exclusively.

blazing canopy
#

Essentially it follows MVC architecture, thus the multiple files.

digital hatch
# blazing canopy Have you used sudolang to make code that can span across like say..a dozen files...

Yes - generally it can't generate that much without making a mistake or 10. The examples repo contains a codebot that will use TDD to generate unit tests that you can run to automatically keep the AI on track. You can write a script in Python or JavaScript (or have the AI write one for you) that takes output from the ChatGPT API and runs it in a virtual machine on your computer (virtual machine because you probably don't want to give an unsupervised AI direct editing access to do anything it wants with your computer).

You can create utilities to create files in the current directory and run the unit test suite with every change the AI makes.

#

With each file, the AI should stop and try to run the tests before continuing, taking the test output and feeding it back into the AI in the next prompt.

#

Warning: It is still likely to get stuck once in a while, so make sure there's a way for you to inject messages into the loop.

spark spear
digital hatch
#

πŸŽ‰

blazing canopy
fallen oriole
#

@digital hatch great work with SudoLang! Feels like I’m witnessing the start of the democratisation of AI πŸ˜‰

digital hatch
#

πŸŽ‰

digital hatch
#

That "macro" is just a while loop - documented in the docs. What is the difference between "macros" as you've defined them there and functions?

blazing canopy
#

necroposter!!!!!!!!!!

torpid snow
#

Awesome prompt. Thanks for this.

fallen oriole
#

Hey mate, just wondering if sudolang works with langchain? I mean, if I β€œteach” it some concepts, does the langchain agents draw from this rules / concepts as it tries to solve for my prompt message?

keen sky
#

\

digital hatch
#

I recommend using Yaml instead of json - convert to json in python. You'll save a boatload of money on production apps, and your app response times will improve a lot since there are fewer tokens to parse.

tired quartz
#

Hi, just want to ask because in the beginning you mention that it might be better to put the sudolang specs first. But where can I find the specs?

#

I assume there's a docs? But I'm having difficulty locating it. Cause I see you mentioning it "... If its not in a doc..." and yeah. Can you point me to it?

thorny fulcrum
digital hatch