Skip to content

Commit 2d970fd

Browse files
author
“samuele
committed
vers 1.6.0
1 parent 9cd08ac commit 2d970fd

File tree

23 files changed

+841
-174
lines changed

23 files changed

+841
-174
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,18 @@ All notable changes to this project will be documented in this file.
7777
- **Adaptive Retrieval-Augmented Generation RAG:** Focused on retrieval.
7878
- **Notebooks for RAG Techniques:**
7979
- Organized all the RAG techniques into dedicated notebooks, each containing detailed explanations aimed at didactic purposes.
80+
81+
[1.6.0] - 2025-03-09
82+
### Added
83+
- **Ollama Integration for Local LLM Models:**
84+
- Added support for running LLM models locally through Ollama integration.
85+
- Users can now pull and run models directly on their machines by prefixing model names with `local_` in configuration (e.g., `local_deepseek-r1`, `local_llama3.3`, `local_phi4`).
86+
- Provides data privacy, cost efficiency, and offline capability for sensitive applications.
87+
- Automatically handles model downloading and initialization when specified models aren't already active.
88+
- Supports running models even without GPU by switching to CPU (with reduced performance).
89+
- **Model-Specific Options Configuration:**
90+
- Added capability to set specific options for each Ollama model.
91+
- Users can now customize parameters like temperature, top_p, top_k, and other inference settings on a per-model basis.
92+
- Supports all Ollama model configuration options including context size, repetition penalties, and sampling parameters.
93+
- Enables fine-tuned control over model behavior while maintaining the simplicity of the local integration.
94+
- Configuration options can be set through the API for advanced model tuning.

README.md

+31-47
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
![AutoCode Agent Global Workflow](./static/images/autocode.png)
33

