Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python SDK & bash script #22

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions extract_parse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ apiKey="$1"
func="$2"
file_path="$3"

upload
if [ "$func" == "extract" ]; then
upload
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qq: should upload out of the if, elif, so upload will also apply for parse logic?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm. It looks like this is a bug in previous code.

extract
elif [ "$func" == "parse" ]; then
prompt="$4"
mode="$5"
if [ -z "$mode" ] || [ "$mode" == "" ] || [ "$mode" == "advanced" ]; then
textract=true
textract="True"
else
textract=false
textract="False"
fi
upload
parse
Expand Down
4 changes: 2 additions & 2 deletions open_parser/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def setAPIKey(self, apiKey):
def extract(self, file_path):
user_id, job_id, s3_key = self._request_and_upload_by_apiKey(file_path)
result = self._request_file_extraction(user_id, job_id, s3_key)
return json.loads(result)["result"]["file_content"]
return json.loads(result)["result"]

def parse(self, file_path, prompt, mode="advanced"):
user_id, job_id, s3_key = self._request_and_upload_by_apiKey(file_path)
Expand Down Expand Up @@ -85,7 +85,7 @@ def _request_info_extraction(self, user_id, job_id, s3_key, mode, prompt=""):
"jobId": job_id,
"fileKey": s3_key,
"user_prompt": prompt,
"use_textract": True if mode == "advanced" else False,
"use_textract": "True" if mode == "advanced" else "False",
}
response = requests.post(
self._parseurl, headers=self._request_header, json=payload
Expand Down
2 changes: 1 addition & 1 deletion open_parser_base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ extract() {
-d "$payload" \
"$EXTRACT_URL")

result=$(echo "$response" | jq -r '.result.file_content')
result=$(echo "$response" | jq -r '.result')
}

parse() {
Expand Down
2 changes: 1 addition & 1 deletion parse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fi
apiKey="$1"
file_path="$2"
prompt="$3"
textract=false
textract="False"

echo "Parsing $file_path..."

Expand Down
Loading