Files
hack/tools/scripts/llm-key-hunter/results/_cache/content/adnansheikh08_python-with-langchain.json

1 line
6.5 KiB
JSON

{"repo": "adnansheikh08/python-with-langchain", "files": {"LangChains/generativeai/1-langchainintro.ipynb": {"1cacf29f077bfca0336775dcc8a4bbdccc64cc4e": {"t": 1785745501.0535226, "n": 5536, "h": "64f1a71166183849", "c": "{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"id\": \"07deea21\",\n \"metadata\": {},\n \"source\": [\n \"### Langchain Version V1\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"5029310a\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"import langchain\\n\",\n \"print(langchain.__version__)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"9653db05\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"import os \\n\",\n \"from dotenv import load_dotenv\\n\",\n \"load_dotenv()\\n\",\n \"\\n\",\n \"os.environ[\\\"GROQ_API_KEY\\\"] = os.getenv(\\\"GROQ_API_KEY\\\")\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"3d970d56\",\n \"metadata\": {},\n \"source\": [\n \"### Generative AI application using Agents using Google Gemini\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"28d9ecd6\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"os.environ[\\\"GOOGLE_API_KEY\\\"]=os.getenv(\\\"GOOGLE_API_KEY\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"fcc34382\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"from langchain.chat_models import init_chat_model\\n\",\n \"model = init_chat_model(\\\"google_genai:gemini-2.5-flash-lite\\\")\\n\",\n \"response = model.invoke(\\\"Hello, how are you?\\\")\\n\",\n \"print(response.content)\\n\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"f3c144a3\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"from langchain_google_genai import ChatGoogleGenerativeAI\\n\",\n \"model = ChatGoogleGenerativeAI(model=\\\"gemini-2.5-flash-lite\\\")\\n\",\n \"response = model.invoke(\\\"Hello, who do you think is the Current President of the United States?\\\")\\n\",\n \"print(response.content)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"6187a62c\",\n \"metadata\": {},\n \"source\": [\n \"### Generative AI integration using Groq\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"2efbcf37\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"import os \\n\",\n \"from langchain.chat_models import init_chat_model\\n\",\n \"os.environ[\\\"GROQ_API_KEY\\\"] = os.getenv(\\\"GROQ_API_KEY\\\")\\n\",\n \"\\n\",\n \"model = init_chat_model(\\\"groq:llama-3.1-8b-instant\\\")\\n\",\n \"response =model.invoke(\\\"Tell me a joke\\\")\\n\",\n \"\\n\",\n \"print(response.content)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"06d0ed24\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"import os \\n\",\n \"from langchain_groq import ChatGroq\\n\",\n \"model = ChatGroq(model=\\\"qwen/qwen3-32b\\\")\\n\",\n \"response = model.invoke(\\\"What is the capital of France?\\\")\\n\",\n \"print(response.content)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"bf2969b2\",\n \"metadata\": {},\n \"source\": [\n \"### Generative AI with Deepseek API\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"08873645\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"os.environ[\\\"DEEPSEEK_API_KEY\\\"]=os.getenv(\\\"DEEPSEEK_API_KEY\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"8e9cf562\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"from langchain.chat_models import init_chat_model\\n\",\n \"model = init_chat_model(\\n\",\n \" \\\"deepseek-chat\\\",\\n\",\n \" model_provider=\\\"openai\\\",\\n\",\n \" api_key=os.getenv(\\\"DEEPSEEK_API_KEY\\\"),\\n\",\n \" base_url=\\\"https://api.deepseek.com\\\"\\n\",\n \")\\n\",\n \"\\n\",\n \"response = model.invoke(\\\"Tell me a joke\\\")\\n\",\n \"\\n\",\n \"print(response.content)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"68443c73\",\n \"metadata\": {},\n \"source\": [\n \"### Streaming and Batch\\n\",\n \"\\n\",\n \"### Streaming \\n\",\n \"Most models can stream their output content while it is being generated.\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"a11376ec\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"model.invoke(\\\"write me a 500 word essay on India\\\")\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"29428160\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"for chunk in model.stream(\\\"write me a 500 word essay on India\\\"):\\n\",\n \" print(chunk.text, end=\\\"\\\",flush=True)\"\n ]\n },\n {\n \"cell_type\": \"markdown\",\n \"id\": \"8d9ee5a3\",\n \"metadata\": {},\n \"source\": [\n \"### Batch \\n\",\n \"Batching a collection of inpedependence requests to a model can significantly improve performance and reduce costs.\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"9ae87ce1\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": [\n \"responses = model.batch(\\n\",\n \" [\\n\",\n \" \\\"What is your name?\\\",\\n\",\n \" \\\"What is the capital of France?\\\",\\n\",\n \" \\\"What is the weather in Lucknow?\\\"\\n\",\n \" ]\\n\",\n \")\\n\",\n \"for response in responses:\\n\",\n \" print(response.content)\"\n ]\n },\n {\n \"cell_type\": \"code\",\n \"execution_count\": null,\n \"id\": \"7faa90a4\",\n \"metadata\": {},\n \"outputs\": [],\n \"source\": []\n }\n ],\n \"metadata\": {\n \"kernelspec\": {\n \"display_name\": \".venv\",\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.14.3\"\n }\n },\n \"nbformat\": 4,\n \"nbformat_minor\": 5\n}\n"}}}}