anthropics / anthropic-sdk-python

MIT License
1.35k stars 164 forks source link

control the llm output #99

Closed turagatron closed 1 year ago

turagatron commented 1 year ago

Every time I provide explicit prompt instructions to claude-2 to return something in a specific format, it does so reliably but the output always includes a preamble of that claude did.

For example:

There are several ways a court case can reach the U.S. Supreme Court:

- Appeal from lower federal courts - Most cases come to the Supreme Court on appeal from lower federal appellate courts, like the circuit courts or the Court of Appeals for the Federal Circuit. A party who loses at the appellate level can request the Supreme Court hear the case.

- Appeal from state supreme courts - If the highest state court rules on an issue of federal law, like the constitutionality of a state law, the losing party can appeal to the U.S. Supreme Court. This accounts for about a third of the caseload.

- Original jurisdiction cases - A limited category of cases has the Supreme Court as the court of first instance. These include cases between two or more U.S. states or cases involving ambassadors and other public ministers. 

- Certified questions from appellate courts - Appellate courts can ask the Supreme Court to answer a question of law in a case pending before them. This happens infrequently.

- Writ of certiorari - The most common way cases reach the Supreme Court is through a petition for writ of certiorari. This is a request that the Supreme Court order a lower court to send up the record of a case for review. The Court grants cert in less than 5% of petitions received.

I just want the bulleted list without the There are several ways.. preamble.

  1. Any suggestions on how to do this?
  2. Is there a mode that can be enabled that follows the given prompt examples more explicitly?
rattrayalex commented 1 year ago

You might find Anthropic's prompt design docs useful: https://docs.anthropic.com/claude/docs/constructing-a-prompt

This repo is specifically for the Anthropic Python SDK, so closing as off-topic. If you have followup questions, you can try https://support.anthropic.com/