simonw / llm-bedrock

Run prompts against models hosted on AWS Bedrock
Apache License 2.0
6 stars 0 forks source link

Attachment support #3

Closed simonw closed 12 hours ago

simonw commented 13 hours ago

Split from:

simonw commented 12 hours ago

From https://boto3.amazonaws.com/v1/documentation/api/1.35.8/reference/services/bedrock-runtime/client/converse.html it looks like both images and documents are supported:

response = client.converse(
    modelId='string',
    messages=[
        {
            'role': 'user'|'assistant',
            'content': [
                {
                    'text': 'string',
                    'image': {
                        'format': 'png'|'jpeg'|'gif'|'webp',
                        'source': {
                            'bytes': b'bytes'
                        }
                    },
                    'document': {
                        'format': 'pdf'|'csv'|'doc'|'docx'|'xls'|'xlsx'|'html'|'txt'|'md',
                        'name': 'string',
                        'source': {
                            'bytes': b'bytes'
                        }
                    },
simonw commented 12 hours ago

Also from those docs:

You can include up to 20 images. Each image’s size, height, and width must be no more than 3.75 MB, 8000 px, and 8000 px, respectively.

You can include up to five documents. Each document’s size must be no more than 4.5 MB.

If you include a ContentBlock with a document field in the array, you must also include a ContentBlock with a text field.

simonw commented 12 hours ago

OK this works, and it's wildly inexpensive.

2024-12-04T01:38:22 conversation: 01je7n3aqmn5j7wq1tcarszjjn

Model: us.amazon.nova-lite-v1:0

Prompt:

describe this document

Attachments

  1. application/pdf: /private/tmp/Living Computer Museum - Full Filing - Nonprofit Explorer - ProPublica.pdf

Response:

Summary of Form 990-PF for Living Computer Museum

Organization Information:

  • Name: Living Computer Museum
  • Address: 505 5th Ave S, Suite 900, Seattle, WA 98104
  • EIN: 46-0979323
  • Contact Person: Joyce Lee
  • Phone: (206) 342-2000

Financial Overview:

  • Revenue and Expenses:
    • Total Revenue: $1,025
    • Total Expenses: $1,125
    • Net Income/(Loss): $(100)
  • Net Investment Income: $0
  • Disbursements for Charitable Purposes: $0

Balance Sheet Summary:

  • Total Assets at End of Year: $174,598
  • Total Liabilities at End of Year: $52,898
  • Net Assets at End of Year: $121,700

Key Activities and Compliance:

  • Political Campaign Activities: None
  • Unrelated Business Income: None
  • Disqualified Persons Transactions: None
  • Charitable Distributions: None

Governance and Personnel:

  • Officers/Directors:
    • Joyce Lynn Allen (Director/President)
    • Alison G Ivey (Director/Secretary/VP)
    • William H Hilf (Director/Vice President)
    • Carola Ross (Vice President)
    • Danielle M Harper (Vice President)
  • Compensation: None reported for officers/directors

Additional Information:

  • Undistributed Income: None
  • Qualifying Distributions: None
  • Program-Related Investments: None
  • Minimum Investment Return: $1,906

Supplementary Information:

  • Grants and Contributions: None reported
  • Relationships with Noncharitable Exempt Organizations: None

Declaration:

  • The form has been examined and is declared true, correct, and complete by the preparer.

Note: This summary is based on the provided OCR results and may not capture all details or nuances present in the full document. For a complete and accurate understanding, the full Form 990-PF should be reviewed.

Token usage:

16,002 input, 465 output

That cost 0.1072 cents - analyzing a 14 page PDF.

simonw commented 12 hours ago

I need this not to activate for us.amazon.nova-micro-v1:0