BG change
This commit is contained in:
@@ -12,29 +12,10 @@ import Anthropic from '@anthropic-ai/sdk'
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Managed Agent configuration
|
// Managed Agent configuration
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// The Managed Agent ID is supplied via the ANTHROPIC_AGENT_ID env var. When
|
// The Managed Agent ID is supplied via the ANTHROPIC_AGENT_ID env var. The
|
||||||
// present the call is routed to that agent. Otherwise we fall back to a
|
// agent's system prompt and model are defined in the Claude Console and used
|
||||||
// system-prompt-driven "virtual agent" that defines the persona inline.
|
// by default. ANTHROPIC_MODEL and ANTHROPIC_SYSTEM_PROMPT may optionally
|
||||||
|
// override them.
|
||||||
const SYSTEM_PROMPT = `You are the "PMC Funder Discovery Agent", an expert
|
|
||||||
fundraising consultant for U.S. public media stations (NPR/PBS member
|
|
||||||
stations, community radio, and independent public broadcasters).
|
|
||||||
|
|
||||||
Your job is to take a brief intake form about a public media station and
|
|
||||||
produce a tailored funding outlook that includes:
|
|
||||||
1. A short profile of the station based on the supplied details.
|
|
||||||
2. 3-5 likely foundation funders that match the station's mission and
|
|
||||||
geography (CPB, Knight, MacArthur, Wyncote, regional community
|
|
||||||
foundations, etc.).
|
|
||||||
3. 2-3 corporate underwriting angles relevant to the station's market.
|
|
||||||
4. Concrete next steps for the development director.
|
|
||||||
|
|
||||||
Write in clear, direct prose. Use Markdown headings and bullet lists. If
|
|
||||||
you need additional information, you may emit a tool_use block requesting
|
|
||||||
it; otherwise produce the brief in one pass. Avoid speculation about
|
|
||||||
specific dollar amounts.`
|
|
||||||
|
|
||||||
const MODEL = process.env.ANTHROPIC_MODEL || 'claude-sonnet-4-5'
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Anthropic client (reused across warm Lambda invocations)
|
// Anthropic client (reused across warm Lambda invocations)
|
||||||
@@ -67,8 +48,6 @@ export default async (req /*, context */) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
userName = '',
|
|
||||||
userEmail = '',
|
|
||||||
stationName = '',
|
stationName = '',
|
||||||
stationLocation = '',
|
stationLocation = '',
|
||||||
stationWebsite = '',
|
stationWebsite = '',
|
||||||
@@ -93,23 +72,17 @@ export default async (req /*, context */) => {
|
|||||||
|
|
||||||
const userMessage = `Here is a new public media station intake:
|
const userMessage = `Here is a new public media station intake:
|
||||||
|
|
||||||
- Submitter Name: ${userName}
|
|
||||||
- Submitter Email: ${userEmail}
|
|
||||||
- Station Name: ${stationName}
|
- Station Name: ${stationName}
|
||||||
- Station Location: ${stationLocation}
|
- Station Location: ${stationLocation}
|
||||||
- Station Website: ${stationWebsite}
|
- Station Website: ${stationWebsite}
|
||||||
|
|
||||||
Please draft the funding outlook brief described in your instructions.`
|
Please follow your instructions to produce the funding outlook brief.`
|
||||||
|
|
||||||
// ----- Build the streaming request -----
|
// ----- Build the streaming request -----
|
||||||
// Note: when calling a Managed Agent, the Anthropic SDK accepts an
|
// The Managed Agent's system prompt and model (configured in the Claude
|
||||||
// `agent_id` field on the messages.stream() call. We include it
|
// Console) are used by default. Optional env vars can override them.
|
||||||
// conditionally so the same code path also works with a plain system
|
|
||||||
// prompt while you're wiring things up.
|
|
||||||
const streamArgs = {
|
const streamArgs = {
|
||||||
model: MODEL,
|
|
||||||
max_tokens: 10000,
|
max_tokens: 10000,
|
||||||
system: SYSTEM_PROMPT,
|
|
||||||
messages: [
|
messages: [
|
||||||
{
|
{
|
||||||
role: 'user',
|
role: 'user',
|
||||||
@@ -120,6 +93,12 @@ Please draft the funding outlook brief described in your instructions.`
|
|||||||
if (process.env.ANTHROPIC_AGENT_ID) {
|
if (process.env.ANTHROPIC_AGENT_ID) {
|
||||||
streamArgs.agent_id = process.env.ANTHROPIC_AGENT_ID
|
streamArgs.agent_id = process.env.ANTHROPIC_AGENT_ID
|
||||||
}
|
}
|
||||||
|
if (process.env.ANTHROPIC_MODEL) {
|
||||||
|
streamArgs.model = process.env.ANTHROPIC_MODEL
|
||||||
|
}
|
||||||
|
if (process.env.ANTHROPIC_SYSTEM_PROMPT) {
|
||||||
|
streamArgs.system = process.env.ANTHROPIC_SYSTEM_PROMPT
|
||||||
|
}
|
||||||
|
|
||||||
const upstream = client.messages.stream(streamArgs)
|
const upstream = client.messages.stream(streamArgs)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
font-family: 'Noto Serif', serif;
|
font-family: 'Noto Serif', serif;
|
||||||
background-color: #f7f4ee;
|
background-color: #ffffff;
|
||||||
color: #1f1b16;
|
color: #1f1b16;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user