change to superset
Browse files- Dockerfile +7 -74
- main.py +65 -9
- requirements.txt +1 -0
Dockerfile
CHANGED
@@ -1,79 +1,12 @@
|
|
1 |
-
|
2 |
-
#
|
3 |
-
# WORKDIR /code
|
4 |
-
#
|
5 |
-
# COPY ./requirements.txt /code/requirements.txt
|
6 |
-
#
|
7 |
-
# RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
8 |
-
#
|
9 |
-
# COPY . .
|
10 |
-
#
|
11 |
-
# CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
12 |
-
# FROM grafana/grafana:latest
|
13 |
-
#
|
14 |
-
# ENV GF_SERVER_HTTP_PORT 7860
|
15 |
-
#
|
16 |
-
# CMD ["grafana-server", "--config=/etc/grafana/grafana.ini", "--homepath=/usr/share/grafana"]
|
17 |
-
|
18 |
-
# FROM jenkins/jenkins:lts
|
19 |
-
# USER root
|
20 |
-
#
|
21 |
-
# RUN chown -R jenkins:jenkins /var/jenkins_home
|
22 |
-
# ENV JENKINS_OPTS "--httpPort=80"
|
23 |
-
# USER jenkins
|
24 |
-
#
|
25 |
-
# # Install Jenkins plugins using install-plugins.sh
|
26 |
-
# RUN jenkins-plugin-cli --plugins "git:5.2.0 \
|
27 |
-
# workflow-step-api:639.v6eca_cd8c04a_a_ \
|
28 |
-
# ssh-credentials:308.ve4497b_ccd8f4 \
|
29 |
-
# workflow-scm-step:415.v434365564324 \
|
30 |
-
# docker-plugin:1.5 \
|
31 |
-
# docker-workflow:572.v950f58993843 \
|
32 |
-
# "
|
33 |
-
# ENV JENKINS_OPTS="--httpPort=7860"
|
34 |
-
#
|
35 |
-
# # CMD ["java", "-jar", "jenkins.war", "--httpPort=9090"]
|
36 |
-
# CMD ["java", "-jar", "/usr/share/jenkins/jenkins.war", "--httpPort=7860"]
|
37 |
-
|
38 |
-
|
39 |
-
# Use an official Python runtime as a parent image
|
40 |
-
FROM python:3.8-slim
|
41 |
-
|
42 |
-
# Set environment variables
|
43 |
-
ENV SUPERSET_HOME=/opt/superset
|
44 |
-
|
45 |
-
# Install system dependencies
|
46 |
-
RUN apt-get update -y && \
|
47 |
-
apt-get install -y build-essential libssl-dev libffi-dev libmysqlclient-dev libjpeg-dev libldap2-dev libsasl2-dev && \
|
48 |
-
apt-get clean
|
49 |
|
50 |
-
|
51 |
-
RUN pip install superset psycopg2-binary sqlalchemy-redshift mysqlclient pyldap flask-caching
|
52 |
|
53 |
-
|
54 |
-
RUN mkdir -p $SUPERSET_HOME
|
55 |
|
56 |
-
|
57 |
-
WORKDIR $SUPERSET_HOME
|
58 |
-
|
59 |
-
# Initialize the database
|
60 |
-
RUN superset db upgrade
|
61 |
-
|
62 |
-
# Create an admin user (replace these values with your own)
|
63 |
-
RUN superset fab create-admin \
|
64 |
-
--username admin \
|
65 |
-
--firstname Admin \
|
66 |
-
--lastname User \
|
67 |
-
--email admin@example.com \
|
68 |
-
--password admin
|
69 |
-
|
70 |
-
# Load some example data to play with (optional)
|
71 |
-
RUN superset load_examples
|
72 |
-
|
73 |
-
# Start Superset
|
74 |
-
CMD ["superset", "run", "-p", "7860", "--with-threads", "--reload"]
|
75 |
-
|
76 |
-
# Expose port 8088
|
77 |
-
EXPOSE 7860
|
78 |
|
|
|
79 |
|
|
|
|
|
|
1 |
+
FROM python:3.9
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
WORKDIR /code
|
|
|
4 |
|
5 |
+
COPY ./requirements.txt /code/requirements.txt
|
|
|
6 |
|
7 |
+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
+
COPY . .
|
10 |
|
11 |
+
CMD ["python", "main.py"]
|
12 |
+
# CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
main.py
CHANGED
@@ -1,15 +1,71 @@
|
|
1 |
-
from
|
|
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
|
8 |
-
|
9 |
-
def
|
10 |
-
return
|
11 |
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from telegram import ForceReply, Update
|
2 |
+
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters, InlineQueryHandler, CallbackContext
|
3 |
|
4 |
+
import openai
|
5 |
|
6 |
+
openai.api_key = "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"
|
7 |
+
messages = [
|
8 |
+
{
|
9 |
+
"role": "system",
|
10 |
+
"content": "Welcome to Grow Bot on telegram"
|
11 |
+
}
|
12 |
+
]
|
13 |
|
14 |
|
15 |
+
TOKEN= "6058469252:AAEIpuQPvhZfanC1nCrylNCjikYKcXmHMko"
|
16 |
+
def convert_text(text):
|
17 |
+
return text.replace("_", "\\_").replace("*", "\\*").replace("[", "\\[").replace("`", "\\`").replace(".", "\\.")
|
18 |
|
19 |
|
20 |
+
async def welcome_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
21 |
+
await update.message.reply_text("Welcome to Grow Bot!")
|
22 |
+
|
23 |
+
async def echo_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
24 |
+
input = update.message.text
|
25 |
+
messages.append(
|
26 |
+
{"role": "user", "content": input[6:]}
|
27 |
+
)
|
28 |
+
chat = openai.ChatCompletion.create(
|
29 |
+
model = "gpt-3.5-turbo", messages = messages
|
30 |
+
)
|
31 |
+
reply = chat.choices[0].message.content
|
32 |
+
print("Reply: ", reply)
|
33 |
+
|
34 |
+
await update.message.reply_markdown(f"{reply}")
|
35 |
+
# await update.message.reply_text(f"{reply}")
|
36 |
+
|
37 |
+
async def clear_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
38 |
+
messages = []
|
39 |
+
await update.message.reply_text("Clear context!")
|
40 |
+
async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
41 |
+
"""Send a message when the command /help is issued."""
|
42 |
+
await update.message.reply_text("Help!")
|
43 |
+
|
44 |
+
async def non_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
45 |
+
input = update.message.text
|
46 |
+
messages.append(
|
47 |
+
{"role": "user", "content": input}
|
48 |
+
)
|
49 |
+
chat = openai.ChatCompletion.create(
|
50 |
+
model = "gpt-3.5-turbo", messages = messages
|
51 |
+
)
|
52 |
+
messages[-1]["role"] = "assistant"
|
53 |
+
reply = chat.choices[0].message.content
|
54 |
+
print(f"Input: {input}, Reply: {reply}")
|
55 |
+
|
56 |
+
await update.message.reply_markdown(f"{reply}")
|
57 |
+
|
58 |
+
|
59 |
+
def main() -> None:
|
60 |
+
application = Application.builder().token(TOKEN).build()
|
61 |
+
application.add_handler(CommandHandler("welcome", welcome_command))
|
62 |
+
application.add_handler(CommandHandler("echo", echo_command))
|
63 |
+
application.add_handler(CommandHandler("clear", clear_command))
|
64 |
+
application.add_handler(CommandHandler("help", help_command))
|
65 |
+
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, non_command))
|
66 |
+
|
67 |
+
application.run_polling()
|
68 |
+
|
69 |
+
|
70 |
+
if __name__=='__main__':
|
71 |
+
main()
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
fastapi
|
2 |
uvicorn
|
|
|
|
1 |
fastapi
|
2 |
uvicorn
|
3 |
+
python-telegram-bot
|