Upgrade Temporal agent to Claude 3 Haiku for WhatsApp booking
Build Agents Runtime / build (push) Successful in 3m2s Details

This commit is contained in:
Deep Koluguri 2026-05-26 18:53:17 -04:00
parent 6df7a23d57
commit 291d444a60
4 changed files with 12 additions and 11 deletions

BIN
agents.tar Normal file

Binary file not shown.

View File

@ -30,10 +30,10 @@ spec:
value: "default"
- name: CURAFLOW_TASK_QUEUE
value: "curaflow-tasks"
- name: OLLAMA_BASE_URL
value: "http://ollama.ai-core.svc.cluster.local:11434/v1"
- name: ANTHROPIC_API_KEY
value: "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"
- name: LLM_MODEL
value: "qwen2.5:3b"
value: "claude-3-haiku-20240307"
resources:
limits:
cpu: 500m

View File

@ -2,6 +2,7 @@
requests
langchain
langchain-openai
langchain-anthropic
temporalio
pydantic

View File

@ -2,23 +2,20 @@ import os
import json
from temporalio import activity
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import PromptTemplate
from pydantic import BaseModel, Field
from .models import ClinicalNote, BillingCodesOutput
from .lab_models import AnomalyReport
# In the cluster, Ollama provides an OpenAI-compatible endpoint.
# We fetch model/URL from env vars so it's easy to override for testing.
OLLAMA_BASE_URL = os.environ.get("OLLAMA_BASE_URL", "http://ollama.ai-core.svc.cluster.local:11434/v1")
LLM_MODEL = os.environ.get("LLM_MODEL", "qwen2.5:3b")
ANTHROPIC_API_KEY = os.environ.get("ANTHROPIC_API_KEY", "")
LLM_MODEL = os.environ.get("LLM_MODEL", "claude-3-haiku-20240307")
def get_llm():
return ChatOpenAI(
return ChatAnthropic(
model=LLM_MODEL,
api_key="ollama", # Ollama doesn't strictly need an API key
base_url=OLLAMA_BASE_URL,
api_key=ANTHROPIC_API_KEY,
temperature=0.1,
model_kwargs={"response_format": {"type": "json_object"}}
)
@activity.defn
@ -187,6 +184,9 @@ async def parse_booking_intent_activity(chat_history: list[dict]) -> dict:
"Analyze the conversation. Extract any appointment details (department, date, time).\n"
"If they want to book an appointment but haven't specified department, date, and time, "
"add those to missing_info and formulate a reply_message asking for them.\n"
"CRITICAL INSTRUCTIONS FOR ASKING:\n"
"- If the user hasn't specified a department, you MUST list the 4 available departments (Cardiology, General Medicine, Pediatrics, Orthopedics) so they know what to choose. Do not make them guess!\n"
"- If they haven't specified a time, suggest common intervals (e.g. 10:00 AM, 11:00 AM, 6:00 PM).\n"
"If all details are present, set missing_info to empty and formulate a confirmation reply_message.\n"
"Format output strictly as JSON matching the schema."
)