better error handling

This commit is contained in:
Falko Victor Habel 2024-05-19 15:33:03 +02:00
parent a86d15f99c
commit a37d3f121d
3 changed files with 8 additions and 8 deletions

View File

@ -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}"

View File

@ -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()

View File

@ -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}")