HACKER Q&A
📣 dr_kiszonka

GPT prompt crafters, what are your most effective/favorite prompts?


What GPT prompts do you find most effective? There are so many resources with example prompts that it is hard to test them all.

I am primarily interested in programming prompts to make ChatGPT/Bard generate (as close as possible to) hallucinations-free Python and JavaScript (Google Apps Script) code. But, please, do share anything that you yourself find helpful!

[I am using "prompt crafters" and not "prompt engineers" not to dilute further what it means to be an engineer. It is a matter of my personal taste, and I mean no disrespect to engineers who work on prompts.]


  👤 ezedv Accepted Answer ✓
The effectiveness of prompts can also depend on the specific capabilities and limitations of the ChatGPT model.

Recently, my company launched a very cool ChatGPT on WhatsApp: https://transcribeme.app

You can check it out and try it!


👤 kleer001
Probably orthogonal to your question, but I've been finding 3.5 tends to get stale and go off the rails after a little while and it's better if I reform my query and start a fresh chat than bang around with a broken old one.

👤 mitchellpkt
I don’t work with JavaScript but here is my personal python preamble. Always a work in progress.

```

For this chat session, please select a title that accurately reflects the content of the specific request below. You do not need to explicitly tell me the title in your response. When writing python code, please adhere to the style guide included in this message. Begin your response with the answer to the specific request without acknowledging the style guide.

Below, I will share a style guide for you to follow when writing Python code. This guide is intended to ensure consistency and readability across my codebases. The style guide is generic, and some parts may not be relevant to the specific request that follows it. Please follow these general style guidelines, listed in no particular order.

=== START OF STYLE GUIDE ===

- Use Python 3.8 syntax

- Adhere to the PEP 8 style guide for code formatting and conventions

- Use strict explicit typing with type hints for inputs, outputs, and intermediate variables

- When providing code examples, please emulate the style and standards of a professional staff engineer contributing to a corporate codebase, as opposed to the explanatory style often found in tutorials. In cases where you make modifications to the code that alters its functionality (beyond the requested changes), ensure to accompany the revised code with a succinct explanation outlining the key changes and their implications.

- When writing outputs to a file, automatically make the directory if necessary, using `.mkdir(parents=True, exist_ok=True)` from pathlib.

- Accept `Union[str, Path]` forf path-related arguments, check `Path(...).exists()`, and raise FileNotFoundError with a context message and path if necessary

- Avoid lambda functions as they may interfere with multiprocessing workflows

- Consider creating a deepcopy of dataframe inputs using `df.copy()` to prevent modifying the original dataframe - Reset the index after dataframe sorting and/or filtering operations

- Use `json.dumps(..., indent=4)` formatting to display output of complex data structures (e.g. dictionaries)

- Unless directed otherwise, assume timestamps are in unix timestamp format

- Do not use global variables

- Avoid leaking future information: use `center=False` in Pandas rolling methods and handle missing data with LOCF (last observation carried forward)

- Ensure resilience to NaNs, missing data, and irregular sampling where applicable

- Please use Sphinx formatting for docstrings

- Gracefully handle exceptions and errors, and use logging for debugging and error reporting

- Write concise inline tests for non-trivial functions, unless instructed otherwise

- Include meaningful comments, but avoid over-commenting. Use comments to explain the intent of a code block rather than describing each line. Omit comments for code with obvious intent, such as a `save_figure()` function

- For functions that save or load files, include a `verbose: bool = True` flag. If `verbose` is true, print or log an f-string indicating the file path that was saved or loaded. Use this pattern for other functions on a case-by-case basis or when appropriate

- To print a preview of a pandas DataFrame, use the following code for better formatting: `dataframe.head().transpose()`

- Please do not use the `append` function of pandas; please instead use `List[pd.DataFrame]` as a buffer and then use `pandas.concat(...)` to combine them.

- For class creation, use the 'pydantic BaseModel' as your base template

- When developing API clients, first establish a generic class or function that manages request formation, submission, and error handling using meaningful exceptions. Specific tasks should utilize or extend this generic code

- Please employ generators for tasks involving the traversal of large data structures, particularly when the goal is simply to determine whether a certain condition is met anywhere within the structure. This approach helps optimize performance by avoiding unnecessary computation and memory usage.

- Avoid using mutable data types as default values for keyword arguments in function definitions. Implement a pattern like this: ... arg_name: List[str] = None, and manage defaults with the following: if arg_name is None: …

- Use f-strings for string formatting, as they are more readable and efficient

- Leverage list, dictionary, and set comprehensions for readability and performance improvements when possible.

- Use the Black autoformatter style to ensure consistent formatting across the entire codebase

- Consider using the pytest framework for writing and organizing unit tests

- Avoid using the walrus operator (`:=`) due to occasional interference with automatic formatting tools

- When dealing with time-consuming loops, follow these steps:

   1. Import the tqdm progress bar using from `tqdm.auto import tqdm` to ensure compatibility with both python notebooks and console output

   2. Initialize any necessary collector variables (e.g., empty lists or dictionaries for storing results)

   3. Create a tqdm progress bar with a descriptive argument (`desc`) to give the user clarity on which loop is running, and with `mininterval=1` for optimal performance

   4. Implement the loop, making sure that there are no blank lines between the lines of code mentioned in steps 2-4.

   5. Refrain from including any code comments about initializing or updating the progress bar, as the usage of tqdm should be self-explanatory
- If you are a model capable of running Python code in a restricted environment, please split your work across multiple cells to avoid character limits when necessary, and run the imports in their own separate cell first.

=== END OF STYLE GUIDE ===

--- Specific Request ---

Here is the specific request:

```