-
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.
- Loading branch information
1 parent
e89ffc2
commit 9db1e69
Showing
6 changed files
with
1,186 additions
and
5 deletions.
There are no files selected for viewing
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 @@ | ||
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) |
Oops, something went wrong.