import time
import os
import tiktoken
import openai
import json
from langchain.globals import set_llm_cache
from langchain_openai import OpenAI
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent, load_tools
from langchain_core.prompts import ChatPromptTemplate
from langchain.callbacks.manager import get_openai_callback
from typing import List
from langchain_core.messages import BaseMessage, ToolMessage
from langchain_core.language_models import BaseChatModel, SimpleChatModel
from langchain_core.messages import AIMessageChunk, BaseMessage, HumanMessage
from langchain_core.outputs import ChatGeneration, ChatGenerationChunk,ChatResult, Generation
from langchain_core.runnables import run_in_executor
from langsmith.wrappers import wrap_openai
from langsmith import traceable
from langsmith import Client
from langsmith.evaluation import evaluate
from langchain_groq import ChatGroq
from langchain_core.pydantic_v1 import BaseModel, Field
from langchain_core.tools import tool
from langchain_core.rate_limiters import InMemoryRateLimiter
from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough, RunnableLambda, RunnableParallel, RunnableGenerator
from langchain_community.llms.llamafile import Llamafile
from langchain_core.messages import (
AIMessage,
HumanMessage,
SystemMessage,
trim_messages,
filter_messages,
merge_message_runs,
)
from langchain_core.chat_history import InMemoryChatMessageHistory
from langchain_core.runnables.history import RunnableWithMessageHistory
from langchain_community.cache import SQLiteCache
from typing import Any, Dict, Iterator, List, Mapping, Optional, Iterable
from langchain_core.callbacks.manager import CallbackManagerForLLMRun
from langchain_core.language_models.llms import LLM
from langchain_core.outputs import GenerationChunk
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.prompts import PromptTemplate
from langchain_core.pydantic_v1 import BaseModel, Field, validator
from langchain.output_parsers.json import SimpleJsonOutputParser
from langchain_core.exceptions import OutputParserException
from langchain_community.document_loaders import UnstructuredHTMLLoader, BSHTMLLoader,UnstructuredMarkdownLoader
from langchain_core.documents import Document
from pathlib import Path
from pprint import pprint
from langchain_community.document_loaders import JSONLoader
The following code:
from langchain.output_parsers import PydanticOutputParser, YamlOutputParser,OutputFixingParser, RetryOutputParser, BaseOutputParser
from langchain_core.output_parsers import BaseOutputParser, BaseGenerationOutputParser, YamlOutputParser
Yaml Output parser is not available in langchain: langchain_core.output_parsers package & Base Output parser is not there in langchain.output_parsers.
Using google colab notebook with the following other packages & environment variables:
%pip install -qU langchain-openai %pip install -U langsmith %pip install "unstructured[md]" !pip install -qU langchain-community !pip install wikipedia !pip install langchain_groq !rm .langchain.db %pip install bs4
import time import os import tiktoken import openai import json
from langchain.globals import set_llm_cache from langchain_openai import OpenAI from langchain_core.pydantic_v1 import BaseModel, Field from langchain_openai import ChatOpenAI from langchain.agents import AgentExecutor, create_tool_calling_agent, load_tools from langchain_core.prompts import ChatPromptTemplate from langchain.callbacks.manager import get_openai_callback from typing import List from langchain_core.messages import BaseMessage, ToolMessage from langchain_core.language_models import BaseChatModel, SimpleChatModel from langchain_core.messages import AIMessageChunk, BaseMessage, HumanMessage from langchain_core.outputs import ChatGeneration, ChatGenerationChunk,ChatResult, Generation from langchain_core.runnables import run_in_executor from langsmith.wrappers import wrap_openai from langsmith import traceable from langsmith import Client from langsmith.evaluation import evaluate from langchain_groq import ChatGroq from langchain_core.pydantic_v1 import BaseModel, Field from langchain_core.tools import tool from langchain_core.rate_limiters import InMemoryRateLimiter from langchain_core.messages import AIMessage, HumanMessage, ToolMessage from langchain_core.prompts import ChatPromptTemplate from langchain_core.runnables import RunnablePassthrough, RunnableLambda, RunnableParallel, RunnableGenerator from langchain_community.llms.llamafile import Llamafile from langchain_core.messages import ( AIMessage, HumanMessage, SystemMessage, trim_messages, filter_messages, merge_message_runs, ) from langchain_core.chat_history import InMemoryChatMessageHistory from langchain_core.runnables.history import RunnableWithMessageHistory from langchain_community.cache import SQLiteCache from typing import Any, Dict, Iterator, List, Mapping, Optional, Iterable from langchain_core.callbacks.manager import CallbackManagerForLLMRun from langchain_core.language_models.llms import LLM from langchain_core.outputs import GenerationChunk from langchain_core.prompts import ChatPromptTemplate from langchain_core.prompts import PromptTemplate from langchain_core.pydantic_v1 import BaseModel, Field, validator from langchain.output_parsers.json import SimpleJsonOutputParser from langchain_core.exceptions import OutputParserException from langchain_community.document_loaders import UnstructuredHTMLLoader, BSHTMLLoader,UnstructuredMarkdownLoader from langchain_core.documents import Document from pathlib import Path from pprint import pprint from langchain_community.document_loaders import JSONLoader
& environment variables:
os.environ["GROQ_API_KEY"] = "**"
os.environ["LANGCHAIN_TRACING_V2"] = "true"
os.environ["LANGCHAIN_API_KEY"] = "**"
os.environ["TAVILY_API_KEY"] = "***"
os.environ["OPENAI_API_KEY"] = "*****"