Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import anthropic
- client = anthropic.Anthropic(
- # defaults to os.environ.get("ANTHROPIC_API_KEY")
- api_key=os.environ["ANTHROPIC_API_KEY"],
- )
- def create_anthropic_message(system_prompt, user_prompt, anthropic_model = "claude-3-opus-20240229",
- max_tokens = 200, temperature = 1, **kwargs):
- message = client.messages.create(
- model=anthropic_model,
- max_tokens=max_tokens,
- temperature=temperature,
- system=system_prompt,
- # Also include any other arguments in the def function kwargs
- **kwargs,
- messages=[{"role": "user","content": [{"type": "text","text": user_prompt}]}])
- return (message)
- for i in range(20):
- try:
- r = create_anthropic_message("You are an oncology expert","Compose a brief 1-sentence presentation of a US-based patient presenting with Skin Cancer.")
- print(r.content[0])
- except Exception as error:
- # handle the exception
- print("An exception occurred:", error)
- # Results with Temperature 0
- ContentBlock(text='A 62-year-old Caucasian male with a history of excessive sun exposure presents with a rapidly growing, asymmetric, irregularly bordered, 8mm diameter, dark brown to black pigmented lesion on his left upper back.', type='text')
- ContentBlock(text='A 62-year-old Caucasian male with a history of excessive sun exposure presents with a rapidly growing, asymmetric, irregularly bordered, 8mm diameter, dark brown to black pigmented lesion on his left upper back.', type='text')
- ContentBlock(text='A 62-year-old Caucasian male with a history of excessive sun exposure presents with a rapidly growing, asymmetric, irregularly bordered, 8mm diameter, dark brown to black pigmented lesion on his left upper back.', type='text')
- ContentBlock(text='A 62-year-old Caucasian male with a history of excessive sun exposure presents with a rapidly growing, asymmetric, irregularly bordered, 8mm diameter, dark brown to black pigmented lesion on his left upper back.', type='text')
- # Results with Temperature 1
- ContentBlock(text='A 62-year-old Caucasian male from Florida presented with a rapidly growing, asymmetric, irregularly bordered, 8mm diameter, dark brown to black lesion on his left upper back that had changed in size and color over the past 3 months.', type='text')
- ContentBlock(text='A 45-year-old fair-skinned female from Florida presents with a slowly growing, asymmetric, irregularly bordered, multicolored, 8mm diameter mole on her left forearm that has recently started to itch and bleed.', type='text')
- ContentBlock(text='A 45-year-old Caucasian male construction worker from Florida presented with a rapidly growing, irregularly bordered, darkly pigmented lesion on his left shoulder that had changed in size and color over the past 3 months.', type='text')
- ContentBlock(text='A 62-year-old Caucasian male with a history of extensive sun exposure presents with a rapidly growing, irregularly bordered, and multicolored lesion on his left forearm, suspicious for melanoma.', type='text')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement