Skip to content

Commit

Permalink
LLM Suggestion local runs
Browse files Browse the repository at this point in the history
- Adds LLM feature to next
- Creates endpoints in flask
- Adds conditional logic checking for OPEN_API_KEY
- Update READEME.md
- Update env-config with next vars
  • Loading branch information
lukemun committed Dec 4, 2024
1 parent 7162f9d commit 988f12f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,8 @@ gcloud config list, to display current account

## Local Run with AI Suggestions

1. Add your OPENAI_API_KEY= to flask .env (personal one ATM)
2. Start flask locally (./deploy.sh --env=local flask)
3. Take note of where it's running (likey http://127.0.0.1:8080)
4. Change NEXT_PUBLIC_FLASK_BACKEND to the url from Step 3
5. Run the next server (npm run dev)
6. Get suggestion should show. Clicking it will go next client -> next server -> flask
1. Add your OPENAI_API_KEY= to local.env
2. Run next and flask (./deploy.sh --env=local next flask)
3. Get suggestion button should show automatically

On main page load, next will check with flask if it has the OPEN_API_KEY and conditionally show the get suggestion input.
4 changes: 2 additions & 2 deletions flask/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ def __init__(self, import_name, *args, **kwargs):
app = MyFlask(__name__)
CORS(app)

client = OpenAI(api_key= os.getenv("OPENAI_API_KEY"))


@app.route('/suggestion', methods=['GET'])
def suggestion():
print("got request")
print("got suggestion request")
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
sentry_sdk.metrics.incr(
key="endpoint_call",
value=1,
Expand Down
2 changes: 1 addition & 1 deletion next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dompurify": "^3.1.7"
},
"scripts": {
"dev": "next dev",
"dev": "NODE_OPTIONS='--dns-result-order=ipv4first' next dev",
"start": "next start",
"build": "prisma generate && next build",
"lint": "next lint",
Expand Down

0 comments on commit 988f12f

Please sign in to comment.