Files changed (1) hide show
  1. app.py +21 -3
app.py CHANGED
@@ -15,6 +15,23 @@ def get_text():
15
  input_text = st.text_input("You: ", "", key="input")
16
  return input_text
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  def query(payload):
19
  response = requests.post(API_URL, headers=headers, json=payload)
20
  return response.json()
@@ -32,7 +49,7 @@ def translate(text,source="English",target="Moroccan Arabic"):
32
 
33
 
34
  # Function to generate a response from the chatbot
35
- def generate_response(user_input):
36
 
37
  user_input_translated = str(translate(user_input, "Moroccan Arabic", "English"))
38
  name = 'Mohammed'
@@ -51,7 +68,7 @@ def generate_response(user_input):
51
  <s> [INST] You are an agriculture expert, and my name is {name} Given the following informations, prevailing weather conditions, specific land type, chosen type of agriculture, and soil composition of a designated area, answer the question below
52
  Location: {location},
53
  Current Month : {date}
54
- land type: {soil_type}
55
  humidity: {humidity}
56
  weather: {weather}
57
  temperature: {temp}
@@ -116,6 +133,7 @@ def main():
116
  # sidebar_bg('bg.jpg')
117
  # Layout of input/response containers
118
  input_container = st.container()
 
119
 
120
  if st.button("Clear Chat"):
121
  st.session_state['past'] = []
@@ -137,7 +155,7 @@ def main():
137
  ## Conditional display of AI generated responses as a function of user provided prompts
138
  with response_container:
139
  if user_input:
140
- response = generate_response(user_input)
141
  st.session_state.past.append(user_input)
142
  st.session_state.generated.append(response)
143
 
 
15
  input_text = st.text_input("You: ", "", key="input")
16
  return input_text
17
 
18
+ soil_types = {
19
+ "Sais plain": "Brown limestone, vertisols, lithosols, and regosols",
20
+ "Chaouïa, Doukkala, and Abda plains": "Rendzines associated with lithosols in the Atlantic coast and isohumic and vertisols inland",
21
+ "Eastern High Plateaux and Moulouya Valley": "Sierozems and fluvisols",
22
+ "Rif": "Brown soils associated with lithosols and regosols or vertisols",
23
+ "Mamora and Zemmour plateau": "Sandy soil",
24
+ "Middle Atlas": "Brown soils and rendzinas",
25
+ "High Atlas": "Lithosols and regosols, in association with brown soils and sierozems",
26
+ "Loukkos": "Mostly gleysols and brunified",
27
+ "Rharb plain": "Gleysols and vertisols",
28
+ "Central plateau": "In forested areas, soils are brown associated with lithosols and regosols. Elsewhere (Zaer), vertisols and gleysols dominate",
29
+ "Plains and plateaux of north of the Atlas": "Lithosols (Rehamnas, Jebilete), sierozems associated with lithosols",
30
+ "Argan zone": "Soils are mostly lithosols and regosols, associated with fluvisols and saline soils on lowlands",
31
+ "Presaharan soils": "Lithosols and regosols in association with sierozems and regs",
32
+ "Saharan zone": "Yermosols, associated with sierozems, lithosols, and saline soils"
33
+ }
34
+
35
  def query(payload):
36
  response = requests.post(API_URL, headers=headers, json=payload)
37
  return response.json()
 
49
 
50
 
51
  # Function to generate a response from the chatbot
52
+ def generate_response(user_input,region):
53
 
54
  user_input_translated = str(translate(user_input, "Moroccan Arabic", "English"))
55
  name = 'Mohammed'
 
68
  <s> [INST] You are an agriculture expert, and my name is {name} Given the following informations, prevailing weather conditions, specific land type, chosen type of agriculture, and soil composition of a designated area, answer the question below
69
  Location: {location},
70
  Current Month : {date}
71
+ land type: {soil_types[region]}
72
  humidity: {humidity}
73
  weather: {weather}
74
  temperature: {temp}
 
133
  # sidebar_bg('bg.jpg')
134
  # Layout of input/response containers
135
  input_container = st.container()
136
+ selected_region = st.selectbox("Choose a region:", list(soil_types.keys()))
137
 
138
  if st.button("Clear Chat"):
139
  st.session_state['past'] = []
 
155
  ## Conditional display of AI generated responses as a function of user provided prompts
156
  with response_container:
157
  if user_input:
158
+ response = generate_response(user_input,str(selected_region))
159
  st.session_state.past.append(user_input)
160
  st.session_state.generated.append(response)
161