Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
C Cheng committed Dec 19, 2024
1 parent c2d6ab5 commit 25cdf59
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/src/chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ class Citation(BaseModel):

@staticmethod
def format_highlighted_uri(source_url: str, subsection_text: str) -> str:
if not source_url:
return None
citation_without_special_chars = re.sub(r"\W+", " ", subsection_text).strip()
citation_arr = citation_without_special_chars.split(" ")
formatted_text_to_highlight = (
Expand Down Expand Up @@ -316,7 +318,6 @@ async def run_query(
logger.info("Response: %s", result.response)

final_result = simplify_citation_numbers(result)
print(final_result.subsections)
citations = [Citation.from_subsection(subsection) for subsection in final_result.subsections]
return QueryResponse(response_text=final_result.response, citations=citations)

Expand Down
3 changes: 1 addition & 2 deletions app/tests/src/test_chat_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ def test_citation_formatting():
subsection_text = "* [CalFresh](https://www.getcalfresh.org/?source=edd) (formerly known as Food Stamps) \n CalFresh provides monthly food assistance to people and families with low income, including those who lost their job because of the pandemic. Visit [GetCalFresh.org](https://www.getcalfresh.org/?source=edd) to apply online.\n* [California Association of Food Banks](http://www.cafoodbanks.org/) \n In California, federal, state, and local community organizations coordinate to make sure that groceries are available at local food banks.\n* [Free Summer Lunch Programs](http://www.cde.ca.gov/ds/sh/sn/summersites.asp) \n Free lunches are available to all children under 18, regardless of income.\n* [School Meals](https://www.fns.usda.gov/school-meals/applying-free-and-reduced-price-school-meals) \n Free or reduced-price breakfast and lunch at public schools when in session.\n* [Women, Infants and Children (WIC) Program](https://www.cdph.ca.gov/Programs/CFH/DWICSN/Pages/Program-Landing1.aspx) \n Pregnant women and children under age 5 receive nutrition support at WIC."
source_url = "https://edd.ca.gov/en/disability/options_to_file_for_pfl_benefits/"
highlighted_url = Citation.format_highlighted_uri(source_url, subsection_text)
assert "*" not in highlighted_url
assert " " not in highlighted_url

assert (
highlighted_url
== "https://edd.ca.gov/en/about_edd/additional_resources#:~:text=CalFresh%20https%20www%20getcalfresh%20org,receive%20nutrition%20support%20at%20WIC"
Expand Down

0 comments on commit 25cdf59

Please sign in to comment.