Files
wehub-resource-sync e768098d0e
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:39:52 +08:00

61 lines
1.6 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from main import chat_with_pdf, print_stream_and_return_full_answer\n",
"from dotenv import load_dotenv\n",
"\n",
"load_dotenv()\n",
"\n",
"bert_paper_url = \"https://arxiv.org/pdf/1810.04805.pdf\"\n",
"questions = [\n",
" \"what is BERT?\",\n",
" \"what NLP tasks does it perform well?\",\n",
" \"is BERT suitable for NER?\",\n",
" \"is it better than GPT\",\n",
" \"when was GPT come up?\",\n",
" \"when was BERT come up?\",\n",
" \"so about same time?\",\n",
"]\n",
"\n",
"history = []\n",
"for q in questions:\n",
" stream, context = chat_with_pdf(q, bert_paper_url, history)\n",
" print(\"User: \" + q, flush=True)\n",
" print(\"Bot: \", end=\"\", flush=True)\n",
" answer = print_stream_and_return_full_answer(stream)\n",
" history = history + [\n",
" {\"role\": \"user\", \"content\": q},\n",
" {\"role\": \"assistant\", \"content\": answer},\n",
" ]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "pf",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.17"
},
"stage": "development"
},
"nbformat": 4,
"nbformat_minor": 2
}