Fix: Update actions.py

#11
by pvanand - opened
Files changed (1) hide show
  1. actions/actions.py +2 -249
actions/actions.py CHANGED
@@ -12,7 +12,6 @@ import random
12
  import os
13
  import sys
14
  import openai
15
- import requests
16
 
17
  # Add "/app/actions" to the sys.path
18
  actions_path = os.path.abspath("/app/actions")
@@ -22,7 +21,6 @@ print("-#-System-path-#-")
22
  for path in sys.path:
23
  print(path)
24
  print("-#-END-OF-System-path-#-")
25
-
26
  # Import search_content.py from /actions folder
27
  from search_content import main_search
28
 
@@ -33,7 +31,7 @@ secret_value_0 = os.environ.get("openai")
33
  openai.api_key = secret_value_0
34
  # Provide your OpenAI API key
35
 
36
- def generate_openai_response(query, model_engine="text-davinci-002", max_tokens=124, temperature=0.8):
37
  """Generate a response using the OpenAI API."""
38
 
39
  # Run the main function from search_content.py and store the results in a variable
@@ -212,249 +210,4 @@ class SayHelloWorld(Action):
212
 
213
  # Output the generated response to user
214
  generated_text = response.choices[0].text
215
- dispatcher.utter_message(text=generated_text)
216
-
217
- ##----CIVIL SOCIETY-----DEB B-------------##
218
-
219
- class ActionCivilSocietyBenefitsOfAIEnabled(Action):
220
- def name(self) -> Text:
221
- return "action_civil_society_benefits_of_ai_enabled"
222
-
223
- def run(self, dispatcher: CollectingDispatcher,
224
- tracker: Tracker,
225
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
226
- response = "Organizations can 10x their impact by becoming AI-enabled through the Omdena platform. The platform offers access to a global AI community and diverse AI talent from around the world."
227
- dispatcher.utter_message(text=response)
228
- return []
229
-
230
- class ActionCivilSocietyOmdenaPlatformOffer(Action):
231
- def name(self) -> Text:
232
- return "action_civil_society_omdena_platform_offer"
233
-
234
- def run(self, dispatcher: CollectingDispatcher,
235
- tracker: Tracker,
236
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
237
- response = "The Omdena platform offers organizations a collaborative ecosystem for AI projects. It connects them with a global community of AI experts. Through this diverse talent pool, organizations can access valuable perspectives, knowledge, and skillsets needed to develop AI solutions tailored to their specific challenges."
238
- dispatcher.utter_message(text=response)
239
- return []
240
-
241
- class ActionCivilSocietyCaseStudies(Action):
242
- def name(self) -> Text:
243
- return "action_civil_society_case_studies"
244
-
245
- def run(self, dispatcher: CollectingDispatcher,
246
- tracker: Tracker,
247
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
248
- response = "Here are some case studies showcasing the impact of Omdena's AI-enabled solutions: \n\n Climate change: ...\n Mental health: ...\n AI Assisted Collaborative Mapping Tool: ..."
249
- dispatcher.utter_message(text=response)
250
- return []
251
-
252
- class ActionCivilSocietyGetTestimonials(Action):
253
- def name(self) -> Text:
254
- return "action_civil_society_get_testimonials"
255
-
256
- def run(self, dispatcher: CollectingDispatcher,
257
- tracker: Tracker,
258
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
259
- response = "Working with Omdena was a game-changer for organization. Their collaborative approach and access to diverse AI talent allowed us to tackle complex problems we couldn't solve on our own.\n\"- Jean Ayoub, International Social Service, CEO.\n\"The Omdena platform provided us with the AI expertise we needed to help tackle the devastating social and economic cost of road crashes. Amazing experts in AI, the projects brought deep expertise to measure the safety of the world's roads and save lives. Unique and valuable experience - Rob McInerney, CEP IRAP\""
260
- dispatcher.utter_message(text=response)
261
- return []
262
-
263
-
264
- class ActionCivilSocietyOutlineKeySteps(Action):
265
- def name(self) -> Text:
266
- return "action_civil_society_outline_key_steps"
267
-
268
- def run(self, dispatcher: CollectingDispatcher,
269
- tracker: Tracker,
270
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
271
- response = '''
272
- "The path to becoming an AI-enabled NGO involves several essential steps:
273
- Discover:
274
- The first step is to identify the problems or challenges that the NGO aims to address using AI.
275
- Simultaneously, the NGO needs to explore available data sources relevant to the identified problems.
276
- Agile Development:
277
- An initial innovation project is crucial to test and experiment with AI solutions. This short-term project helps the NGO explore different approaches to problem-solving using AI.
278
- Productionize:
279
- After successful proof of concept, the AI solution is transitioned into production. It is made accessible and usable by stakeholders to start generating real value.
280
- Capacity Building:
281
- To sustain AI initiatives, the NGO embarks on a larger project focused on building internal capacities. This includes developing technical skills among staff members, fostering collaboration and communication within the organization, and promoting problem-solving capabilities"
282
- '''
283
- dispatcher.utter_message(text=response)
284
- return []
285
-
286
- class ActionCivilSocietyExplainWorkingWithOmdena(Action):
287
- def name(self) -> Text:
288
- return "action_civil_society_explain_working_with_omdena"
289
-
290
- def run(self, dispatcher: CollectingDispatcher,
291
- tracker: Tracker,
292
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
293
- response = '''
294
- "Omdena offers various ways to collaborate and work together, each tailored to specific outcomes:
295
- AI Innovation Challenge:
296
- Through the AI Innovation Challenge, organizations can participate in collaborative projects with Omdena's diverse top talent teams. The outcome of this engagement is the development of AI models that address specific challenges. Each project involves 50 engineers contributing a total of 5000 hours of development time.
297
- Top Talent Teams:
298
- For organizations seeking AI products and solutions, Omdena provides dedicated top talent teams comprising 1 to 5 skilled engineers. These teams represent the top 2% of Omdena's talent pool, ensuring high-quality work and innovative results
299
- Hiring:
300
- Omdena also serves as a platform for organizations to find their next hire(s). Around 85% of startups"
301
- '''
302
- dispatcher.utter_message(text=response)
303
- return []
304
-
305
-
306
- class ActionCivilSocietyDescribeSuccessfulJourney(Action):
307
- def name(self) -> Text:
308
- return "action_civil_society_describe_successful_journey"
309
-
310
- def run(self, dispatcher: CollectingDispatcher,
311
- tracker: Tracker,
312
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
313
- response = '''
314
- "Over a span of 10 months, the World Resources Institute (WRI) embarked on a highly successful journey with Omdena, engaging in transformative AI innovation. The collaboration resulted in remarkable achievements, with significant impact and outcomes.
315
- Key highlights of the journey with Omdena are as follows:
316
- Duration: The collaboration between WRI and Omdena lasted for 10 months, allowing for comprehensive and in-depth exploration of various AI-driven initiatives.
317
- Innovation Projects: Throughout the partnership, WRI and Omdena actively collaborated on five innovation projects. These projects aimed to tackle complex environmental and sustainability challenges using AI-driven solutions.
318
- Products Developed: The collective effort of WRI and Omdena's talented teams led to the development of three AI products. These products were designed to address specific environmental issues, providing valuable insights and data-driven solutions.
319
- Funding Secured: The successful outcomes of the innovation projects and the potential of the AI products attracted interest and support from various stakeholders.
320
- Collaborators Involved: The journey witnessed the active involvement of more than 150 collaborators."
321
- '''
322
- dispatcher.utter_message(text=response)
323
- return []
324
-
325
-
326
- class ActionCivilSocietyDescribeCollaborationUpskilling(Action):
327
- def name(self) -> Text:
328
- return "action_civil_society_describe_collaboration_upskilling"
329
-
330
- def run(self, dispatcher: CollectingDispatcher,
331
- tracker: Tracker,
332
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
333
- response = '''
334
- "Omdena and WRI's teams are working closely together to provide upskilling opportunities for WRI's internal staff. Through this collaboration, WRI's staff gains valuable skills in managing and executing real-world AI projects successfully. This partnership empowers WRI to leverage AI technologies effectively to address environmental and sustainability challenges."
335
- '''
336
- dispatcher.utter_message(text=response)
337
- return []
338
-
339
-
340
- class ActionCivilSocietyDescribeCollaborationSuccess(Action):
341
- def name(self) -> Text:
342
- return "action_civil_society_describe_collaboration_success"
343
-
344
- def run(self, dispatcher: CollectingDispatcher,
345
- tracker: Tracker,
346
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
347
- response = '''
348
- "The collaboration between Omdena and WRI plays a crucial role in the successful execution of real-world AI projects. By giving WRI access to their knowledge base and tool partnerships, Omdena empowers WRI's teams with the necessary AI skills and resources. This ensures that AI projects are well-informed and guided by best practices."
349
- '''
350
- dispatcher.utter_message(text=response)
351
- return []
352
-
353
- class ActionCivilSocietyContactOmdena(Action):
354
- def name(self) -> Text:
355
- return "action_civil_society_contact_omdena"
356
-
357
- def run(self, dispatcher: CollectingDispatcher,
358
- tracker: Tracker,
359
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
360
- response = "Omdena Civil Society can be contacted through their website https://omdena.com/civil-society"
361
- dispatcher.utter_message(text=response)
362
- return []
363
-
364
- #Domain specific actions
365
- class ActionCivilSocietyHumanRightsPartners(Action):
366
- def name(self) -> Text:
367
- return "action_civil_society_human_rights_partners"
368
-
369
- def run(self, dispatcher: CollectingDispatcher,
370
- tracker: Tracker,
371
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
372
- response = '''
373
- "Amnesty International is a global human rights organization that works to protect individuals and groups who are denied basic rights. Omdena and Amnesty International have collaborated on a number of projects, including the development of a tool to track human rights abuses in Syria."
374
- "Human Rights Watch is a non-profit organization that monitors and reports on human rights abuses around the world. Omdena and Human Rights Watch have collaborated on a number of projects, including the development of a tool to track the use of torture in the Democratic Republic of Congo."
375
- "The Carter Center is a non-partisan organization that works to advance human rights and democracy around the world. Omdena and The Carter Center have collaborated on a number of projects, including the development of a tool to monitor elections in Kenya."
376
- "The Open Society Foundations is a philanthropic organization that supports projects that promote democracy, human rights, and justice around the world. Omdena and The Open Society Foundations have collaborated on a number of projects, including the development of a tool to track hate speech online."
377
- '''
378
- "One example of Omdena's work in the field of human rights is its collaboration with Amnesty International to develop a tool to track human rights abuses in Syria. The tool, called the Syriatracker, uses AI to collect and analyze data from social media and other sources to identify and document human rights abuses in Syria. "
379
- '''
380
- "Omdena's collaborations with human rights organizations have helped to develop powerful AI-powered tools that can be used to protect human rights and promote social justice. These tools have the potential to make a significant impact on the lives of people around the world who are denied basic rights."
381
- '''
382
- dispatcher.utter_message(text=response)
383
- return []
384
-
385
- class ActionCivilSocietyEnvironmentalSustainabilityPartners(Action):
386
- def name(self) -> Text:
387
- return "action_civil_society_environmental_sustainability_partners"
388
-
389
- def run(self, dispatcher: CollectingDispatcher,
390
- tracker: Tracker,
391
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
392
- response = '''
393
- "The Nature Conservancy: Omdena and The Nature Conservancy collaborated on a project to develop an AI-powered tool to track deforestation in the Amazon rainforest. The tool uses satellite imagery and machine learning to identify areas of deforestation. This information is used to help The Nature Conservancy to protect the rainforest and its inhabitants."
394
- '''
395
- '''
396
- "The World Resources Institute: Omdena and WRI collaborated on a project to develop an AI-powered tool to track water pollution in India. The tool uses satellite imagery and machine learning to identify areas of water pollution. This information is used to help WRI to protect India's water resources."
397
- '''
398
- '''
399
- "The United Nations Environment Programme: Omdena and UNEP collaborated on a project to develop an AI-powered tool to track climate change. The tool uses satellite imagery and machine learning to identify areas that are most vulnerable to climate change. This information is used to help UNEP to develop strategies to mitigate the effects of climate change."
400
- '''
401
- dispatcher.utter_message(text=response)
402
- return []
403
-
404
- class ActionCivilSocietyHealthcareAcessPartners(Action):
405
- def name(self) -> Text:
406
- return "action_civil_society_healthcare_access_partners"
407
-
408
- def run(self, dispatcher: CollectingDispatcher,
409
- tracker: Tracker,
410
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
411
- response = '''
412
- "Access to Maternal Care in Sub-Saharan Africa: Omdena collaborated with the African Medical and Research Foundation (AMREF) to develop an AI-powered tool to improve access to maternal care in sub-Saharan Africa. The tool uses data from mobile phones and other sources to identify pregnant women who are at risk of complications. This information is used to help AMREF to provide these women with the care they need."
413
- "AI-Powered Chatbot for Women's Mental Health Support: Omdena collaborated with the NGO Pratham to develop an AI-powered chatbot for women's mental health support. The chatbot uses natural language processing to provide women with support and resources for mental health. This information is used to help Pratham to provide more accessible mental health care to women in India"
414
- "Mitigating Implicit Biases in Healthcare: Omdena collaborated with the Mayo Clinic to develop an AI-powered tool to mitigate implicit biases in healthcare. The tool uses machine learning to identify and address biases in healthcare settings. This information is used to help the Mayo Clinic to provide more equitable care to all patients."
415
- '''
416
- dispatcher.utter_message(text=response)
417
- return []
418
-
419
- class ActionCivilSocietyMarginalizedCommunitiesPartners(Action):
420
- def name(self) -> Text:
421
- return "action_civil_society_marginalized_communities_partners"
422
-
423
- def run(self, dispatcher: CollectingDispatcher,
424
- tracker: Tracker,
425
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
426
- response = '''
427
- "Pratham is an NGO that works to improve education in India. Omdena and Pratham have collaborated on a number of projects, including the development of an AI-powered chatbot for women's mental health support."
428
- "UNDP is the United Nations Development Programme. Omdena and UNDP have collaborated on a project to develop an AI-powered tool to track the Sustainable Development Goals (SDGs)."
429
- '''
430
- dispatcher.utter_message(text=response)
431
- return []
432
-
433
- class ActionCivilSocietyEducationOpportunitiesPartners(Action):
434
- def name(self) -> Text:
435
- return "action_civil_society_education_opportunities_partners"
436
-
437
- def run(self, dispatcher: CollectingDispatcher,
438
- tracker: Tracker,
439
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
440
- response = '''"Aga Khan Foundation: Omdena and Aga Khan Foundation have collaborated on a project to develop an AI-powered tool to identify and address learning gaps in children. The tool uses machine learning to analyze data from student assessments and identify areas where children need additional support. This information is used to help Aga Khan Foundation to provide more personalized learning experiences for children."
441
- '''
442
- '''"UNESCO: Omdena and UNESCO have collaborated on a project to develop an AI-powered tool to track the progress of the Sustainable Development Goals (SDGs) in education. The tool uses data from a variety of sources to track the progress of the SDGs in education and identify areas where more work is needed. This information is used to help UNESCO to advocate for policies that will help to achieve the SDGs in education."
443
- '''
444
- dispatcher.utter_message(text=response)
445
- return []
446
-
447
- class ActionCivilSocietyGloabalIssuesPartners(Action):
448
- def name(self) -> Text:
449
- return "action_civil_society_global_issues_partners"
450
-
451
- def run(self, dispatcher: CollectingDispatcher,
452
- tracker: Tracker,
453
- domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
454
- response = '''
455
- "Education: Omdena is working with organizations to develop AI-powered tools that can help to improve access to education, identify and address learning gaps, and track the progress of the Sustainable Development Goals (SDGs) in education."
456
- "Healthcare: Omdena is working with organizations to develop AI-powered tools that can help to improve access to healthcare, mitigate implicit biases in healthcare, and track the spread of diseases."
457
- "Environment: Omdena is working with organizations to develop AI-powered tools that can help to track deforestation, water pollution, and climate change."
458
- '''
459
- dispatcher.utter_message(text=response)
460
- return []
 
12
  import os
13
  import sys
14
  import openai
 
15
 
16
  # Add "/app/actions" to the sys.path
17
  actions_path = os.path.abspath("/app/actions")
 
21
  for path in sys.path:
22
  print(path)
23
  print("-#-END-OF-System-path-#-")
 
24
  # Import search_content.py from /actions folder
25
  from search_content import main_search
26
 
 
31
  openai.api_key = secret_value_0
32
  # Provide your OpenAI API key
33
 
34
+ def generate_openai_response(query, model_engine="text-davinci-003", max_tokens=124, temperature=0.8):
35
  """Generate a response using the OpenAI API."""
36
 
37
  # Run the main function from search_content.py and store the results in a variable
 
210
 
211
  # Output the generated response to user
212
  generated_text = response.choices[0].text
213
+ dispatcher.utter_message(text=generated_text)