Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/ai-llm-bootcamp_001-langgraph-round2-esp.json

1 line
11 KiB
JSON

{"repo": "ai-llm-bootcamp/001-langgraph-round2-esp", "files": {".ipynb_checkpoints/zzz-nb-deepseek-checkpoint.ipynb": {"df2e27f07791d425e84014877f16fbce66197459": {"t": 1785745477.367488, "n": 10473, "h": "de4d44b5bb8cf199", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"id\": \"be46161e-45e9-46d7-8214-bcbea10aff2e\",\n \"metadata\": {},\n \"source\": [\n \"# DeepSeek: what you need to know about it and how to use it\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"b616bc01-46f8-4c59-b068-1400ef962dbf\",\n \"metadata\": {},\n \"source\": [\n \"## A quick intro: what is DeepSeek and why it has become so popular suddenly?\\n\",\n \"DeepSeek is a Chinese artificial intelligence company founded in 2023 by Liang Wenfeng, headquartered in Hangzhou, Zhejiang. The company focuses on developing open-source large language models (LLMs) and is solely funded by the hedge fund High-Flyer.\\n\",\n \"\\n\",\n \"One of DeepSeek's notable achievements is the development of the DeepSeek-R1 model, which offers performance comparable to leading models like OpenAI's GPT-4o. Remarkably, DeepSeek-R1 was trained at a cost of approximately `$6 million`, significantly lower than the estimated `$100 million` for similar models, and it requires only a tenth of the computing power.\\n\",\n \"\\n\",\n \"In January 2025, DeepSeek released a free chatbot app based on the DeepSeek-R1 model for iOS and Android platforms. By the end of that month, the app had surpassed ChatGPT as the most-downloaded free app on the U.S. iOS App Store, highlighting its rapid adoption and impact.\\n\",\n \"\\n\",\n \"Overall, DeepSeek has emerged as a significant player in the AI industry, challenging established competitors with its cost-effective and efficient approach to developing advanced language models.\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"424dee01-5af5-426b-a35e-37a83c0b47b0\",\n \"metadata\": {},\n \"source\": [\n \"## Why is Deepseek relevant for Generative AI Engineers?\\n\",\n \"The newest Deepseek model is very recent and the Gen AI community is still learning about it. There have been initial analysis that suggest that **the newest Deepseek model may be almost as good as the top OpenAI models, and using it may be way more cheaper for developers. Like 97% cheaper**. There have also been some questions about the security and privacy of the data introduced in the Deepseek model, since this is a Chinese company. As we say, Deepseek is still a very new player and we will see how it evolves, but our opinion is that **Gen AI Engineers must pay attention to this new scenario and start exploring Deepseek as a possible good alternative to OpenAI**. We are also expecting a bold reaction from OpenAI making their models more affordable for developers.\\n\",\n \"\\n\",\n \"Again, as of today DeepSeek offers a significantly more cost-effective solution for developers compared to OpenAI.\\n\",\n \"\\n\",\n \"OpenAI and DeepSeek offer large language models (LLMs) with distinct pricing structures, reflecting differences in their development costs and business models.\\n\",\n \"\\n\",\n \"Below we present the situation as it is in January 2025. Remember that Generative AI is the fastest-changing field in software, so the following data may have changed when you read this. Please make your own research to check the current status.\\n\",\n \"\\n\",\n \"**OpenAI:**\\n\",\n \"\\n\",\n \"- **Subscription Services:** OpenAI provides access to its models through subscription plans. For instance, ChatGPT Plus is available at `$20` per user per month, offering enhanced features and priority access to new capabilities.\\n\",\n \"\\n\",\n \"- **API Pricing:** OpenAI's API pricing varies by model and usage. For example, the GPT-4o model is priced at `$5` per million input tokens and `$20` per million output tokens. These rates can differ based on the specific model and its capabilities.\\n\",\n \"\\n\",\n \"**DeepSeek:**\\n\",\n \"\\n\",\n \"- **Open-Source Model:** DeepSeek has released its DeepSeek-R1 model as a free, open-source platform, allowing developers to access and modify the model without licensing fees.\\n\",\n \"\\n\",\n \"- **API Pricing:** For API access, DeepSeek offers competitive rates. As of February 8th, the pricing is set at `$0.27` per million input tokens and `$1.10` per million output tokens, with potential discounts for cache hits. \"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"b6a05b6b-43d2-4a8e-8f40-fef718a33f97\",\n \"metadata\": {},\n \"source\": [\n \"## How to use DeepSeek in your LangChain apps\\n\",\n \"* The LangChain-DeepSeek integration was enabled very recently. Because of that, it is likely we will see it evolve and improve in the near future. Remember the Gen AI Engineer path: study, research, experiment, and solve! Go for it! 💪\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"ee5ea6ed-7d17-4c45-b845-3940ad800dfc\",\n \"metadata\": {},\n \"source\": [\n \"## How to get your free Deepseek API Key\\n\",\n \"* Go to the [DeepSeek Website](https://www.deepseek.com/).\\n\",\n \"* Click on the right-top link API Platform.\\n\",\n \"* Register for free.\\n\",\n \"* Once registered, you will need to add some credit balance in the Billing section.\\n\",\n \"* To get your API Key, go to the sidebar link API keys and click on the Create new API key button.\\n\",\n \"* Copy the API key and paste it in your .env file next.\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"af743328-1bc8-4b01-85fb-fcb21c6499c2\",\n \"metadata\": {},\n \"source\": [\n \"## Create your .env file\\n\",\n \"* Remember to include:\\n\",\n \"* DEEPSEEK_API_KEY=your_deepseek_api_key\\n\",\n \"* LANGCHAIN_TRACING_V2=true\\n\",\n \"* LANGCHAIN_ENDPOINT=https://api.smith.langchain.com\\n\",\n \"* LANGCHAIN_API_KEY=your_langchain_api_key\\n\",\n \"* LANGCHAIN_PROJECT=your_project_name\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"40e766aa-f3e2-491f-be99-d0c6b700d47a\",\n \"metadata\": {},\n \"source\": [\n \"## Track operations\\n\",\n \"From now on, we can track the operations **and the cost** of this project from LangSmith:\\n\",\n \"* [smith.langchain.com](https://smith.langchain.com)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"4f99504a-1b8f-4360-b342-0b81ffa06aff\",\n \"metadata\": {},\n \"source\": [\n \"## Connect with the .env file located in the same directory of this notebook\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"e39e5789-5bde-42e1-88dd-92dc8e363c24\",\n \"metadata\": {},\n \"source\": [\n \"If you are using the pre-loaded poetry shell, you do not need to install the following package because it is already pre-loaded for you:\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"c5514113-ddca-4ae9-9de6-0b9225b18f3c\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"#pip install python-dotenv\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"49a1f935-c684-46a9-9e20-0d5391630ec5\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"import os\\n\",\n \"from dotenv import load_dotenv, find_dotenv\\n\",\n \"_ = load_dotenv(find_dotenv())\\n\",\n \"deepseek_api_key = os.environ[\\\"DEEPSEEK_API_KEY\\\"]\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"03f4a923-b19e-498e-9be5-e47ec4a77d80\",\n \"metadata\": {},\n \"source\": [\n \"#### Install LangChain\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"9fef1e5c-b7e2-4a04-96c5-8f64377b8eba\",\n \"metadata\": {},\n \"source\": [\n \"If you are using the pre-loaded poetry shell, you do not need to install the following package because it is already pre-loaded for you:\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": 3,\n \"id\": \"c1cf94ae-6c39-4475-9c5b-4b74d8d78753\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"#!pip install langchain\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"189e9e17-dfb0-4fd3-85b9-1fba83771941\",\n \"metadata\": {},\n \"source\": [\n \"## Connect with an LLM\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"b21d23f4-61f5-4227-8a75-7eefde6680ee\",\n \"metadata\": {},\n \"source\": [\n \"If you are using the pre-loaded poetry shell, you do not need to install the following package because it is already pre-loaded for you:\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"4fc427b9-bace-47cc-bb53-592b96b66cda\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"#pip install -qU langchain-deepseek-official\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"df978ec5-bfd2-4167-bd33-86bc2687d1cb\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"from langchain_deepseek import ChatDeepSeek\\n\",\n \"\\n\",\n \"llm = ChatDeepSeek(\\n\",\n \" model=\\\"deepseek-chat\\\",\\n\",\n \" temperature=0,\\n\",\n \" max_tokens=None,\\n\",\n \" timeout=None,\\n\",\n \" max_retries=2,\\n\",\n \" # other params...\\n\",\n \")\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"0380afb5-e980-4eef-8246-7cd3afb8fac5\",\n \"metadata\": {},\n \"source\": [\n \"## Invoke example\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"c9ede793-5085-45c8-b6b7-410966d3eb81\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"messages = [\\n\",\n \" (\\\"system\\\", \\\"You are a helpful translator. Translate the user sentence to French.\\\"),\\n\",\n \" (\\\"human\\\", \\\"I love programming.\\\"),\\n\",\n \"]\\n\",\n \"llm.invoke(messages)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"7222251f-a97f-4603-9438-c77ac7bff42e\",\n \"metadata\": {},\n \"source\": [\n \"## Stream example\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"f6651acc-8777-4726-bdef-3a0b0f8cdd66\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"for chunk in llm.stream(messages):\\n\",\n \" print(chunk)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"63500641-192b-4ffb-ac1d-d3836e2c2f48\",\n \"metadata\": {},\n \"source\": [\n \"## Additional operations\\n\",\n \"* See the [LangChain Documentation Page for ChatDeepSeek](https://python.langchain.com/api_reference/deepseek/chat_models/langchain_deepseek.chat_models.ChatDeepSeek.html).\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"19a3b3cc-6068-4788-8259-b841eda78df6\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": []\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \"Python 3 (ipykernel)\",\n \"language\": \"python\",\n \"name\": \"python3\"\n },\n \"language_info\": {\n \"codemirror_mode\": {\n \"name\": \"ipython\",\n \"version\": 3\n },\n \"file_extension\": \".py\",\n \"mimetype\": \"text/x-python\",\n \"name\": \"python\",\n \"nbconvert_exporter\": \"python\",\n \"pygments_lexer\": \"ipython3\",\n \"version\": \"3.12.5\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 5\n}\n"}}}}