44
# AutoCodeAgent - An innovative AI agent powered by IntelliChain, Deep Search, and multi-RAG techniques
5-
![version](https://img.shields.io/badge/version-1.5.0-blue)
5+
![version](https://img.shields.io/badge/version-1.6.0-blue)
66

77
## One agent, Infinite possibilities
88
AutoCodeAgent redefines AI-powered problem solving by seamlessly integrating three groundbreaking modes:
@@ -20,7 +20,22 @@ You can also benefit from these techniques for educational purposes, as each one
2020
By fusing these three potent modes, AutoCodeAgent transforms intricate challenges into innovative, actionable solutions, setting a new standard in intelligent automation and advanced research.
2121

2222
[Application Setup](#application-setup)
23-
Step-by-step guide to setting up the project for the first time.
23+
Step-by-step guide to setting up the project for the first time.
24+
25+
AutoCodeAgent provides flexible integration with Large Language Models (LLMs) through both local and cloud-based solutions.
26+
Our agentic framework can communicate with LLM models in two ways:
27+
28+
1. **Local Integration**: Using Ollama to run models directly on your machine using our prebuilt Docker container.
29+
- Supports running LLM models locally through Ollama integration
30+
- Pull and run models directly on your machine by prefixing model names with `local_` in configuration (e.g., `local_deepseek-r1`, `local_llama3.3`, `local_phi4`)
31+
- Automatically handles model downloading and initialization when specified models aren't already active
32+
- Supports running models even without GPU by switching to CPU (with reduced performance)
33+
- Customize parameters like temperature, top_p, top_k, and other inference settings on a per-model basis
34+
35+
For detailed information about local model management and Ollama integration, please refer to the complete documentation at [models/README.md](models/README.md)
36+
37+
2. **Cloud Services**: Connecting to OpenAI's API for access to their hosted models
38+
2439

2540

2641
## IntelliChain sections
@@ -127,61 +142,32 @@ REDIS_HOST=redis
127142
REDIS_PORT=6379
128143
REDIS_DB=0
129144

130-
SIMPLE_RAG_CHUNK_SIZE=1500 # chunk size for simple rag
131-
SIMPLE_RAG_OVERLAP=200 # overlap for simple rag
132-
SIMPLE_RAG_EMBEDDING_MODEL=text-embedding-ada-002 # simple rag embedding model
133-
134-
HYBRID_VECTOR_GRAPH_RAG_CHUNK_SIZE=1500 # chunk size for hybrid vector graph rag
135-
HYBRID_VECTOR_GRAPH_RAG_OVERLAP=200 # overlap for hybrid vector graph rag
136-
HYBRID_VECTOR_GRAPH_RAG_SUMMARIZATION_GRAPH_NODE_LENGTH=100 # summarization graph node length for hybrid vector graph rag
137-
HYBRID_VECTOR_GRAPH_RAG_SIMILARITY_RETRIEVE_THRESHOLD=0.9 # similarity retrieve threshold for hybrid vector graph rag
138-
HYBRID_VECTOR_GRAPH_RAG_SIMILARITY_EDGE_THRESHOLD=0.9 # similarity edge threshold for hybrid vector graph rag
139-
HYBRID_VECTOR_GRAPH_RAG_QUERY_MAX_DEPTH=3 # max depth for hybrid vector graph rag
140-
HYBRID_VECTOR_GRAPH_RAG_QUERY_TOP_K=3 # top k for hybrid vector graph rag
141-
HYBRID_VECTOR_GRAPH_RAG_QUERY_MAX_CONTEXT_LENGTH=10000 # max context length for hybrid vector graph rag
142-
HYBRID_VECTOR_GRAPH_RAG_EMBEDDING_VECTOR_MODEL=text-embedding-ada-002 # hybrid vector graph rag embedding vector model
143-
HYBRID_VECTOR_GRAPH_RAG_SUMMARIZATION_GRAPH_NODE_MODEL=gpt-4o # hybrid vector graph rag summarization graph node model
144-
145-
CHROMA_DB_PATH=./tools/rag/database/chroma_db # url for chroma db used in simple rag
146-
LLAMA_INDEX_DB_PATH=./tools/rag/database/llama_index # url for llama index db used in llama index rag tool
147-
LLAMA_INDEX_CONTEXT_WINDOW_DB_PATH=./tools/rag/database/llama_index_context_window # url for llama index context window db used in llama index context window rag tool
148-
LLAMA_INDEX_CORPUS_DIR=./tools/rag/llama_index/corpus # url for llama index corpus used in llama index rag tool
149-
LLAMA_INDEX_CONTEXT_WINDOW_CORPUS_DIR=./tools/rag/llama_index_context_window/corpus # url for llama index context window corpus used in llama index context window rag tool
150-
151-
LLAMA_INDEX_CONTEXT_WINDOW_SIZE_INGEST=30 # sentences for llama index context window ingestion
152-
LLAMA_INDEX_CONTEXT_WINDOW_MAX_ADJACENT_CHARS_RAG_RETRIEVE=150 # max adjacent characters for llama index context window rag tool
153-
LLAMA_INDEX_CONTEXT_WINDOW_TOP_K_RAG_RETRIEVE=5 # top k chunks for llama index context window rag tool
154-
155-
HYDE_RAG_CHUNK_SIZE=1500 # chunk size for hyde rag tool
156-
HYDE_RAG_QUERY_TOP_K=5 # query top k for hyde rag tool
157-
HYDE_GENERATE_HYPO_DOC_MODEL=gpt-4o # generate hyde rag tool model
158-
159-
[email protected] # gmail user for send email tool
160-
PASSGMAILAPP=your_password # gmail password for send email tool
161-
162-
TOOL_HELPER_MODEL=gpt-4o # tool helper model
163-
JSON_PLAN_MODEL=gpt-4o # json plan model
164-
EVALUATION_MODEL=gpt-4o # evaluation model
165-
SURF_AI_JSON_TASK_MODEL=gpt-4o # surf ai json task model, important: for surfAi you must use a multimodal modal with text + vision capabilities
166-
DEEP_SEARCH_MODEL=o3-mini # deep search model
145+
[email protected] # Gmail user for default tool send_email
146+
PASSGMAILAPP=your_password # Gmail app password for default tool send_email
167147

168148
ELEVEN_API_KEY=API_KEY # elevenlabs api key for langchain tool
169149
OPENWEATHERMAP_API_KEY=API_KEY # openweathermap api key for langchain tool
170150
SERPAPI_API_KEY=API_KEY # serpapi api key for langchain tool and also deep search mode
171151
SERPER_API_KEY=API_KEY # serpapi api key for deep search mode (optional, the script use serpapi by default)
172152
```
173153

174-
4. Build the Docker image:
154+
4. File params.py
155+
The `params.py` file contains a comprehensive configuration dictionary that controls the behavior of AutoCodeAgent 2.0's various RAG (Retrieval-Augmented Generation) systems and tools. This configuration file centralizes all adjustable parameters, making the system highly customizable.
156+
Additionally, it configures database paths for various vector stores (ChromaDB, LlamaIndex), email functionality credentials, and specifies which AI models to use for different components of the system (tool assistance, planning, evaluation, web automation, and search).
157+
You can set which models to use throughout the system - whether cloud-based models from OpenAI or local models running through Ollama or any other API-compatible service. Models can be specified by prefixing with "local_" for local models (e.g., "local_llama3") or using the standard model name for cloud services (e.g., "gpt-4o").
158+
This centralized configuration allows users to set the system's behavior by adjusting parameters without modifying core code.
159+
160+
5. Build the Docker image:
175161
```bash
176162
docker-compose build
177163
```
178164

179-
5. Run the Docker container:
165+
6. Run the Docker container:
180166
```bash
181167
docker-compose up -d
182168
```
183169

184-
6. Check the backend logs:
170+
7. Check the backend logs:
185171
```bash
186172
docker logs -f flask_app
187173
```
@@ -190,7 +176,6 @@ If you want to rebuild and restart the application, and optimize docker space:
190176
docker-compose down
191177
docker-compose build --no-cache
192178
docker-compose up -d
193-
docker system prune -a --volumes -f
194179
docker builder prune -a -f
195180
docker logs -f flask_app
196181
```
@@ -199,16 +184,16 @@ Is a good idea to always check docker space usage after building and starting th
199184
docker system df
200185
```
201186

202-
7. Access the AI Agent chat interface:
187+
8. Access the AI Agent chat interface:
203188
```bash
204189
http://localhost:5000
205190

206191
```
207-
8. To view the automated browser sessions (powered by SurfAi), open:
192+
9. To view the automated browser sessions (powered by SurfAi), open:
208193
```bash
209194
http://localhost:6901/vnc.html
210195
```
211-
9. To explore and interact with the Neo4j graph database, visit:
196+
10. To explore and interact with the Neo4j graph database, visit:
212197
```bash
213198
http://localhost:7474/browser/
214199
```
@@ -1256,4 +1241,3 @@ By contributing, you agree that your changes will be licensed under the same lic
12561241
12571242
Thank you for helping improve this project! 🚀
12581243
1259-

app.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from tools.rag.hybrid_vector_graph_rag.ingest_corpus import hybrid_vector_graph_rag_ingest_corpus
1010
from tools.rag.llama_index.ingest_corpus import llama_index_ingest_corpus
1111
from tools.rag.llama_index_context_window.ingest_corpus import llama_index_context_window_ingest_corpus
12-
12+
from models.models import call_model
1313

1414
logging.basicConfig(
1515
level=logging.DEBUG,
@@ -139,6 +139,7 @@ def hybrid_vector_graph_rag_ingest():
139139
logging.error(traceback.format_exc())
140140
return jsonify({"error": f"Internal server error: {str(e)}"}), 500
141141

142+
142143
#start the acquisition, parsing, and ingestion of all documents present in /tools/rag/llama_index/corpus
143144
# or /tools/rag/llama_index_context_window/corpus if isContextWindow is true
144145
@app.route('/llama-index-ingest-corpus', methods=['POST'])
@@ -159,10 +160,20 @@ def llama_index_ingest():
159160
return jsonify({"error": f"Internal server error: {str(e)}"}), 500
160161

161162

163+
164+
@app.route('/call-test-model', methods=['GET'])
165+
def call_test_model():
166+
response = call_model(
167+
chat_history=[{"role": "user", "content": "Tell me a story about a cat and a dog."}],
168+
model="local_llama3.2:1b"
169+
)
170+
return jsonify({"response": response}), 200
171+
172+
162173
if __name__ == '__main__':
163174
app.run(
164175
host='0.0.0.0',
165176
port=int(os.getenv('FLASK_PORT', 5000)),
166177
debug=True
167-
)
178+
)
168179

code_agent/code_agent.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import json
2-
import os
32
from typing import List, Dict
43
from .tool_generator import generate_tools
54
from .logging_handler import LoggingConfigurator
65
from .agent_plan_generator import PlanGenerator
76
from .agent_plan_evaluator import PlanEvaluator
87
from .agent_subtask_executor import SubtaskExecutor
98
from .utils import transform_final_answer
9+
from params import PARAMS
1010

1111
class CodeAgent:
1212
def __init__(self, chat_history: List[Dict], tools: List[str], use_default_tools: bool = True):
@@ -20,10 +20,10 @@ def __init__(self, chat_history: List[Dict], tools: List[str], use_default_tools
2020
self.logger = LoggingConfigurator.configure_logger(self.execution_logs)
2121
self.enrich_log = LoggingConfigurator.enrich_log
2222
self.models = {
23-
"TOOL_HELPER_MODEL": os.getenv("TOOL_HELPER_MODEL"),
24-
"JSON_PLAN_MODEL": os.getenv("JSON_PLAN_MODEL"),
25-
"EVALUATION_MODEL": os.getenv("EVALUATION_MODEL"),
26-
"SIMPLE_RAG_EMBEDDING_MODEL": os.getenv("SIMPLE_RAG_EMBEDDING_MODEL")
23+
"TOOL_HELPER_MODEL": PARAMS["TOOL_HELPER_MODEL"],
24+
"JSON_PLAN_MODEL": PARAMS["JSON_PLAN_MODEL"],
25+
"EVALUATION_MODEL": PARAMS["EVALUATION_MODEL"],
26+
"SIMPLE_RAG_EMBEDDING_MODEL": PARAMS["SIMPLE_RAG_EMBEDDING_MODEL"]
2727
}
2828
# Instantiate helper components.
2929
self.plan_generator = PlanGenerator(self.chat_history, self.tools, self.models["JSON_PLAN_MODEL"])

code_agent/tool_generator.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from string import Template
55
from langchain_community.agent_toolkits.load_tools import load_tools
66
from .default_tools import DEFAULT_TOOLS, TOOLS_ACTIVATION
7+
from params import PARAMS
78

89

910
logger = logging.getLogger(__name__)
@@ -51,9 +52,9 @@ def generate_tools(user_tools, use_default_tools):
5152

5253
# Define variables to substitute.
5354
variables = {
54-
"TOOL_HELPER_MODEL": os.getenv("TOOL_HELPER_MODEL", ""),
55-
"JSON_PLAN_MODEL": os.getenv("JSON_PLAN_MODEL", ""),
56-
"EVALUATION_MODEL": os.getenv("EVALUATION_MODEL", ""),
55+
"TOOL_HELPER_MODEL": PARAMS["TOOL_HELPER_MODEL"],
56+
"JSON_PLAN_MODEL": PARAMS["JSON_PLAN_MODEL"],
57+
"EVALUATION_MODEL": PARAMS["EVALUATION_MODEL"],
5758
"GMAILUSER": os.getenv("GMAILUSER", ""),
5859
"PASSGMAILAPP": os.getenv("PASSGMAILAPP", "")
5960
}

deep_search/planner.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from .egot_engine import EGoTEngine
1717
from .utils import apply_depth_settings
1818
from tools.rag.llama_index.retrieve import retrieve_documents
19+
from params import PARAMS
1920

2021
class DeepSearchAgentPlanner:
2122
def __init__(self, chat_history: List[Dict], **kwargs):
@@ -28,7 +29,7 @@ def __init__(self, chat_history: List[Dict], **kwargs):
2829
self.data.memory_logs = []
2930
self.logger = LoggingConfigurator.configure_logger(self.data.memory_logs)
3031
self.enrich_log = LoggingConfigurator.enrich_log
31-
self.deep_search_model = os.getenv("DEEP_SEARCH_MODEL")
32+
self.deep_search_model = PARAMS["DEEP_SEARCH_MODEL"]
3233

3334
neo4j_uri = os.getenv("NEO4J_URI")
3435
neo4j_user = os.getenv("NEO4J_USER")

docker-compose.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ services:
1919
redis:
2020
condition: service_started
2121

22+
ollama:
23+
image: ollama/ollama:latest
24+
container_name: ollama_server
25+
restart: unless-stopped
26+
ports:
27+
- "11434:11434"
28+
volumes:
29+
- ollama_data:/data
30+
2231
neo4j:
2332
image: neo4j:4.4
2433
container_name: neo4j_db
@@ -58,4 +67,5 @@ volumes:
5867
neo4j_logs:
5968
neo4j_import:
6069
neo4j_plugins:
61-
redis-data:
70+
redis-data:
71+
ollama_data:

0 commit comments

Comments
 (0)