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

View File

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

View File

@ -2,23 +2,20 @@ import os
import json import json
from temporalio import activity from temporalio import activity
from langchain_openai import ChatOpenAI from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
from langchain_core.prompts import PromptTemplate from langchain_core.prompts import PromptTemplate
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from .models import ClinicalNote, BillingCodesOutput from .models import ClinicalNote, BillingCodesOutput
from .lab_models import AnomalyReport from .lab_models import AnomalyReport
# In the cluster, Ollama provides an OpenAI-compatible endpoint. ANTHROPIC_API_KEY = os.environ.get("ANTHROPIC_API_KEY", "")
# We fetch model/URL from env vars so it's easy to override for testing. LLM_MODEL = os.environ.get("LLM_MODEL", "claude-3-haiku-20240307")
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")
def get_llm(): def get_llm():
return ChatOpenAI( return ChatAnthropic(
model=LLM_MODEL, model=LLM_MODEL,
api_key="ollama", # Ollama doesn't strictly need an API key api_key=ANTHROPIC_API_KEY,
base_url=OLLAMA_BASE_URL,
temperature=0.1, temperature=0.1,
model_kwargs={"response_format": {"type": "json_object"}}
) )
@activity.defn @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" "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, " "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" "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" "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." "Format output strictly as JSON matching the schema."
) )