LangChain is a framework for developing applications powered by language models. We believe that the most powerful and differentiated applications will not only call out to a language model via an api, but will also:
Be data-aware: connect a language model to other sources of data
Be agentic: Allow a language model to interact with its environment
> Entering new chain... I need to find the temperature first, then calculate the square root Action: Search Action Input: "Beijing yesterday highest temperature" Observation: Beijing Temperature Yesterday. Maximum temperature yesterday: 102 °F (at 5:00 pm) Minimum temperature yesterday: 72 °F (at 5:00 am) Average temperature ... Thought: I need to convert the temperature to Celsius Action: Calculator Action Input: 102 Fahrenheit to Celsius Observation: Answer: 38.888888888888886 Thought: I now need to calculate the square root Action: Calculator Action Input: 38.888888888888886^(1/2) Observation: Answer: 6.236095644623235 Thought: I now know the final answer Final Answer: The highest temperature in Beijing yesterday was 38.888888888888886°C and the square root of this number is 6.236095644623235.
> Finished chain. The highest temperature in Beijing yesterday was 38.888888888888886°C and the square root of this number is 6.236095644623235.
> Entering new chain... I need to find the highest temperature in Beijing yesterday and then calculate the square root of that number Action: duckduckgo_search Action Input: "Beijing highest temperature yesterday" Observation: By Reuters BEIJING, June 22 — The temperature in Beijing breached 106 degrees Fahrenheit on Thursday and shattered the record for the hottest day in June as heatwaves that had seared nort hern... On Friday, Beijing baked in temperatures as high as 40.3C, after sizzling at 41.1C on Thursday, the second-hottest day recorded by the Chinese capital in modern times. Beijing's all-time high of ... The city experienced its all-time recorded high of 41.9 C (107 F) on July 24, 1999. Chinese meteorologists say the current heat wave was caused by warm air masses associated with high-pressure ridges in the atmosphere, compounded by thin cloud covers and long daylight hours around the summer solstice. Last week, Beijing recorded its highest temperature for mid-June, with weather officials warning the public to stay indoors as the mercury hit 39.4C. With Agence France-Presse and Reuters... Beijing recorded a high temperature of 41.1 C yesterday (Jun 23) as the capital city continues to experience an ongoing heatwave, according to a report from Beijing News (新京报). This isn't the first time the city has seen the heat cranked up to over 41 C, but the first time it's happened in June. Thought: I now have the highest temperature in Beijing yesterday Action: Calculator Action Input: 41.1 Observation: Answer: 41.1 Thought: I now know the final answer Final Answer: The highest temperature in Beijing yesterday was 41.1°C and its square root is 6.4.
一次查询便得到了结果,效果似乎更好,不过日期错了,并不是昨天😭
也可以调用本地shell:
1 2 3 4 5 6 7 8 9 10
from langchain.llms import OpenAI from langchain.agents import initialize_agent, AgentType, load_tools
from langchain.prompts import (ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate, MessagesPlaceholder) from langchain.chains import ConversationChain from langchain.chat_models import ChatOpenAI from langchain.memory import ConversationBufferMemory