Open Ai/Langchain/
2023-06-15T05:38:37.634438Z
Published on
Since the introduction of chatGPT text-based generative AI developed by Open Ai uses pre-trained neural networks to generate more personalized responses. The Ai model has been trained on a vast amount of data including text, articles, news articles, and websites.
Although it’s trained on huge amounts of data its knowledge database is limited to 2021. No recent or latest data is not updated on the Ai model. Thus I can’t ask a question happening after 2021 simply it says the data it can access is limited to 2021.
In conclusion, ChatGPT is an impressive technology that has the potential to revolutionize the way we interact with AI systems. With its ability to understand natural language, personalize responses, and continually learn and improve, it has opened up exciting opportunities for businesses and individuals alike.
Navigate to https://platform.openai.com/docs/introduction
Signup for an account.
Purchase an API key.
copy the API key and store it in a secure place.
We can’t access Google Search directly using API because they don’t provide API access. SerpAPI is a third API service that provides access to the Google search engine via API.
Navigate to https://serpapi.com/
Signup for an account.
Purchase an API key.
copy the API key and store it in a secure place.
Install the following Python packages
Open AI
pip install openai
Langchain
pip install langchain
Create new Python file chat_gpt_search.py
Imported the required packages
from langchain.agents import load_tools
from langchain.agents import initialize_agent
from langchain.agents import AgentType
from langchain.llms import OpenAI
Python code to connect Open Ai API with Google search.
Paste your Open Ai key and SerpAPI key
llm = OpenAI(openai_api_key="", temperature=0.9)
tools = load_tools(["serpapi", "llm-math"], llm=llm, serpapi_api_key="")
agent = initialize_agent(tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)
question = "Give me details about ceo of episyche"
a = agent.run(question)
print(a)
Write your queries on the question variable and run the Python file.
Comments