From 5ee250aed0ffe79d86db14093b13f4fe5d0d85be Mon Sep 17 00:00:00 2001 From: James Cacapit Date: Wed, 1 Oct 2025 21:18:11 -0700 Subject: [PATCH] add doc file and initial setup --- .gitignore | 1 + InitialSetupDoc.txt | 21 +++++++++++++++++++++ db.py | 8 ++++++-- main.py | 5 ++--- 4 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 InitialSetupDoc.txt diff --git a/.gitignore b/.gitignore index c3bc2ea..8bc6eab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ venv .env aws_lambda_artifact.zip +.pyc \ No newline at end of file diff --git a/InitialSetupDoc.txt b/InitialSetupDoc.txt new file mode 100644 index 0000000..d80f6ed --- /dev/null +++ b/InitialSetupDoc.txt @@ -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 \ No newline at end of file diff --git a/db.py b/db.py index d048a70..4ae8ac9 100644 --- a/db.py +++ b/db.py @@ -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: diff --git a/main.py b/main.py index f779e3f..dedaef5 100644 --- a/main.py +++ b/main.py @@ -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() @@ -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')