Server.Enrichment.AI.Anthropic

Query Anthropic AI for analysis of data.

Paramaters:

  • PrePrompt - Added as preprompt. Default is: “You are a Cyber Incident Responder and need to analyze data. You have an eye for detail and like to use short precise technical language. Analyze the following data and provide summary analysis:”
  • Prompt - Is User prompt as string: When pushing a dict object via PromtData good practice is add some strings related to the type of data for analysis or artifact name to provide context.
  • PromptData - add optional object to be serialized and added to the User prompt.
  • Model - Model to use for your request. Default is claude-3-7-sonnet-20250219
  • AnthropicVersion - anthropic-version header
  • MaxTokens - Set max token size default 64000

This artifact can be called from within another artifact (such as one looking for files) to enrich the data made available by that artifact.


name: Server.Enrichment.AI.Anthropic
author: Matt Green - @mgreen27
description: |
  Query Anthropic AI for analysis of data.
  
  Paramaters:
  
  * `PrePrompt` - Added as preprompt. Default is: 
  "You are a Cyber Incident Responder and need to analyze data. You have an eye 
  for detail and like to use short precise technical language. Analyze the 
  following data and provide summary analysis:"
  * `Prompt` - Is User prompt as string: When pushing a dict object via 
  PromtData good practice is add some strings related to the type of data for 
  analysis or artifact name to provide context.
  * `PromptData` - add optional object to be serialized and added to the User prompt.
  * `Model` - Model to use for your request. Default is claude-3-7-sonnet-20250219
  * AnthropicVersion - anthropic-version header
  * `MaxTokens` - Set max token size  default 64000
  
  This artifact can be called from within another artifact (such as one looking 
  for files) to enrich the data made available by that artifact.
  
type: SERVER

parameters:
    - name: PrePrompt
      type: string
      description: |
        Prompt to send with data. For example, when asking 
        a question, then providing data separately
      default: |
        You are a Cyber Incident responder and need to analyse forensic 
        collections. You have an eye for detail and like to use short precise 
        technical language. Your PRIMARY goal is to analyse the following data 
        and provide summary analysis:
    - name: Prompt
      type: string
      default: Can you list 10 Windows persistance items in bullet points?
    - name: PromptData
      type: string
      description: The data sent to Anthropic - this data is serialised and added to the prompt
    - name: Model
      type: string
      description: The model used for processing the prompt
      default: claude-3-7-sonnet-20250219
    - name: AnthropicVersion
      type: string
      description: anthropic-version header
      default: "2023-06-01"
    - name: AnthropicToken
      type: string
      description: Token for Anthropic. Leave blank here if using server metadata store.
    - name: MaxTokens
      type: int
      default: 64000

sources:
  - query: |
        LET Creds <= if(
            condition=AnthropicToken,
            then=AnthropicToken,
            else=server_metadata().AnthropicToken)
        LET messages = if(condition=PromptData,
                        then = dict(role='user',content=PrePrompt + Prompt + ' ' + serialize(item=PromptData)) ,
                        else= dict(role='user',content=PrePrompt + Prompt) )
        LET Data = if(condition=MaxTokens,
                        then= dict(model=Model, messages=[messages,],max_tokens=MaxTokens),
                        else= dict(model=Model, messages=[messages,]) 
                    )

        SELECT
            messages.content as UserPrompt,
            parse_json(data=Content).content[0].text AS ResponseText,
            parse_json(data=Content) AS ResponseDetails
        FROM http_client(
            url='https://api.anthropic.com/v1/messages',
            headers=dict(
                    `x-api-key`=Creds, 
                    `Content-Type`="application/json", 
                    `anthropic-version`=AnthropicVersion
                ),
            method="POST",
            data=Data )