Skip to content

Instantly share code, notes, and snippets.

@ahmednuaman
Created April 22, 2024 15:55
Show Gist options
  • Save ahmednuaman/0f4a828d22d2f6297c064e47be1e2b59 to your computer and use it in GitHub Desktop.
Save ahmednuaman/0f4a828d22d2f6297c064e47be1e2b59 to your computer and use it in GitHub Desktop.
@app.post("/api/invoke-prompt")
async def invoke_prompt(req: Request):
try:
body = await req.json()
return {
"response": await invoke_model_stream(
{
"messages": body["messages"],
"max_tokens": 3100,
"temperature": 0.5,
"top_k": 150,
"top_p": 0.5,
"system": body.get(
"system",
"You are an expert focusing on the insurance claims industry.",
),
"anthropic_version": "bedrock-2023-05-31",
},
"anthropic.claude-3-haiku-20240307-v1:0",
)
}
except Exception as e:
raise HTTPException(status_code=400, detail=f"Call to Bedrock failed: {str(e)}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment