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