Skip to content

Add remote deployment URL support for openapi.yaml and ai-plugin.json #64

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 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REMOTE_URL="https://your-website.com"
7 changes: 7 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import json

import os
import quart
import quart_cors
from quart import request

REMOTE_URL = os.getenv('REMOTE_URL', None)

app = quart_cors.cors(quart.Quart(__name__), allow_origin="https://chat.openai.com")

# Keep track of todo's. Does not persist if Python session is restarted.
Expand Down Expand Up @@ -40,13 +43,17 @@ async def plugin_manifest():
host = request.headers['Host']
with open("./.well-known/ai-plugin.json") as f:
text = f.read()
if REMOTE_URL:
text = text.replace("http://localhost:5003", REMOTE_URL)
return quart.Response(text, mimetype="text/json")

@app.get("/openapi.yaml")
async def openapi_spec():
host = request.headers['Host']
with open("openapi.yaml") as f:
text = f.read()
if REMOTE_URL:
text = text.replace("http://localhost:5003", REMOTE_URL)
return quart.Response(text, mimetype="text/yaml")

def main():
Expand Down