|
|
|
@ -13,12 +13,11 @@
|
|
|
|
|
"from bs4 import BeautifulSoup\n", |
|
|
|
|
"from IPython.display import Markdown, display, clear_output\n", |
|
|
|
|
"from openai import OpenAI\n", |
|
|
|
|
"import time\n", |
|
|
|
|
"\n", |
|
|
|
|
"load_dotenv(override=True)\n", |
|
|
|
|
"api_key = os.getenv('DEEPSEEK_API_KEY')\n", |
|
|
|
|
"base_url=os.getenv('DEEPSEEK_BASE_URL')\n", |
|
|
|
|
"start_time = time.time()\n", |
|
|
|
|
"MODEL = \"deepseek-chat\"\n", |
|
|
|
|
"\n", |
|
|
|
|
"system_prompt = \"You are an assistant that analyzes the contents of a website \\\n", |
|
|
|
|
"and provides a short summary, ignoring text that might be navigation related. \\\n", |
|
|
|
@ -74,7 +73,7 @@
|
|
|
|
|
"def summarize(url):\n", |
|
|
|
|
" website = Website(url)\n", |
|
|
|
|
" response = openai.chat.completions.create(\n", |
|
|
|
|
" model=\"deepseek-chat\",\n", |
|
|
|
|
" model=MODEL,\n", |
|
|
|
|
" messages=messages_for(website),\n", |
|
|
|
|
" stream=True\n", |
|
|
|
|
" )\n", |
|
|
|
@ -86,9 +85,6 @@
|
|
|
|
|
" clear_output(wait=True) # Clear the previous output\n", |
|
|
|
|
" display(Markdown(accumulated_content)) # Display the updated content\n", |
|
|
|
|
"\n", |
|
|
|
|
" # # Final display (optional, as the loop already displays the content)\n", |
|
|
|
|
" # display(Markdown(accumulated_content))\n", |
|
|
|
|
"\n", |
|
|
|
|
"def display_summary():\n", |
|
|
|
|
" url = str(input(\"Enter the URL of the website you want to summarize: \"))\n", |
|
|
|
|
" summarize(url)\n", |
|
|
|
|