Skip to content
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 .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
venv
.env
aws_lambda_artifact.zip
.pyc
21 changes: 21 additions & 0 deletions InitialSetupDoc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Make sure you have python or python3 within visual studio code

pip should be installed by default

if not curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

then run pip install -r requirements.txt when you're in the root directory

you may need to install -m pip install pymysql and tavily-python

after you need to obtain the api key from tavily

for windows setx TAVILY_API_KEY "{API KEY HERE}" within environmental user variables along with the OPENAI_API_KEY

pip install uvicorn[standard] run main.py

the web browser will be something along the lines of 127.0.0.1.8000 and use the endpoints to switch to the proper route to debug

next would be to pip install passlib[bcrypt] so you can register properly with a hashed and salted password

uvicorn main:app --reload to launch the web browser
8 changes: 6 additions & 2 deletions db.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from sqlmodel import Session, create_engine
from sqlmodel import SQLModel, Session, create_engine

# name of the database to connect to
db = "users"

mysql_url = f"mysql+pymysql://root:password@IP_address:3306/{db}"



mysql_url = f"mysql+pymysql://root:xcr223@152.42.164.213:3306/{db}"
engine = create_engine(mysql_url, echo=True)
SQLModel.metadata.create_all(engine)

def get_session():
with Session(engine) as session:
Expand Down
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
from tools import *

# import asyncio
from openai import AsyncOpenAI
from openai.helpers import LocalAudioPlayer
from openai import OpenAI, AsyncOpenAI
from dotenv import load_dotenv
load_dotenv()

Expand Down Expand Up @@ -241,7 +240,7 @@ def chat_page(user: user_dependency, request: Request):
return RedirectResponse(url="/login", status_code=status.HTTP_302_FOUND)

@app.post("/chat", response_class=HTMLResponse)
async def chat(user: user_dependency, request: Request, user_input: Annotated[str, Form()], temperature: float = Form(...), chat_id: int | None = Form(None)):
async def chat(user: user_dependency, request: Request, user_input: Annotated[str, Form()], temperature: float = Form(...), chat_id: Optional[int] = Form(None)):

if user:
chat_id = user.get('id')
Expand Down