pvanand commited on
Commit
7682cdd
·
1 Parent(s): b23e5f6

Update actions/actions.py

Browse files
Files changed (1) hide show
  1. actions/actions.py +28 -1
actions/actions.py CHANGED
@@ -125,4 +125,31 @@ class ActionCostClassify(Action):
125
  msg = "I'm sorry, I didn't understand your question. Could you please rephrase?"
126
  dispatcher.utter_message(text=msg)
127
 
128
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  msg = "I'm sorry, I didn't understand your question. Could you please rephrase?"
126
  dispatcher.utter_message(text=msg)
127
 
128
+ class SayHelloWorld(Action):
129
+
130
+ def name(self) -> Text:
131
+ return "hello_world"
132
+
133
+ def run(self,
134
+ dispatcher: CollectingDispatcher,
135
+ tracker: Tracker,
136
+ domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
137
+
138
+ # Use OpenAI API to generate a response
139
+ secret_value_0 = os.environ.get("openai")
140
+ openai.api_key = secret_value_0
141
+ model_engine = "text-davinci-002"
142
+ prompt_template = "Say hello world"
143
+
144
+ response = openai.Completion.create(
145
+ engine=model_engine,
146
+ prompt=prompt_template,
147
+ max_tokens=124,
148
+ temperature=0.8,
149
+ n=1,
150
+ stop=None,
151
+ )
152
+
153
+ # Output the generated response to user
154
+ generated_text = response.choices[0].text
155
+ dispatcher.utter_message(text=generated_text)