Skip to content

Version-1 changes for Maple Chatbot pr_2198_bot - #2218

Open
vkavith wants to merge 3 commits into
codeforboston:mainfrom
vkavith:maple_pr_2198_bot
Open

Version-1 changes for Maple Chatbot pr_2198_bot#2218
vkavith wants to merge 3 commits into
codeforboston:mainfrom
vkavith:maple_pr_2198_bot

Conversation

@vkavith

@vkavith vkavith commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

Maple Chatbot where a User can ask Questions about Bill/Policy issue question answering chat

ReAct AI agent with tool calling and reasoning loop capability

Access to firebase vector index search

Add a short summary of the changes, and a reference to the original issue using # and the issue number, like #1

Checklist

  • On the frontend, I've made my strings translate-able.
  • If I've added shared components, I've added a storybook story.
  • I've made pages responsive and look good on mobile.
  • If I've added new Firestore queries, I've added any new required indexes to firestore.indexes.json (Please do not only create indexes through the Firebase Web UI, even though the error messages may reccommend it - indexes created this way may be obliterated by subsequent deploys)

Screenshots

Add some screenshots highlighting your changes.

Known issues

If you've run against limitations or caveats, include them here. Include follow-up issues as well.

Steps to test/reproduce

For each feature or bug fix, create a step by step list for how a reviewer can test it out. E.g.:

  1. Go to the home page
  2. Click on a testimony
  3. See that it's loaded with a loading spinner

@vercel

vercel Bot commented Aug 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
maple-dev Error Error Aug 19, 2026 1:41am

Request Review

Comment thread .venv/bin/activate Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

venv to be removed

Comment thread llm/requirements.txt

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code in llm/ not relevant to this PR, so I recommend not modifying the requirements here

@nesanders nesanders left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is initial high level feedback.

@@ -0,0 +1,104 @@
import { useState, useRef, useEffect } from "react"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A big open question is if we should be authoring our own chat widget or adopting a framework like copilotkit instead.

│ functions/src/llm/agent.ts │
│ │
│ createReactAgent(@langchain/langgraph/prebuilt) │
│ Model: OpenAI gpt-4o-mini • temperature: 0 │

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed, we'd prefer to align on using gemini models in our google account rather than these older openai models used in the old llm/ code


// Logged-in users: persistent monthly token budget, tracked in the
// top-level `llmUsage` collection (see usage.ts).
loggedInMonthlyTokenBudget: 50_000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These default budgets might be too small to be useful for either logged in or anonymous users, but we can modify later

---

## Backfilling Existing Documents

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything we actually need to backfill? I think we already have the relevant embeddings for bills, questions, and testimony in the index.

Comment thread functions/package.json
"rimraf": "^3.0.2",
"ts-jest": "^29.2.5",
"typescript": "4.5.5"
"typescript": "^5.5.4"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we will update typescript version as part of this PR, though w may do so later for other reasons

Comment thread functions/package.json
"@google-cloud/pubsub": "^3.0.1",
"@langchain/core": "^0.3.0",
"@langchain/langgraph": "^0.2.0",
"@langchain/openai": "^0.3.0",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As noted elsewhere, we will use google instead of openai

{
name: "search_bills",
description:
"Semantic search over Massachusetts legislative bills (title and full text). Use this to find bills related to a topic, policy area, or question.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the MCP server code in this repo, we have a function called something like 'search_policies' that explicitly searches across both bills and questions. We should reuse that code if possible (to eliminate redundancy) and generally follow the same pattern. We should expose a bill-only search tool, a question-only search tool, and a combined search called 'policy'.

{
name: "search_testimony",
description:
"Semantic search over public testimony submitted on bills. Optionally scope to a specific bill by ID. Use this to find what people have said about a bill or issue.",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here - we want the agent to be able to search for testimony on only bills, testimony on only questions, or both. Right now, in the MCP server code, we do that through 3 separate tools and we should generally follow the same pattern here.

import { httpsCallable } from "firebase/functions"
import { functions } from "components/firebase"
import { useAuth } from "components/auth"
import styles from "./ChatWidget.module.css"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we need to add a mock frontend pag that just exposes this widget on a placeholder page for initial testing purposes.

import { vectorSearchTools } from "./vectorSearchTools"
import { LLM_CONFIG } from "./config"

const SYSTEM_PROMPT = `You are a helpful assistant for the MAPLE platform, answering questions about Massachusetts legislation, testimony, and ballot questions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! We can probably elaborate on this with input from the design team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants