Skip to content

Commit

Permalink
feat: Added openai api key setting remote API
Browse files Browse the repository at this point in the history
  • Loading branch information
onuratakan committed Aug 6, 2024
1 parent 9346dbd commit 94b5e67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions gpt_computer_assistant/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,16 @@ def expand():
return jsonify({"response": "Expanded."})


@app.route("/save_openai_api_key", methods=["POST"])
def save_openai_api_key():
"""
This api saves the OpenAI API key
"""
data = request.json
openai_api_key = data["openai_api_key"]
from .utils.db import save_api_key
save_api_key(openai_api_key)
return jsonify({"response": "OpenAI API key saved."})

class ServerThread(threading.Thread):
def __init__(self, app, host, port):
Expand Down
5 changes: 5 additions & 0 deletions gpt_computer_assistant/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ def expand(self):
return response["response"]


def save_openai_api_key(self, openai_api_key):
data = {"openai_api_key": openai_api_key}
response = self.send_request("/save_openai_api_key", data)
return response["response"]


def wait(self, second):
time.sleep(second)
Expand Down

0 comments on commit 94b5e67

Please sign in to comment.