Skip to content

Dev #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Dev #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

#openaikey
openaiapikey.txt
19 changes: 18 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
from flask import Flask
from flask import Flask, request
from chatai import AI_Response

app = Flask(__name__)

@app.route("/api", methods=["GET", "POST"])
def hello():
if request.method == "GET":
data = request.args.get("prompt")
elif request.method == "POST":
jsondata = request.get_json()
data = jsondata["prompt"]

response = AI_Response(data)
return response

@app.route('/')
def hello_world():
return 'Hello, World!'


if __name__ == "__main__":
app.run()
12 changes: 12 additions & 0 deletions chatai.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
import openai

def AI_Response(text:str):
openai.api_key = os.environ.get("OPENAI_API_KEY")
response = openai.Completion.create(
model="text-davinci-003",
prompt=text,
max_tokens=100,
temperature=0
)
return response
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Flask
Gunicorn
numpy
openai