Browse Source

remove unwanted comments

pull/124/head
266367 3 months ago
parent
commit
b9723acee1
  1. 8
      week1/community-contributions/wk1-day1-deepseek-stream-summarize.ipynb

8
week1/community-contributions/wk1-day1-deepseek-stream-summarize.ipynb

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

Loading…
Cancel
Save