From 37cff6882db161628b667b10bbd3cebde5f202ad Mon Sep 17 00:00:00 2001 From: hayden outlaw <98779749+outlawhayden@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:26:50 -0600 Subject: [PATCH 1/8] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 3add7f39..7cfd4574 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,6 @@ Work in Progress -## Tulane Dev Integration Branch - -Sawt is a tool designed to bridge the communication gap between New Orleanians and their city council representatives. - ## Prerequisites - Install [DVC](https://dvc.org/doc/install) From 9d0c77b0d0b5045f3619cbc2339a37dee0a5d745 Mon Sep 17 00:00:00 2001 From: Ayyub Ibrahim Date: Sun, 10 Dec 2023 21:41:36 -0600 Subject: [PATCH 2/8] augmented prompt to be more concise, less verbose, and to include definitions for technical/uncommon language --- .../functions/getanswer/inquirer.py | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/googlecloud/functions/getanswer/inquirer.py b/packages/googlecloud/functions/getanswer/inquirer.py index ca005b98..3873970f 100644 --- a/packages/googlecloud/functions/getanswer/inquirer.py +++ b/packages/googlecloud/functions/getanswer/inquirer.py @@ -176,12 +176,12 @@ def get_indepth_response_from_query(df, db, query, k): docs_page_content = append_metadata_to_content(doc_list) + template = """ Question: {question} - Based on the information from the New Orleans city council documents provided, answer the following question: {question}. - + If possible, extract the key points, decisions, and actions discussed during the city council meetings relevant to {question}; highlight any immediate shortcomings, mistakes, or negative actions by the city council relevant to {question}; elaborate on the implications and broader societal or community impacts of the identified issues relevant to {question}; @@ -190,9 +190,25 @@ def get_indepth_response_from_query(df, db, query, k): The final output should be in paragraph form without any formatting, such as prefixing your points with "a.", "b.", or "c." The final output should not include any reference to the model's active sorting by date. + Please provide direct and concise responses without unnecessary verbosity. + + If your response includes technical or uncommon terms related to city council that may not be widely understood, kindly provide a brief definition for those terms at the end of your response using the following format: + + Definitions: + + [Word] + [Definition] + + [Word] + [Definition] + + The final output should be in paragraph form without any formatting, such as prefixing your points with "a.", "b.", or "c." + The final output should not include any reference to the model's active sorting by date. + Documents: {docs} """ + prompt = PromptTemplate( input_variables=["question", "docs"], template=template, From 712f6525b179c6b4aa924696417a0e6e1d1df98a Mon Sep 17 00:00:00 2001 From: hayden outlaw Date: Mon, 11 Dec 2023 14:41:45 -0600 Subject: [PATCH 3/8] fixing varied responses formatting --- .../googlecloud/functions/getanswer/process_public_queries.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/googlecloud/functions/getanswer/process_public_queries.py b/packages/googlecloud/functions/getanswer/process_public_queries.py index 32f080fc..9f2fcc9d 100644 --- a/packages/googlecloud/functions/getanswer/process_public_queries.py +++ b/packages/googlecloud/functions/getanswer/process_public_queries.py @@ -21,8 +21,8 @@ def make_api_call(title, k_inp): response = requests.post(f"{api_endpoint}", json=payload) rdict = json.loads(response.text) card_type_out = rdict["card_type"] - citations_out = rdict["citations"] - responses_out = rdict["responses"] + citations_out = json.dumps(eval(str(rdict["citations"]))) + responses_out = json.dumps(eval(str(rdict["responses"]))) return card_type_out, citations_out, responses_out, k_inp # Open CSV file in append mode From 63616ae2cee7b18f29781edee6628207467b37a3 Mon Sep 17 00:00:00 2001 From: Marvin Arnold Date: Tue, 12 Dec 2023 19:51:14 -0600 Subject: [PATCH 4/8] build: add version to feedback_cards --- .../migrations/20231213014353_versioned_feedback.sql | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 packages/web/supabase/migrations/20231213014353_versioned_feedback.sql diff --git a/packages/web/supabase/migrations/20231213014353_versioned_feedback.sql b/packages/web/supabase/migrations/20231213014353_versioned_feedback.sql new file mode 100644 index 00000000..e34ba8e2 --- /dev/null +++ b/packages/web/supabase/migrations/20231213014353_versioned_feedback.sql @@ -0,0 +1,7 @@ +alter table "public"."feedback_cards" add column "model_version" text; + +update feedback_cards +set + model_version = 'v0.0.1'; + +alter table "public"."feedback_cards" alter column "model_version" set not null; From a10dbc7cdd82591cfaa2a9591015c7bb775c56fb Mon Sep 17 00:00:00 2001 From: Ayyub Ibrahim Date: Tue, 12 Dec 2023 20:05:25 -0600 Subject: [PATCH 5/8] reset search bar after query finishes processes --- packages/web/components/NewQuery.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/web/components/NewQuery.tsx b/packages/web/components/NewQuery.tsx index 923dfdb4..67d90f9a 100644 --- a/packages/web/components/NewQuery.tsx +++ b/packages/web/components/NewQuery.tsx @@ -53,6 +53,7 @@ export default function NewQuery() { if (newCard) { await sendQueryToFunction(newCard); setCurrentCardId(newCard.id ?? null); + setQuery(''); } }; From 6e5b75981eb67e67103e4d25861137a271c0c719 Mon Sep 17 00:00:00 2001 From: Marvin Arnold Date: Wed, 13 Dec 2023 22:57:21 -0600 Subject: [PATCH 6/8] feat: filter feedback_cards by version --- packages/web/.env.example | 1 + packages/web/app/feedback/page.tsx | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/web/.env.example b/packages/web/.env.example index 2091845e..40653b63 100644 --- a/packages/web/.env.example +++ b/packages/web/.env.example @@ -2,3 +2,4 @@ NEXT_PUBLIC_SUPABASE_URL=https://xxxxxxxxxxx.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key NEXT_PUBLIC_TGI_API_ENDPOINT=http://localhost:8080 SUPABASE_SERVICE_ROLE_SECRET="" +NEXT_PUBLIC_FEEDBACK_VERSION=v0.0.2 diff --git a/packages/web/app/feedback/page.tsx b/packages/web/app/feedback/page.tsx index 141c08df..81b5a08c 100644 --- a/packages/web/app/feedback/page.tsx +++ b/packages/web/app/feedback/page.tsx @@ -69,13 +69,14 @@ export default function UserFeedback() { useEffect(() => { const getCard = async () => { const randId = randQuestionId(); - console.log("Fetching cards " + randId); + // console.log("Fetching cards " + randId); try { const cardsArray: Array> = []; const { data: newCards, error } = await supabase .from(TABLES.FEEDBACK_CARDS) .select("*") - .eq("question_id", randId); + .eq("question_id", randId) + .eq("model_version", process.env.NEXT_PUBLIC_FEEDBACK_VERSION); if (newCards) { setCards(newCards); } From 9d14e7f82c8c192185bd934161401644ed50d445 Mon Sep 17 00:00:00 2001 From: Marvin Arnold Date: Wed, 13 Dec 2023 23:05:10 -0600 Subject: [PATCH 7/8] feat: display version in feedback --- packages/web/app/feedback/page.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/web/app/feedback/page.tsx b/packages/web/app/feedback/page.tsx index 81b5a08c..6cf224bb 100644 --- a/packages/web/app/feedback/page.tsx +++ b/packages/web/app/feedback/page.tsx @@ -155,6 +155,10 @@ export default function UserFeedback() { Next question )} + +

