Skip to content

Commit 9c118fb

Browse files
committed
updated ai-agent files
1 parent 98568da commit 9c118fb

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

content/learning-paths/servers-and-cloud-computing/ai-agent-on-cpu/ai-agent-backend.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@ Once you set up the environment, create a Python script which will execute the A
1212
### Option A
1313
- Clone the repository
1414
```bash
15+
cd ~
1516
git clone https://github.com/jc2409/ai-agent.git
1617
```
1718

1819
### Option B
1920
- Creat a Python file:
2021
```bash
22+
cd ~
2123
touch agent.py
2224
```
2325

2426
- Copy and paste the following code:
2527
```bash
26-
import os
2728
from enum import Enum
2829
from typing import Union
2930
from pydantic import BaseModel, Field
@@ -36,16 +37,17 @@ from llama_cpp_agent import MessagesFormatterType
3637
from llama_cpp_agent import LlamaCppAgent
3738
from llama_cpp_agent.providers import LlamaCppPythonProvider
3839
from llama_cpp import Llama
39-
# from langchain_community.tools import TavilySearchResults // Uncomment this to enable search function
40-
from dotenv import load_dotenv
40+
# import os
41+
# from dotenv import load_dotenv
42+
# from langchain_community.tools import TavilySearchResults # Uncomment this to enable search function
4143

4244

43-
load_dotenv()
45+
# load_dotenv()
4446

45-
os.environ.get("TAVILY_API_KEY")
47+
# os.environ.get("TAVILY_API_KEY")
4648

4749
llama_model = Llama(
48-
model_path="./models/llama3.1-8b-instruct.Q4_0_arm.gguf", // make sure you use the correct path for the quantized model
50+
model_path="./models/llama3.1-8b-instruct.Q4_0_arm.gguf", # make sure you use the correct path for the quantized model
4951
n_batch=2048,
5052
n_ctx=10000,
5153
n_threads=64,
@@ -112,7 +114,7 @@ def calculator(
112114
else:
113115
raise ValueError("Unknown operation.")
114116

115-
// Uncomment the following function to enable web search functionality (You will need to install langchain-community)
117+
# Uncomment the following function to enable web search functionality (You will need to install langchain-community)
116118
# def search_from_the_web(content: str):
117119
# """
118120
# Search useful information from the web to answer User's question
@@ -174,4 +176,10 @@ if __name__ == '__main__':
174176
You are now ready to test the AI Agent. Use the following command in a terminal to start the application:
175177
```bash
176178
python3 agent.py
177-
```
179+
```
180+
181+
{{% notice Note %}}
182+
183+
If it takes too long to process, try to terminate the application and try again.
184+
185+
{{% /notice %}}

content/learning-paths/servers-and-cloud-computing/ai-agent-on-cpu/set-up.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Set up the Environment to Run an AI Application Locally
3-
weight: 2
3+
weight: 3
44

55
### FIXED, DO NOT MODIFY
66
layout: learningpathall
@@ -16,6 +16,15 @@ In this Learning Path, you learn how to build an AI Agent application using llam
1616

1717
## Installation
1818

19+
Set up the virtual environment and install dependencies:
20+
```bash
21+
sudo apt-get update
22+
sudo apt-get upgrade
23+
sudo apt install python3-pip python3-venv cmake -y
24+
python3 -m venv ai-agent
25+
source ai-agent/bin/activate
26+
```
27+
1928
Install the `llama-cpp-python` package using pip:
2029

2130
```bash

0 commit comments

Comments
 (0)