Advertisement
xbsd

Claude 3 Issue

Mar 10th, 2024 (edited)
691
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.01 KB | None | 0 0
  1. import anthropic
  2.  
  3. client = anthropic.Anthropic(
  4.     # defaults to os.environ.get("ANTHROPIC_API_KEY")
  5.     api_key=os.environ["ANTHROPIC_API_KEY"],
  6. )
  7.  
  8.  
  9. def create_anthropic_message(system_prompt, user_prompt, anthropic_model = "claude-3-opus-20240229",
  10.                              max_tokens = 200, temperature = 1, **kwargs):
  11.     message = client.messages.create(
  12.         model=anthropic_model,
  13.         max_tokens=max_tokens,
  14.         temperature=temperature,
  15.         system=system_prompt,
  16.         # Also include any other arguments in the def function kwargs
  17.         **kwargs,
  18.         messages=[{"role": "user","content": [{"type": "text","text": user_prompt}]}])
  19.     return (message)
  20.  
  21. for i in range(20):
  22.   try:
  23.     r = create_anthropic_message("You are an oncology expert","Compose a brief 1-sentence presentation of a US-based patient presenting with Skin Cancer.")
  24.     print(r.content[0])
  25.   except Exception as error:
  26.     # handle the exception
  27.     print("An exception occurred:", error)
  28.    
  29. # Results with Temperature 0
  30. 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')
  31. 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')
  32. 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')
  33. 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')
  34.  
  35.  
  36. # Results with Temperature 1
  37. 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')
  38. 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')
  39. 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')
  40. 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')
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement