Skip to content

Commit 5869def

Browse files
committed
Initial commit
0 parents  commit 5869def

8,705 files changed

Lines changed: 427493 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.breakpoints

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"files": {}
3+
}

.replit

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing
2+
run = "python3 app.py"
3+
4+
# The primary language of the repl. There can be others, though!
5+
language = "python3"
6+
entrypoint = "app.py"
7+
# A list of globs that specify which files and directories should
8+
# be hidden in the workspace.
9+
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]
10+
11+
# Specifies which nix channel to use when building the environment.
12+
[nix]
13+
channel = "stable-22_11"
14+
15+
# The command to start the interpreter.
16+
[interpreter]
17+
[interpreter.command]
18+
args = [
19+
"prybar-python310",
20+
"-q",
21+
"--ps1",
22+
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
23+
"-i",
24+
]
25+
env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }
26+
27+
[env]
28+
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
29+
PATH = "${VIRTUAL_ENV}/bin"
30+
PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.10/site-packages"
31+
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
32+
MPLBACKEND = "TkAgg"
33+
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"
34+
35+
# Enable unit tests. This is only supported for a few languages.
36+
[unitTest]
37+
language = "python3"
38+
39+
# Add a debugger!
40+
[debugger]
41+
support = true
42+
43+
# How to start the debugger.
44+
[debugger.interactive]
45+
transport = "localhost:0"
46+
startCommand = ["dap-python", "main.py"]
47+
48+
# How to communicate with the debugger.
49+
[debugger.interactive.integratedAdapter]
50+
dapTcpAddress = "localhost:0"
51+
52+
# How to tell the debugger to start a debugging session.
53+
[debugger.interactive.initializeMessage]
54+
command = "initialize"
55+
type = "request"
56+
57+
[debugger.interactive.initializeMessage.arguments]
58+
adapterID = "debugpy"
59+
clientID = "replit"
60+
clientName = "replit.com"
61+
columnsStartAt1 = true
62+
linesStartAt1 = true
63+
locale = "en-us"
64+
pathFormat = "path"
65+
supportsInvalidatedEvent = true
66+
supportsProgressReporting = true
67+
supportsRunInTerminalRequest = true
68+
supportsVariablePaging = true
69+
supportsVariableType = true
70+
71+
# How to tell the debugger to start the debuggee application.
72+
[debugger.interactive.launchMessage]
73+
command = "attach"
74+
type = "request"
75+
76+
[debugger.interactive.launchMessage.arguments]
77+
logging = {}
78+
79+
# Configures the packager.
80+
[packager]
81+
language = "python3"
82+
ignoredPackages = ["unit_tests"]
83+
84+
[packager.features]
85+
enabledForHosting = false
86+
# Enable searching packages from the sidebar.
87+
packageSearch = true
88+
# Enable guessing what packages are needed from the code.
89+
guessImports = true
90+
91+
# These are the files that need to be preserved when this
92+
# language template is used as the base language template
93+
# for Python repos imported from GitHub
94+
[gitHubImport]
95+
requiredFiles = [".replit", "replit.nix", ".config", "venv"]
96+
97+
[languages]
98+
99+
[languages.python3]
100+
pattern = "**/*.py"
101+
102+
[languages.python3.languageServer]
103+
start = "pylsp"

app.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import openai
2+
import os
3+
4+
openai.api_key = os.environ.get("OPENAI_API_KEY")
5+
6+
from flask import Flask, render_template, request, redirect, url_for, flash
7+
8+
app = Flask(__name__)
9+
app.secret_key = 'your_secret_key'
10+
11+
prompt_dict = {}
12+
13+
@app.route('/')
14+
def index():
15+
return render_template('index.html', prompts=prompt_dict)
16+
17+
@app.route('/add', methods=['POST'])
18+
def add_prompt():
19+
prompt = request.form['prompt'].strip()
20+
response = request.form['response'].strip()
21+
if prompt and response:
22+
prompt_dict[prompt] = response
23+
flash('Prompt added successfully.')
24+
else:
25+
flash('Prompt or response cannot be empty.')
26+
return redirect(url_for('index'))
27+
28+
if __name__ == '__main__':
29+
app.run(host='0.0.0.0', port=8080)
30+
31+
from flask import jsonify
32+
33+
@app.route('/gpt3', methods=['POST'])
34+
def gpt3():
35+
prompt = request.form['prompt']
36+
response = openai.Completion.create(
37+
engine="text-davinci-002",
38+
prompt=prompt,
39+
max_tokens=50,
40+
n=1,
41+
stop=None,
42+
temperature=0.5,
43+
)
44+
return jsonify(response.choices[0].text)

0 commit comments

Comments
 (0)