Langchain no longer works with OpenAI? All programs that worked correctly until a month ago no longer work. They all give me connection problems.
here a simple example. The Error it’s the same form any cide that use langchian.
The OpenAI API works fine from python.
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
import myConfig
llm = ChatOpenAI(openai_api_key=myConfig.api_key)
prompt = ChatPromptTemplate.from_messages([
("system", "You are world class technical documentation writer."),
("user", "{input}")
])
chain = prompt | llm
chain.invoke({"input": "how can langsmith help with testing?"})
output_parser = StrOutputParser()
chain = prompt | llm | output_parser
chain.invoke({"input": "how can langsmith help with testing?"})`
I get this error:
.......
File "C:GenAI.venvLibsite-packageshttpcore_exceptions.py", line 14, in map_exceptions
raise to_exc(exc) from exc
**httpcore.ConnectError: [WinError 10061] Impossibile stabilire la connessione. Rifiuto persistente del computer di destinazione
**
The above exception was the direct cause of the following exception:
........
File "C:GenAI.venvLibsite-packagesopenai_base_client.py", line 1053, in _retry_request
return self._request(
^^^^^^^^^^^^^^
File "C:GenAI.venvLibsite-packagesopenai_base_client.py", line 986, in _request
raise APIConnectionError(request=request) from err
**openai.APIConnectionError: Connection error**.
Any suggestion?
New contributor
Carlo P. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.