Path: blob/main/Create AI Agent for Wikipedia and Calculator - OpenAI/AI Agent for Wikipedia and Calculator - OpenAI.ipynb
569 views
Kernel: Python 3 (ipykernel)
Import Modules
In [2]:
Create ChatBot Class
In [14]:
Create Agent Prompt
In [4]:
Configure Functions
In [18]:
In [15]:
Out[15]:
An AI agent is a computational entity that employs artificial intelligence techniques to perceive its environment, make decisions, and perform actions autonomously or semi-autonomously to achieve specific goals. Here’s an overview of the key concepts and characteristics associated with AI agents:
### Key Characteristics of AI Agents
1. **Autonomy**:
- AI agents operate without human intervention. They can make decisions based on their perceptions and learned experiences.
2. **Perception**:
- AI agents can perceive their environment through sensors, data inputs, or predefined data sources. This allows them to gather information that is essential for making informed decisions.
3. **Action**:
- Based on their evaluations of the environment, AI agents can take actions to pursue their goals. This could involve responding to user inputs, controlling machinery, or even interacting with other agents or systems.
4. **Adaptability and Learning**:
- Many AI agents can learn from their experiences, adapt to new situations, and improve their performance over time. This is often achieved through machine learning techniques.
5. **Goal-Oriented Behavior**:
- AI agents are designed to achieve specific objectives or goals. These goals may involve maximizing efficiency, minimizing costs, or satisfying user preferences.
6. **Communication**:
- In multi-agent systems, AI agents may communicate with one another to share knowledge, coordinate actions, and achieve collective goals.
### Types of AI Agents
1. **Reactive Agents**:
- These agents respond to immediate stimuli without the ability to learn from past experiences. They operate based on pre-defined rules and behaviors.
2. **Deliberative Agents**:
- These agents maintain an internal model of the world and can reason about their actions over time. They plan their actions based on knowledge and predictions about future states.
3. **Learning Agents**:
- Using machine learning techniques, these agents can improve their performance by learning from experience and adapting to changes in the environment.
4. **Multi-Agent Systems**:
- A group of AI agents that work together to solve problems or complete tasks. They can collaborate, negotiate, and coordinate their actions.
### Applications of AI Agents
- **Virtual Assistants**: Such as Siri, Alexa, and Google Assistant that help users by providing information and performing tasks.
- **Autonomous Vehicles**: AI agents that navigate and make driving decisions in real time.
- **Robotics**: Robots that perform tasks in various domains, from manufacturing to service industries.
- **Recommendation Systems**: AI agents that suggest products or content based on user preferences and behavior.
- **Game AI**: Non-player characters (NPCs) that use AI to react and adapt to players’ actions in video games.
### Challenges
- **Ethics and Bias**: Ensuring that AI agents make fair decisions and do not perpetuate biases present in the training data.
- **Transparency**: Understanding and explaining how AI agents make decisions can be difficult, especially in complex models.
- **Safety and Security**: Ensuring that AI agents operate safely in dynamic and unpredictable environments.
AI agents represent a significant advancement in automation and intelligent systems, possessing remarkable capabilities to enhance productivity, efficiency, and user experience across numerous applications.
In [16]:
In [19]:
Out[19]:
'Ottawa is the <span class="searchmatch">capital</span> city <span class="searchmatch">of</span> <span class="searchmatch">Canada</span>. It is located in the southern portion <span class="searchmatch">of</span> the province <span class="searchmatch">of</span> Ontario, at the meeting <span class="searchmatch">of</span> the Ottawa River and the Rideau\n\n<span class="searchmatch">Capital</span> punishment in <span class="searchmatch">Canada</span> dates to <span class="searchmatch">Canada\'s</span> earliest history, including its period as first a French then a British colony. From 1867 to the elimination\n\nofficial federal designation encompassing the <span class="searchmatch">Canadian</span> <span class="searchmatch">capital</span> <span class="searchmatch">of</span> Ottawa, Ontario, the adjacent city <span class="searchmatch">of</span> Gatineau, Quebec, and surrounding suburban and\n\n'
In [20]:
Out[20]:
5
Main Function for AI Agent
In [23]:
In [24]:
Out[24]:
Thought: I need to find out what the capital of Canada is, so I'll look it up on Wikipedia.
Action: wikipedia: Canada
PAUSE
Running wikipedia: Canada
Observation: <span class="searchmatch">Canada</span> is a country in North America. Its ten provinces and three territories extend from the Atlantic Ocean to the Pacific Ocean and northward into the
<span class="searchmatch">Canadians</span> (French: Canadiens) are people identified with the country of <span class="searchmatch">Canada</span>. This connection may be residential, legal, historical or cultural. For
up <span class="searchmatch">cañada</span> in Wiktionary, the free dictionary. <span class="searchmatch">Cañada</span> may refer to: <span class="searchmatch">Cañada</span> de Gómez, Santa Fe province <span class="searchmatch">Cañada</span> Rosquín, Santa Fe province La <span class="searchmatch">Cañada</span>, Santiago
Thought: The information from Wikipedia doesn't explicitly mention the capital of Canada. I need to perform a search focusing specifically on the capital.
Action: wikipedia: Capital of Canada
PAUSE
Running wikipedia: Capital of Canada
Observation: Ottawa is the <span class="searchmatch">capital</span> city <span class="searchmatch">of</span> <span class="searchmatch">Canada</span>. It is located in the southern portion <span class="searchmatch">of</span> the province <span class="searchmatch">of</span> Ontario, at the meeting <span class="searchmatch">of</span> the Ottawa River and the Rideau
<span class="searchmatch">Capital</span> punishment in <span class="searchmatch">Canada</span> dates to <span class="searchmatch">Canada's</span> earliest history, including its period as first a French then a British colony. From 1867 to the elimination
official federal designation encompassing the <span class="searchmatch">Canadian</span> <span class="searchmatch">capital</span> <span class="searchmatch">of</span> Ottawa, Ontario, the adjacent city <span class="searchmatch">of</span> Gatineau, Quebec, and surrounding suburban and
Answer: The capital of Canada is Ottawa.
In [25]:
Out[25]:
Thought: This is a simple arithmetic calculation that I can perform to find the answer.
Action: calculate: 10 + 3
PAUSE
Running calculate: 10 + 3
Observation: 13
Answer: The result of 10 + 3 is 13.
In [26]:
Out[26]:
Thought: This is a simple arithmetic question that can be solved easily by adding the two numbers together. 10 plus 13 is straightforward; I will perform the calculation now.
Action: calculate: 10 + 13
PAUSE
Running calculate: 10 + 13
Observation: 23
Answer: 10 plus 13 is 23.
In [ ]: