Laveraging OpenAI's Assistant API to create a PDF assistant that can help you with your PDFs.
Contributions are more than welcome using the "fork and pull request" workflow. Briefly:
<placeholder>-issueNumber
. Where placeholders can be develop
, bugfix
, documentation
only..env
file in the root directory with the following content:OPENAI_API_KEY=<your_openai_api_key>
ENVIRONMENT=<development|production>
FLASK_SECRET_KEY=<flask_secret> # You can generate this from the terminal (see below)
FLASK_DEBUG=<True|False>
FLASK_APP=main.py
FLASK_RUN_PORT=<port>
FLASK_SQLALCHEMY_DATABASE_URI=<database_uri>
FLASK_SQLALCHEMY_ECHO=<True|False>
FLASK_JWT_SECRET_KEY=<jwt_secret_key> # Generate this from flask shell (see below)
python -m venv venv
source venv/bin/activate
or .\venv\Scripts\activate
on Windowspip install -r requirements.txt
FLASK_APP
environment variable: cd src && <export|set> FLASK_APP=main.py
flask run
# Generate FLASK_SECRET_KEY
python -c 'import secrets; print(secrets.token_urlsafe(32))'
# Generate FLASK_JWT_SECRET_KEY
python -c 'import secrets; print(secrets.token_hex(12))'
# Setup the DB (SQLAlchemy)
flask shell
db # Access the SQLAlchemy database instance
from data.user_model import User
db.create_all()
app # Access the Flask application instance.
current_app # Access the current active Flask application.
g # Access the application’s context globals.
request # Access the incoming request object (only available during a request).
session # Access the user session data (only available during a request).
db # The SQLAlchemy database instance if you are using Flask-SQLAlchemy.
db.create_all() # Create all database tables defined in your models.
db.drop_all() # Drop all database tables.
db.session.add(instance) # Add an instance to the database session.
db.session.commit() # Commit the current transaction.
db.session.rollback() # Roll back the current transaction.
db.session.query(Model).all() # Query all records of a model.
db.session.delete(instance) # Delete an instance from the database.
Model.query.all() # Retrieve all records from the table associated with the model.
Model.query.filter_by(attribute=value).first() # Query records with specific criteria.
Model.query.get(id) # Retrieve a record by its primary key.
model_instance.save() # Save an instance (requires custom method in model).
model_instance.delete() # Delete an instance (requires custom method in model).
# Example
from data.user_model import User
user = User.query.filter_by(username='fatjonfreskina').first()