better error handling
This commit is contained in:
parent
a86d15f99c
commit
a37d3f121d
|
@ -36,5 +36,5 @@ class OllamaChatBot:
|
|||
messanges = self.messanges
|
||||
try:
|
||||
return self.ollama.invoke(messanges).content
|
||||
except ValueError:
|
||||
return "An unexpected Error occuried"
|
||||
except ValueError as e:
|
||||
return f"An unexpected Error occuried: {e}"
|
||||
|
|
|
@ -39,8 +39,8 @@ class ChatGUI(CTk.CTk):
|
|||
|
||||
else:
|
||||
return self.bot.get_request(prompt=prompt)
|
||||
except ValueError:
|
||||
return "An unexpected Error occuried"
|
||||
except ValueError as e:
|
||||
return f"An unexpected Error occuried: {e}"
|
||||
|
||||
def on_send(self, event=None):
|
||||
message = self.entry_bar.get().strip()
|
||||
|
|
|
@ -84,12 +84,12 @@ class Rag:
|
|||
return (False, "Success")
|
||||
else:
|
||||
return (True, f"'{file_path}' unsupported, read documentation for more information")
|
||||
except (ValueError, AttributeError):
|
||||
return (True, "An unexpected Error occuried")
|
||||
except (ValueError, AttributeError) as e:
|
||||
return (True, f"An unexpected Error occuried: {e}")
|
||||
def get_request(self, prompt):
|
||||
qachain=RetrievalQA.from_chain_type(self.chat_ollama, retriever=self.retriever)
|
||||
try:
|
||||
return qachain.invoke({"query": prompt})["result"]
|
||||
except ValueError:
|
||||
return (True, "An unexpected Error occuried")
|
||||
except ValueError as e:
|
||||
return (True, f"An unexpected Error occuried: {e}")
|
||||
|
Loading…
Reference in New Issue