Your First Kedi Program
Let's write a simple program to understand the basic syntax of Kedi.
The "Hello World"
Create a file named hello.kedi:
Running the Program
Line-by-Line Breakdown
| Part | Meaning |
|---|---|
[name: str] |
Declare variable name of type str |
= |
Assignment operator |
`...` |
Python code block (executed inline) |
| Part | Meaning |
|---|---|
= |
Return statement |
<name> |
Substitute the value of name |
Adding an LLM Call
Now let's make it interesting by adding an LLM-generated greeting:
hello_ai.kedi
@greet(name: str) -> str:
Create a warm and friendly [greeting] for <name>.
= <greeting>
[user] = `input('Your name: ')`
= <greet(<user>)>
This time:
- The
@greetprocedure sends a prompt to the LLM - The LLM generates a personalized greeting
- The output is captured in
[greeting]and returned
Defining Procedures
Procedures are the building blocks of Kedi programs:
Procedure Anatomy
@say_hello(name: str) -> str:
│ │ │ │ │ │
│ │ │ │ │ └─ Colon starts body
│ │ │ │ └────── Return type
│ │ │ └──────────── Parameter type
│ │ └────────────────── Parameter name
│ └───────────────────────── Procedure name
└────────────────────────────── @ prefix (required)
Next Steps
Now that you understand the basics:
- Learn about Procedures - Master procedure definitions
- Variables & Types - Explore the type system
- LLM Integration - Deep dive into LLM calls