docs: add code example for /code command

This commit is contained in:
Paul Gauthier (aider) 2024-08-11 09:57:51 -07:00
parent 32f771eb31
commit b9b5666a75

View file

@ -13,7 +13,7 @@ Aider has 3 different chat modes:
- `help` - Aider will answer questions about using aider, configuring, troubleshooting, etc. - `help` - Aider will answer questions about using aider, configuring, troubleshooting, etc.
By default, aider starts in "code" mode. As you are talking, you can By default, aider starts in "code" mode. As you are talking, you can
send messages in other modes using `/ask` and `/help` commands: send messages in other modes using `/code`, `/ask`, and `/help` commands:
<div class="chat-transcript" markdown="1"> <div class="chat-transcript" markdown="1">
@ -33,9 +33,26 @@ This is the source code to the popular django package.
Run `aider --model ollama/<ollama-model>`. Run `aider --model ollama/<ollama-model>`.
See these docs for more info: https://aider.chat/docs/llms/ollama.html See these docs for more info: https://aider.chat/docs/llms/ollama.html
#### /code Add a function to calculate the factorial of a number
Certainly! I'll add a function to calculate the factorial of a number. Here's the change:
```python
def factorial(n):
if n == 0 or n == 1:
return 1
else:
return n * factorial(n - 1)
# Example usage
print(factorial(5)) # Output: 120
```
This function uses recursion to calculate the factorial. It's been added to your code.
</div> </div>
Using `/ask` and `/help` applies just to that particular message. Using `/code`, `/ask`, and `/help` applies just to that particular message.
Your next message will go back to code mode. Your next message will go back to code mode.
You can switch between the modes in a sticky way You can switch between the modes in a sticky way