Skip to content

Commit

Permalink
fix mypy issues, ignore langchain missing imports
Browse files Browse the repository at this point in the history
  • Loading branch information
aleneum committed Dec 22, 2023
1 parent b6704b3 commit ee1484d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ ignore_missing_imports = True
[mypy-gradio.*]
ignore_missing_imports = True

[mypy-gradio.langchain.*]
ignore_missing_imports = True

;; gradio is not PEP 561 compliant (no py.typed) yet
[mypy-team_red.frontends.*]
disallow_any_unimported = False
17 changes: 10 additions & 7 deletions team_red/frontends/qa_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,20 @@ def query(question: str, search_type: str, k_source: int, search_strategy: str)
question=question, search_strategy=search_strategy, max_sources=k_source
)
if search_type == "LLM":
res = TRANSPORTER.qa_query(q)
if res.status != 200:
msg = f"Query was unsuccessful: {res.error_msg} (Error Code {res.status})"
qa_res = TRANSPORTER.qa_query(q)
if qa_res.status != 200:
msg = (
f"Query was unsuccessful: {qa_res.error_msg}"
f" (Error Code {qa_res.status})"
)
raise gr.Error(msg)
return res.answer
res = TRANSPORTER.db_query(q)
if not res:
return qa_res.answer
db_res = TRANSPORTER.db_query(q)
if not db_res:
msg = f"Database query returned empty!"
raise gr.Error(msg)
output = ""
for doc in res:
for doc in db_res:
output += f"{doc.content}\n"
output += f"({doc.name} / {doc.page})\n----------\n\n"
return output
Expand Down

0 comments on commit ee1484d

Please sign in to comment.