+ {process.env.NEXT_PUBLIC_FEEDBACK_VERSION} +

From b2e0b59b3581555c50146c2dc49cf708c84b077e Mon Sep 17 00:00:00 2001 From: Marvin Arnold Date: Wed, 13 Dec 2023 23:09:07 -0600 Subject: [PATCH 8/8] fix: lower upper bound on feedback questions --- packages/web/app/feedback/page.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/web/app/feedback/page.tsx b/packages/web/app/feedback/page.tsx index 6cf224bb..dcc18992 100644 --- a/packages/web/app/feedback/page.tsx +++ b/packages/web/app/feedback/page.tsx @@ -36,16 +36,16 @@ export default function UserFeedback() { // }; const randQuestionId = () => { - return Math.floor(Math.random() * 291); + return Math.floor(Math.random() * 237); }; - const shuffleArray = (array: Number[]) => { - for (let i = array.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - [array[i], array[j]] = [array[j], array[i]]; - } - return array; - }; + // const shuffleArray = (array: Number[]) => { + // for (let i = array.length - 1; i > 0; i--) { + // const j = Math.floor(Math.random() * (i + 1)); + // [array[i], array[j]] = [array[j], array[i]]; + // } + // return array; + // }; // const shuffledQuestionIds = shuffleArray(question_idArray); const [currentIndex, setCurrentIndex] = useState(0);