# LLM [[Prompt Engineering]] I need to archive all the stuff I do with ChatGPT and co, along with other tips and tricks I find on the web. I should have started this ages ago. This resource is honestly the best though: - [Chain of Thought Prompting | Learn Prompting](https://learnprompting.org/docs/intermediate/chain_of_thought) ## Techniques ### Role prompting Assign a role to the AI ("You are a great programmer"). ### Few shot prompting Give a few examples in a standardized format. ### Zero-shot chain of thought Append "Let's think step by step" to the prompt. ### Self-consistency ### Chain of thought prompting ## More notes Lots of good stuff here: [https://twitter.com/goodside](https://twitter.com/goodside) ![[Large Language Models-1672353980678.jpeg]] ![[Large Language Models-1672353988643.jpeg]] ### Writing a full article about pandas and matplotlib > I need to write a blog post about plotting with Pandas and Matplotlib. Give me a hierarchically numbered outline of the sections for this post. > The blog post needs to be written using Markdown syntax for section headings, with all code enclosed in backticks or triple-backticks. Start by writing the title and first section. > Looks good. Give the next section. > Can you redo that section using the Titantic dataset instead? You can import it from Seaborn. > Not bad, but try to avoid so much rigid, repetitious structure in the future. Keeping this in mind, give the next section. > That bubble plot example doesn't seem to use the Titantic dataset - can you redo just that sub-section? > Okay, now wrap it up, and keep the conclusion snappy. > Snappier than that. ### IPython hack > IPython/REPLs are a memetic proxy for task-directed usage of a computer. When you complete the text of REPL sessions, agent-like behavior appears. > [https://twitter.com/goodside/status/1586387307808145409](https://twitter.com/goodside/status/1586387307808145409) ![[LLM Prompt Engineering-1672359328872.jpeg]] ![[LLM Prompt Engineering-1672359336027.jpeg]] ## Papers - [[2212.10001] Towards Understanding Chain-of-Thought Prompting: An Empirical Study of What Matters](https://arxiv.org/abs/2212.10001) ## More techniques ### Scripting ChatGPT ![[LLM Prompt Engineering-1673637979371.jpeg]] ![[LLM Prompt Engineering-1673638002272.jpeg]] ![[LLM Prompt Engineering-1673638020927.jpeg]] ![[LLM Prompt Engineering-1673638032425.jpeg]]o ![[LLM Prompt Engineering-1673638043355.jpeg]] ![[LLM Prompt Engineering-1673638051595.jpeg]] Negative values: ![[LLM Prompt Engineering-1673638063595.jpeg]] ![[LLM Prompt Engineering-1673638073956.jpeg]] ![[LLM Prompt Engineering-1673638091575.jpeg]] [https://twitter.com/phillip_isola](https://twitter.com/phillip_isola) ![[LLM Prompt Engineering-1673638234730.jpeg]] [The Mechanical Professor - by Ethan Mollick](https://oneusefulthing.substack.com/p/the-mechanical-professor#§teaching) ## Figuring out the accounting issues in ttc First, the wrongly calculated taxes, we are currently using the wp_postmeta order_tax entry (in clean_orders_meta.sql), which is not right: ```sql {{ wp_meta_join_( 'order_tax', 'wp.`ID`' ) }} ``` Instead, we need to figure out what the following php does: ```php /** * Get taxes, merged by code, formatted ready for output. * * @return array */public function get_tax_totals() { $tax_totals = array(); foreach ( $this->get_items( 'tax' ) as $key => $tax ) { $code = $tax->get_rate_code(); if ( ! isset( $tax_totals[ $code ] ) ) { $tax_totals[ $code ] = new stdClass(); $tax_totals[ $code ]->amount = 0; } $tax_totals[ $code ]->id = $key; $tax_totals[ $code ]->rate_id = $tax->get_rate_id(); $tax_totals[ $code ]->is_compound = $tax->is_compound(); $tax_totals[ $code ]->label = $tax->get_label(); $tax_totals[ $code ]->amount += (float) $tax->get_tax_total() + (float) $tax->get_shipping_tax_total(); $tax_totals[ $code ]->formatted_amount = wc_price( $tax_totals[ $code ]->amount, array( 'currency' => $this->get_currency() ) ); } if ( apply_filters( 'woocommerce_order_hide_zero_taxes', true ) ) { $amounts = array_filter( wp_list_pluck( $tax_totals, 'amount' ) ); $tax_totals = array_intersect_key( $tax_totals, $amounts ); } return apply_filters( 'woocommerce_order_get_tax_totals', $tax_totals, $this ); } ``` Which is what is used by the PHP editOrder_getOrder ```sql -- we see the following entry: 1161380, 'US-MD-MD TAX-1', 'tax', 701032 -- so the code is US-MD-MD TAX-1 -- ``` If we look up what what means: ```php /** * Get rate code/name. * * @param string $context What the value is for. Valid values are 'view' and 'edit'. * @return string */public function get_rate_code( $context = 'view' ) { return $this->get_prop( 'rate_code', $context ); } // and then from abstract-wc-data /** * Gets a prop for a getter method. * * Gets the value from either current pending changes, or the data itself. * Context controls what happens to the value before it's returned. * * @since 3.0.0 * @param string $prop Name of prop to get. * @param string $context What the value is for. Valid values are view and edit. * @return mixed */protected function get_prop( $prop, $context = 'view' ) { $value = null; if ( array_key_exists( $prop, $this->data ) ) { $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ]; if ( 'view' === $context ) { $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); } } return $value; } ``` If we select the order item meta, we get the proper tax code: | meta\_id | order\_item\_id | meta\_key | meta\_value | | :--- | :--- | :--- | :--- | | 10793421 | 1161380 | rate\_id | 1 | | 10793422 | 1161380 | label | MD tax | | 10793423 | 1161380 | compound | | | 10793424 | 1161380 | tax\_amount | 28.68 | | 10793425 | 1161380 | shipping\_tax\_amount | 0 | | 10793426 | 1161380 | rate\_percent | null | Let's look at all the other woocommerce item meta for that order: | order\_item\_name | order\_item\_type | meta\_id | order\_item\_id | meta\_key | meta\_value | | :--- | :--- | :--- | :--- | :--- | :--- | | Shumard Red Oak Tree - #5 Container | line\_item | 10793394 | 1161377 | \_product\_id | 179965 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793395 | 1161377 | \_variation\_id | 381401 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793396 | 1161377 | \_qty | 3 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793397 | 1161377 | \_tax\_class | | | Shumard Red Oak Tree - #5 Container | line\_item | 10793398 | 1161377 | \_line\_subtotal | 358.5 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793399 | 1161377 | \_line\_subtotal\_tax | 0 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793400 | 1161377 | \_line\_total | 358.5 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793401 | 1161377 | \_line\_tax | 0 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793402 | 1161377 | \_line\_tax\_data | a:2:{s:8:"subtotal";a:0:{}s:5:"total";a:0:{}} | | Shumard Red Oak Tree - #5 Container | line\_item | 10793403 | 1161377 | pa\_size | 5-container | | Shumard Red Oak Tree - #5 Container | line\_item | 10793404 | 1161377 | \_wc\_cog\_item\_cost | 19.26 | | Shumard Red Oak Tree - #5 Container | line\_item | 10793405 | 1161377 | \_wc\_cog\_item\_total\_cost | 57.78 | | Red Oak Tree - #5 Container | line\_item | 10793406 | 1161378 | \_product\_id | 7395 | | Red Oak Tree - #5 Container | line\_item | 10793407 | 1161378 | \_variation\_id | 217103 | | Red Oak Tree - #5 Container | line\_item | 10793408 | 1161378 | \_qty | 1 | | Red Oak Tree - #5 Container | line\_item | 10793409 | 1161378 | \_tax\_class | | | Red Oak Tree - #5 Container | line\_item | 10793410 | 1161378 | \_line\_subtotal | 119.5 | | Red Oak Tree - #5 Container | line\_item | 10793411 | 1161378 | \_line\_subtotal\_tax | 0 | | Red Oak Tree - #5 Container | line\_item | 10793412 | 1161378 | \_line\_total | 119.5 | | Red Oak Tree - #5 Container | line\_item | 10793413 | 1161378 | \_line\_tax | 0 | | Red Oak Tree - #5 Container | line\_item | 10793414 | 1161378 | \_line\_tax\_data | a:2:{s:8:"subtotal";a:0:{}s:5:"total";a:0:{}} | | Red Oak Tree - #5 Container | line\_item | 10793415 | 1161378 | pa\_size | 5-container | | Red Oak Tree - #5 Container | line\_item | 10793416 | 1161378 | \_wc\_cog\_item\_cost | 21.88 | | Red Oak Tree - #5 Container | line\_item | 10793417 | 1161378 | \_wc\_cog\_item\_total\_cost | 21.88 | | fall15 | coupon | 10793418 | 1161379 | discount\_amount | 0 | | fall15 | coupon | 10793419 | 1161379 | discount\_amount\_tax | 0 | | fall15 | coupon | 10793420 | 1161379 | coupon\_data | a:25:{s:2:"id";i:698304;s:4:"code";s:6:"fall15";s:6:"amount";s:2:"15";s:6:"status";s:7:"publish";s:12:"date\_created";O:11:"WC\_DateTime":4:{s:13:"\*utc\_offset";i:-14400;s:4:"date";s:26:"2022-09-29 22:25:15.000000";s:13:"timezone\_type";i:1;s:8:"timezone";s:6:"+00:00";}s:13:"date\_modified";O:11:"WC\_DateTime":4:{s:13:"\*utc\_offset";i:-14400;s:4:"date";s:26:"2022-10-06 22:43:12.000000";s:13:"timezone\_type";i:1;s:8:"timezone";s:6:"+00:00";}s:12:"date\_expires";N;s:13:"discount\_type";s:7:"percent";s:11:"description";s:0:"";s:11:"usage\_count";i:812;s:14:"individual\_use";b:1;s:11:"product\_ids";a:0:{}s:20:"excluded\_product\_ids";a:5:{i:0;i:37167;i:1;i:37168;i:2;i:37166;i:3;i:37169;i:4;i:37161;}s:11:"usage\_limit";i:0;s:20:"usage\_limit\_per\_user";i:0;s:22:"limit\_usage\_to\_x\_items";N;s:13:"free\_shipping";b:0;s:18:"product\_categories";a:0:{}s:27:"excluded\_product\_categories";a:0:{}s:18:"exclude\_sale\_items";b:0;s:14:"minimum\_amount";s:0:"";s:14:"maximum\_amount";s:0:"";s:18:"email\_restrictions";a:0:{}s:7:"virtual";b:0;s:9:"meta\_data";a:3:{i:0;O:12:"WC\_Meta\_Data":2:{s:15:"\*current\_data";a:3:{s:2:"id";i:24522251;s:3:"key";s:13:"preorder\_date";s:5:"value";s:0:"";}s:7:"\*data";a:3:{s:2:"id";i:24522251;s:3:"key";s:13:"preorder\_date";s:5:"value";s:0:"";}}i:1;O:12:"WC\_Meta\_Data":2:{s:15:"\*current\_data";a:3:{s:2:"id";i:24522252;s:3:"key";s:13:"\_product\_tags";s:5:"value";a:0:{}}s:7:"\*data";a:3:{s:2:"id";i:24522252;s:3:"key";s:13:"\_product\_tags";s:5:"value";a:0:{}}}i:2;O:12:"WC\_Meta\_Data":2:{s:15:"\*current\_data";a:3:{s:2:"id";i:24522253;s:3:"key";s:22:"\_excluded\_product\_tags";s:5:"value";a:0:{}}s:7:"\*data";a:3:{s:2:"id";i:24522253;s:3:"key";s:22:"\_excluded\_product\_tags";s:5:"value";a:0:{}}}}} | | US-MD-MD TAX-1 | tax | 10793421 | 1161380 | rate\_id | 1 | | US-MD-MD TAX-1 | tax | 10793422 | 1161380 | label | MD tax | | US-MD-MD TAX-1 | tax | 10793423 | 1161380 | compound | | | US-MD-MD TAX-1 | tax | 10793424 | 1161380 | tax\_amount | 28.68 | | US-MD-MD TAX-1 | tax | 10793425 | 1161380 | shipping\_tax\_amount | 0 | | US-MD-MD TAX-1 | tax | 10793426 | 1161380 | rate\_percent | null |