sattari commited on
Commit
bc6e9dd
1 Parent(s): 51578d3

Upgrade model to GPT4o, Improve Greeting Function, Active Italian Lang

Browse files
Files changed (1) hide show
  1. LegalBot.py +1 -55
LegalBot.py CHANGED
@@ -35,37 +35,6 @@ def law_content_splitter(path, splitter="CIVIL CODE"):
35
  text_splitter = CharacterTextSplitter()
36
  return text_splitter.create_documents(law_content_by_article)
37
 
38
- # #1
39
- # # Function to determine if input is a greeting
40
- # def is_greeting(input_str):
41
- # greetings = [
42
- # "hello",
43
- # "hi",
44
- # "hey",
45
- # "greetings",
46
- # "good morning",
47
- # "good afternoon",
48
- # "good evening",
49
- # "hi there",
50
- # "hello there",
51
- # "hey there",
52
- # "whats up",
53
- # "ciao",
54
- # "salve",
55
- # "buongiorno",
56
- # "buona sera",
57
- # "buonasera",
58
- # "buon pomeriggio",
59
- # "buonpomeriggio",
60
- # "come stai",
61
- # "comestai",
62
- # "come va",
63
- # "comeva",
64
- # "come sta",
65
- # "comesta",
66
- # ]
67
- # return any(greet in input_str.lower() for greet in greetings)
68
-
69
 
70
  # Function to handle chatbot logic
71
  def chatbot1(question):
@@ -74,18 +43,9 @@ def chatbot1(question):
74
  except Exception as e:
75
  return f"I'm sorry, I'm having trouble understanding your question. Error: {str(e)}"
76
 
77
- ## 2
78
- # def chatbot(input_str):
79
- # if is_greeting(input_str):
80
- # return "Hello! Ask me your question about Italian Divorce or Inheritance Law?"
81
- # else:
82
- # return chatbot1(input_str)
83
-
84
 
85
 
86
-
87
- #########################
88
- ### Improve Greeting
89
  # Define the greetings list at a global level
90
  greetings = [
91
  "hello",
@@ -132,20 +92,6 @@ def chatbot(input_str):
132
 
133
 
134
 
135
-
136
- ################
137
-
138
-
139
-
140
- # If you want to disable Greeting in the chatbot, use this code:
141
- # def chatbot(input_str):
142
- # # Directly process every input as a question
143
- # response = chatbot1(input_str)
144
- # if response == "N/A":
145
- # return "I'm sorry, I'm having trouble understanding your question. Could you please rephrase it or provide more context"
146
- # else:
147
- # return response
148
-
149
  # Splitting the content of law documents
150
  divorce_splitted = law_content_splitter(file1)
151
  inheritance_splitted = law_content_splitter(file2)
 
35
  text_splitter = CharacterTextSplitter()
36
  return text_splitter.create_documents(law_content_by_article)
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  # Function to handle chatbot logic
40
  def chatbot1(question):
 
43
  except Exception as e:
44
  return f"I'm sorry, I'm having trouble understanding your question. Error: {str(e)}"
45
 
 
 
 
 
 
 
 
46
 
47
 
48
+ ### Improve Greeting Function
 
 
49
  # Define the greetings list at a global level
50
  greetings = [
51
  "hello",
 
92
 
93
 
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  # Splitting the content of law documents
96
  divorce_splitted = law_content_splitter(file1)
97
  inheritance_splitted = law_content_splitter(file2)