-
Notifications
You must be signed in to change notification settings - Fork 231
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
43eeca1
commit 63be262
Showing
20 changed files
with
476 additions
and
30 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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
|
||
test/.env | ||
gp/* | ||
*.pyc | ||
dist/* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 发布 | ||
|
||
```bash | ||
# 发布pip库 | ||
poetry build -f sdist | ||
poetry publish | ||
``` | ||
|
||
# 测试 | ||
|
||
```shell | ||
# 新建python环境 | ||
python -m venv gp | ||
source gp/bin/activate | ||
|
||
# 临时取消python别名 (如果有) | ||
unalias python | ||
|
||
# 安装依赖 | ||
pip install . | ||
|
||
# 测试 | ||
cd test | ||
# 导出环境变量 | ||
export $(grep -v '^#' .env | sed 's/^export //g' | xargs) | ||
python test.py | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
---|---|---|
@@ -1,27 +1,33 @@ | ||
import os | ||
from gptpdf import parse_pdf | ||
|
||
path_load = lambda x: os.path.abspath(os.path.join(os.path.dirname(__file__), x)) | ||
pdf_path = path_load('../examples/attention_is_all_you_need.pdf') | ||
output_dir = path_load('../examples/attention_is_all_you_need/') | ||
|
||
# laod environment variables from .env file | ||
import dotenv | ||
dotenv.load_dotenv() | ||
|
||
def test_use_api_key(): | ||
api_key = 'your' | ||
base_url = 'your' | ||
content, image_paths = parse_pdf(pdf_path, output_dir, api_key, base_url) | ||
from gptpdf import parse_pdf | ||
pdf_path = '../examples/attention_is_all_you_need.pdf' | ||
output_dir = '../examples/attention_is_all_you_need/' | ||
api_key = os.getenv('OPENAI_API_KEY') | ||
base_url = os.getenv('OPENAI_API_BASE') | ||
# Manually provide OPENAI_API_KEY and OPEN_API_BASE | ||
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, api_key=api_key, base_url=base_url, model='gpt-4o') | ||
print(content) | ||
print(image_paths) | ||
# also output_dir/output.md is generated | ||
|
||
|
||
def test_use_env(): | ||
import dotenv | ||
dotenv.load_dotenv(path_load('./.env')) | ||
content, image_paths = parse_pdf(pdf_path, output_dir) | ||
from gptpdf import parse_pdf | ||
pdf_path = '../examples/attention_is_all_you_need.pdf' | ||
output_dir = '../examples/attention_is_all_you_need/' | ||
# Use OPENAI_API_KEY and OPENAI_API_BASE from environment variables | ||
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, model='gpt-4o', verbose=True) | ||
print(content) | ||
print(image_paths) | ||
# also output_dir/output.md is generated | ||
|
||
|
||
if __name__ == '__main__': | ||
# test_use_api_key() | ||
test_use_env() | ||
test_use_api_key() | ||
# test_use_env() |