Skip to content

Commit

Permalink
poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
esteininger committed Mar 18, 2024
1 parent e89ffc2 commit 9db1e69
Show file tree
Hide file tree
Showing 6 changed files with 1,186 additions and 5 deletions.
46 changes: 46 additions & 0 deletions examples/.ipynb_checkpoints/dag-checkpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import requests
import json


def parse(file_url):
url = "http://localhost:8001/file"

payload = json.dumps({"file_url": file_url})
headers = {"Content-Type": "application/json"}

response = requests.request("POST", url, headers=headers, data=payload)

return response.json()


def embed(contents):
url = "http://0.0.0.0:8003/embed"

payload = json.dumps({"input": contents})
headers = {"Content-Type": "application/json"}

response = requests.request("GET", url, headers=headers, data=payload)

return response.json()


def insert(obj):
url = "http://0.0.0.0:8000/storage"

payload = json.dumps(obj)
headers = {"Content-Type": "application/json"}

response = requests.request("POST", url, headers=headers, data=payload)

return response.json()


# do dag here (this triggers from /listener via a message queue or CDC or webhook)
results = parse(
"https://athena-web-app-public-assets.s3.amazonaws.com/nux-tmp/R46947.pdf"
)

for result in results["response"]:
embedding = embed(result["text"])
result["embedding"] = embedding["response"]["embedding"]
insert(result)
Loading

0 comments on commit 9db1e69

Please sign in to comment.