Skip to content

Instantly share code, notes, and snippets.

@sergenes
Created December 10, 2023 15:37
Show Gist options
  • Save sergenes/b4dfd58b789e5ffbbe4588caadd643ce to your computer and use it in GitHub Desktop.
Save sergenes/b4dfd58b789e5ffbbe4588caadd643ce to your computer and use it in GitHub Desktop.
from anthropic import Anthropic, HUMAN_PROMPT, AI_PROMPT
anthropic_api_key = os.getenv('ANTHROPIC_API_KEY_1')
anthropic = Anthropic(api_key=anthropic_api_key)
def get_anthropic_completion(prompt, model="claude-2.1"):
completion = anthropic.completions.create(
model=model,
max_tokens_to_sample=1000,
temperature=0.2,
prompt=f"${HUMAN_PROMPT} ${prompt}${AI_PROMPT}",
)
return completion.completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment