|
import os
|
|
|
|
|
|
import dotenv
|
|
dotenv.load_dotenv()
|
|
|
|
pdf_path = r"F:\桌面文件\composes测试\Desktop\2005C:雨量预报方法优劣的评价模型.pdf"
|
|
output_dir = r'F:\桌面文件\我的vue项目\文档翻译项目\后端重构-api项目\storage\translate'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_use_api_key():
|
|
from gptpdf import parse_pdf
|
|
api_key = os.getenv('OPENAI_API_KEY')
|
|
base_url = os.getenv('OPENAI_API_BASE')
|
|
|
|
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, api_key=api_key, base_url=base_url, model='gpt-4o', gpt_worker=6)
|
|
print(content)
|
|
print(image_paths)
|
|
|
|
|
|
|
|
def test_use_env():
|
|
from gptpdf import parse_pdf
|
|
|
|
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, model='gpt-4o', verbose=True)
|
|
print(content)
|
|
print(image_paths)
|
|
|
|
|
|
|
|
def test_azure():
|
|
from pdf_parse import parse_pdf
|
|
api_key = '8ef0b4df45e444079cd5a4xxxxx'
|
|
base_url = 'https://xxx.openai.azure.com/'
|
|
model = 'azure_xxxx'
|
|
|
|
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, api_key=api_key, base_url=base_url, model=model, verbose=True)
|
|
print(content)
|
|
print(image_paths)
|
|
|
|
def test_qwen_vl_max():
|
|
from pdf_parse import parse_pdf
|
|
api_key = '28032c969954994065d5520e1155418b.u8iXzIijE3qvkXsZ'
|
|
base_url = "https://open.bigmodel.cn/api/paas/v4"
|
|
model = 'glm-4v-flash'
|
|
content, image_paths = parse_pdf(pdf_path, output_dir=output_dir, api_key=api_key, base_url=base_url, model=model, verbose=True, temperature=0.5, max_tokens=1000, top_p=0.9, frequency_penalty=1)
|
|
print(content)
|
|
print(image_paths)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
|
|
test_qwen_vl_max() |