Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Space Station Chatbot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dominic Daniel Krämer
Space Station Chatbot
Commits
2a659eda
Commit
2a659eda
authored
11 months ago
by
Dominic Daniel Krämer
Browse files
Options
Downloads
Patches
Plain Diff
add basic python logic for the current_iss_location action
parent
0e83d4f7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rasa/actions/actions.py
+26
-2
26 additions, 2 deletions
rasa/actions/actions.py
with
26 additions
and
2 deletions
rasa/actions/actions.py
+
26
−
2
View file @
2a659eda
...
...
@@ -2,7 +2,10 @@ from typing import Any, Text, Dict, List
from
rasa_sdk
import
Action
,
Tracker
from
rasa_sdk.executor
import
CollectingDispatcher
import
os.path
import
urllib.request
filepath
=
"
../data/iss-location.txt
"
class
ActionCurrentIssLocation
(
Action
):
...
...
@@ -12,8 +15,24 @@ class ActionCurrentIssLocation(Action):
def
run
(
self
,
dispatcher
:
CollectingDispatcher
,
tracker
:
Tracker
,
domain
:
Dict
[
Text
,
Any
])
->
List
[
Dict
[
Text
,
Any
]]:
dispatcher
.
utter_message
(
text
=
"
[Placeholder for the current ISS location]
"
)
# download (and replace) file
if
os
.
path
.
isfile
(
filepath
):
os
.
remove
(
filepath
)
urllib
.
request
.
urlretrieve
(
"
https://nasa-public-data.s3.amazonaws.com/iss-coords/current/ISS_OEM/ISS.OEM_J2K_EPH.txt
"
,
filepath
)
print
(
os
.
path
.
abspath
(
__file__
))
file
=
open
(
filepath
,
"
r
"
)
end_reached
=
False
location
=
""
for
line
in
file
:
if
end_reached
:
location
=
line
break
if
"
COMMENT End sequence of events
"
in
line
:
end_reached
=
True
dispatcher
.
utter_message
(
text
=
"
location:
"
+
location
)
return
[]
...
...
@@ -26,6 +45,11 @@ class ActionFutureIssLocation(Action):
tracker
:
Tracker
,
domain
:
Dict
[
Text
,
Any
])
->
List
[
Dict
[
Text
,
Any
]]:
# download (and replace) file
if
os
.
path
.
isfile
(
"
../../api-data/iss-location.txt
"
):
os
.
remove
(
"
../../api-data/iss-location.txt
"
)
urllib
.
request
.
urlretrieve
(
"
https://nasa-public-data.s3.amazonaws.com/iss-coords/current/ISS_OEM/ISS.OEM_J2K_EPH.txt
"
,
"
text.txt
"
)
if
(
len
(
tracker
.
latest_message
[
'
entities
'
])
==
0
):
dispatcher
.
utter_message
(
text
=
"
I
'
m sorry, but I didn
'
t understand your formatting. Please try again.
"
)
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment