Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,25 +44,6 @@ def handle_event():
|
|
| 44 |
return (
|
| 45 |
challenge
|
| 46 |
)
|
| 47 |
-
if event=='app_mention':
|
| 48 |
-
API_KEY=os.environ.get('SLACK_APP_TOKEN')
|
| 49 |
-
SLACK_CHANNEL=os.environ.get('SLACK_APP_CHANNEL')
|
| 50 |
-
# Set up the Slack client
|
| 51 |
-
YOUR_BOT_TOKEN=API_KEY
|
| 52 |
-
client = WebClient(token=YOUR_BOT_TOKEN)
|
| 53 |
-
channel= SLACK_CHANNEL
|
| 54 |
-
conversation = request.json['text']
|
| 55 |
-
print(conversation)
|
| 56 |
-
response=text_generate(conversation)
|
| 57 |
-
# Post the response back to the Slack channel
|
| 58 |
-
try:
|
| 59 |
-
client.chat_postMessage(
|
| 60 |
-
channel='#chat-gpt-bot',
|
| 61 |
-
text=response
|
| 62 |
-
)
|
| 63 |
-
except SlackApiError as e:
|
| 64 |
-
response="Error"
|
| 65 |
-
return response
|
| 66 |
if event=='event_callback':
|
| 67 |
API_KEY=os.environ.get('SLACK_APP_TOKEN')
|
| 68 |
SLACK_CHANNEL=os.environ.get('SLACK_APP_CHANNEL')
|
|
@@ -70,6 +51,7 @@ def handle_event():
|
|
| 70 |
YOUR_BOT_TOKEN=API_KEY
|
| 71 |
client = WebClient(token=YOUR_BOT_TOKEN)
|
| 72 |
channel= SLACK_CHANNEL
|
|
|
|
| 73 |
conversation = request.json['event'] ['text']
|
| 74 |
print(conversation)
|
| 75 |
response=search_knowledge(conversation)
|
|
|
|
| 44 |
return (
|
| 45 |
challenge
|
| 46 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
if event=='event_callback':
|
| 48 |
API_KEY=os.environ.get('SLACK_APP_TOKEN')
|
| 49 |
SLACK_CHANNEL=os.environ.get('SLACK_APP_CHANNEL')
|
|
|
|
| 51 |
YOUR_BOT_TOKEN=API_KEY
|
| 52 |
client = WebClient(token=YOUR_BOT_TOKEN)
|
| 53 |
channel= SLACK_CHANNEL
|
| 54 |
+
print(channel)
|
| 55 |
conversation = request.json['event'] ['text']
|
| 56 |
print(conversation)
|
| 57 |
response=search_knowledge(conversation)
|