Skip to content

Commit

Permalink
Fix issue #4181: 'Prompting best practices documentation'
Browse files Browse the repository at this point in the history
  • Loading branch information
openhands-agent committed Oct 3, 2024
1 parent 1abfd3b commit 02a4f7b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
37 changes: 37 additions & 0 deletions docs/prompting_best_practices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Prompting Best Practices

When working with OpenHands AI software developer, it's crucial to provide clear and effective prompts. This guide outlines best practices for creating prompts that will yield the most accurate and useful responses.

## Characteristics of Good Prompts

Good prompts are:

1. **Concrete**: They explain exactly what functionality should be added or what error needs to be fixed.
2. **Location-specific**: If known, they explain the locations in the code base that should be modified.
3. **Appropriately scoped**: They should be the size of a single feature, typically not exceeding 100 lines of code.

## Examples of Good Prompts

1. "Add a function `calculate_average` in the file `/workspace/openhands/utils/math_operations.py` that takes a list of numbers as input and returns their average."

2. "Fix the TypeError in the `process_user_input` function in `/workspace/frontend/src/components/UserInput.tsx`. The error occurs when passing a string instead of a number to the `processData` function."

3. "Implement input validation for the email field in the user registration form. Update the file `/workspace/frontend/src/components/RegistrationForm.tsx` to include this validation before form submission."

## Examples of Bad Prompts

1. "Make the code better." (Too vague and not concrete)

2. "Rewrite the entire backend to use a different framework." (Not appropriately scoped)

3. "Fix all the bugs in the project." (Not concrete, not location-specific, and not appropriately scoped)

## Tips for Writing Effective Prompts

1. Be as specific as possible about the desired outcome or the problem to be solved.
2. Provide context, including relevant file paths and function names.
3. Break down large tasks into smaller, manageable prompts.
4. Include any relevant error messages or logs if you're asking for a bug fix.
5. Specify the programming language and any relevant libraries or frameworks being used.

Remember, the more precise and detailed your prompt is, the better the chances of getting an accurate and helpful response from the OpenHands AI software developer.
7 changes: 7 additions & 0 deletions frontend/src/components/modals/settings/SettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface SettingsFormProps {
agents: string[];
securityAnalyzers: string[];
disabled: boolean;
promptingBestPracticesUrl: string;

onModelChange: (model: string) => void;
onBaseURLChange: (baseURL: string) => void;
Expand All @@ -32,6 +33,7 @@ function SettingsForm({
agents,
securityAnalyzers,
disabled,
promptingBestPracticesUrl,
onModelChange,
onBaseURLChange,
onAPIKeyChange,
Expand Down Expand Up @@ -79,6 +81,11 @@ function SettingsForm({
>
Advanced Options
</Switch>
<div className="mt-4">
<a href={promptingBestPracticesUrl} target="_blank" rel="noopener noreferrer" className="text-blue-500 hover:underline">

Check failure on line 85 in frontend/src/components/modals/settings/SettingsForm.tsx

View workflow job for this annotation

GitHub Actions / Lint frontend

Replace `·href={promptingBestPracticesUrl}·target="_blank"·rel="noopener·noreferrer"·className="text-blue-500·hover:underline"` with `⏎··········href={promptingBestPracticesUrl}⏎··········target="_blank"⏎··········rel="noopener·noreferrer"⏎··········className="text-blue-500·hover:underline"⏎········`
Prompting Best Practices
</a>
</div>
{enableAdvanced && (
<>
<Input
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/modals/settings/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ function SettingsModal({ isOpen, onOpenChange }: SettingsProps) {
onAPIKeyChange={handleAPIKeyChange}
onConfirmationModeChange={handleConfirmationModeChange}
onSecurityAnalyzerChange={handleSecurityAnalyzerChange}
promptingBestPracticesUrl="/docs/prompting_best_practices.md"
/>
)}
</BaseModal>
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ python-pptx = "*"
pylatexenc = "*"
tornado = "*"
python-dotenv = "*"
pytest = "^8.3.3"

[tool.poetry.group.llama-index.dependencies]
llama-index = "*"
Expand Down Expand Up @@ -86,6 +87,7 @@ reportlab = "*"
concurrency = ["gevent"]



[tool.poetry.group.runtime.dependencies]
jupyterlab = "*"
notebook = "*"
Expand Down Expand Up @@ -117,6 +119,7 @@ ignore = ["D1"]
convention = "google"



[tool.poetry.group.evaluation.dependencies]
streamlit = "*"
whatthepatch = "*"
Expand Down

0 comments on commit 02a4f7b

Please sign in to comment.