generated from broomva/databricks_session
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from Broomva/feat/vortex-flows-prefect
Feat/vortex flows prefect
- Loading branch information
Showing
24 changed files
with
1,193 additions
and
57 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# prefect artifacts | ||
.prefectignore | ||
|
||
# python artifacts | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
*.egg-info/ | ||
*.egg | ||
|
||
# Type checking artifacts | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
.pyre/ | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
*.ipynb_checkpoints/* | ||
|
||
# Environments | ||
.python-version | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
|
||
# MacOS | ||
.DS_Store | ||
|
||
# Dask | ||
dask-worker-space/ | ||
|
||
# Editors | ||
.idea/ | ||
.vscode/ | ||
|
||
# VCS | ||
.git/ | ||
.hg/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from prefect.filesystems import GCS | ||
from dotenv import load_dotenv | ||
import os | ||
|
||
load_dotenv() | ||
|
||
block = GCS( | ||
bucket_path="vortex-flows/broomva-flows", | ||
service_account_info=os.environ.get("GCS_SERVICE_ACCOUNT"), | ||
project="broomva-vortex-ai", | ||
) | ||
block.save("gcs-vortex-flows", overwrite=True) | ||
|
||
# %% | ||
# # prefect deployment build web_rag.py:web_rag_flow --name web_rag_deployment --tag gcs-vortex-flows -sb gcs/gcs-vortex-flows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from prefect.filesystems import RemoteFileSystem | ||
import os | ||
|
||
minio_block = RemoteFileSystem( | ||
basepath=f"s3://vortex-flows/{os.environ.get('MINIO_FLOWS_FOLDER', 'broomva-flows')}", | ||
settings={ | ||
"key": os.environ.get("MINIO_USER", "minio"), | ||
"secret": os.environ.get("MINIO_PASSWORD", "minio123"), | ||
"client_kwargs": { | ||
"endpoint_url": os.environ.get("MINIO_HOST", "http://localhost:9001") | ||
}, | ||
}, | ||
) | ||
minio_block.save("minio") | ||
|
||
|
||
# prefect deployment build web_rag.py:web_rag_flow --name web_rag_deployment --tag minio -sb remote-file-system/minio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from prefect import task, flow | ||
from vortex.ai.tools import scrape_website, scrape_website_selenium | ||
from prefect.artifacts import create_markdown_artifact | ||
from vortex.flows.resources import OpenAIResource | ||
|
||
openai_resource = OpenAIResource() | ||
|
||
|
||
@task | ||
def get_article(input_url: str) -> str: | ||
if not input_url: | ||
return None | ||
try: | ||
try: | ||
response = scrape_website(input_url) | ||
except Exception: | ||
response = None | ||
if response is None: | ||
response = scrape_website_selenium(input_url) | ||
except Exception as e: | ||
raise e | ||
return response | ||
|
||
|
||
@task | ||
def summarize_article(article_text: str) -> str: | ||
if not article_text: | ||
return None | ||
user_query = f"Please generate a new fresh article of similar length based on this information: \n{article_text}" | ||
response = openai_resource.get(user_query) | ||
return response | ||
|
||
|
||
@flow(log_prints=True) | ||
def web_rag_flow(input_url: str = "https://github.com/Broomva/vortex"): | ||
article_text = get_article(input_url) | ||
article_summary = summarize_article(article_text) | ||
print(article_summary) | ||
|
||
|
||
if __name__ == "__main__": | ||
web_rag_flow.deploy( | ||
name="web-rag-flow", | ||
work_pool_name="broomva-worker", | ||
parameters={"input_url": "https://github.com/Broomva/vortex"}, | ||
) |
Empty file.
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters