Skip to content

Commit

Permalink
feat: Add Imagine LA engine (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinJBoyer authored Nov 26, 2024
1 parent 4bf0a9b commit 675cefd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/src/app_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AppConfig(PydanticBaseEnvConfig):
embedding_model: str = "multi-qa-mpnet-base-cos-v1"

# Default chat engine
chat_engine: str = "ca-edd-web"
chat_engine: str = "imagine-la"
temperature: float = 0.0

# Default LLM model
Expand Down
4 changes: 2 additions & 2 deletions app/src/chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def __query_user_session(user_id: str) -> UserSession:
Placeholder for creating/retrieving user's session from the DB, including settings and constraints
"""
session = UserSession(
user=UserInfo(user_id, ["ca-edd-web"]),
chat_engine_settings=ChatEngineSettings("ca-edd-web"),
user=UserInfo(user_id, ["imagine-la"]),
chat_engine_settings=ChatEngineSettings("imagine-la"),
)
logger.info("Found user session for: %s", user_id)
return session
Expand Down
21 changes: 20 additions & 1 deletion app/src/chat_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,27 @@ class CaEddWebEngine(BaseEngine):
name: str = "CA EDD Web Chat Engine"
datasets = ["CA EDD"]

system_prompt = f"""You are an assistant to navigators who support clients-such as claimants, beneficiaries, families, and individuals-during the screening, application, and receipt of public benefits from California's Employment Development Department (EDD).
system_prompt = f"""You are an assistant to navigators who support clients (such as claimants, beneficiaries, families, and individuals) during the screening, application, and receipt of public benefits from California's Employment Development Department (EDD).
If you can't find information about the user's prompt in your context, don't answer it. If the user asks a question about a program not delivered by California's Employment Development Department (EDD), don't answer beyond pointing the user to the relevant trusted website for more information. Don't answer questions about tax credits (such as EITC, CTC) or benefit programs not delivered by EDD.
If a prompt is about an EDD program, but you can't tell which one, detect and clarify program ambiguity. Ask: "The EDD administers several programs such as State Disability Insurance (SDI), Paid Family Leave (PFL), and Unemployment Insurance (UI). I'm not sure which benefit program your prompt is about; could you let me know?"
{PROMPT}"""


class ImagineLaEngine(BaseEngine):
retrieval_k: int = 50
retrieval_k_min_score: float = -1

# Note: currently not used
chunks_shown_min_score: float = -1
chunks_shown_max_num: int = 8

engine_id: str = "imagine-la"
name: str = "Imagine LA Chat Engine"
datasets = ["CA EDD", "Imagine LA"]

system_prompt = f"""You are an assistant to navigators who support clients-such as claimants, beneficiaries, families, and individuals-during the screening, application, and receipt of public benefits in California.
If you can't find information about the user's prompt in your context, don't answer it. If the user asks a question about a program not available in California, don't answer beyond pointing the user to the relevant trusted website for more information.
If a prompt is about a benefit program, but you can't tell which one, detect and clarify program ambiguity. Ask: "I'm not sure which benefit program your prompt is about; could you let me know? If you don't know what benefit program might be helpful, you can also describe what you need and I can make a recommendation."
{PROMPT}"""
2 changes: 1 addition & 1 deletion app/tests/src/test_chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_api_healthcheck(client):
def test_api_engines(client):
response = client.get("/api/engines?user_id=TestUser")
assert response.status_code == 200
assert response.json() == ["ca-edd-web"]
assert response.json() == ["imagine-la"]


def test_api_query(monkeypatch, client):
Expand Down

0 comments on commit 675cefd

Please sign in to comment.