Skip to content

LLMRequestsChain not enforcing headers when making http requestsย #6282

@paschembri

Description

@paschembri

System Info

LangChain version 0.0.201

Who can help?

@hwchase17 @agola

Information

  • The official example notebooks/scripts
  • My own modified scripts

Related Components

  • LLMs/Chat Models
  • Embedding Models
  • Prompts / Prompt Templates / Prompt Selectors
  • Output Parsers
  • Document Loaders
  • Vector Stores / Retrievers
  • Memory
  • Agents / Agent Executors
  • Tools / Toolkits
  • Chains
  • Callbacks/Tracing
  • Async

Reproduction

Based on the documentation example, run the following script:

from langchain.llms import OpenAI
from langchain.chains import LLMRequestsChain, LLMChain
from langchain.prompts import PromptTemplate

template = """Here is a company website content :
    ----
    {requests_result}
    ----
    We want to learn more about a company's activity and the kind of
    clients they target. Perform an analysis and write a short summary.
"""

PROMPT = PromptTemplate(
    input_variables=["requests_result"],
    template=template,
)

chain = LLMRequestsChain(llm_chain = LLMChain(llm=OpenAI(temperature=0), prompt=PROMPT))

print(chain.requests_wrapper)

Gives

python3 bug-langchain-requests.py
headers=None aiosession=None

Expected behavior

Provided headers should be enforced

python3 bug-langchain-requests.py
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'} aiosession=None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions