[IMP][FIX] fixes summarization common class and removed duplicate code.
Browse files- app.py +0 -18
- tools/odoo_code_agent_16.py +4 -5
- tools/odoo_code_agent_17.py +3 -5
- tools/odoo_code_agent_18.py +3 -5
app.py
CHANGED
|
@@ -90,19 +90,6 @@ model_providers = {
|
|
| 90 |
}
|
| 91 |
|
| 92 |
|
| 93 |
-
selected_provider = "HuggingFace"
|
| 94 |
-
|
| 95 |
-
model_id = model_providers[selected_provider]["model_id"]
|
| 96 |
-
|
| 97 |
-
# model = HfApiModel(
|
| 98 |
-
# max_tokens=1000,
|
| 99 |
-
# temperature=0.5,
|
| 100 |
-
# model_id=model_id,
|
| 101 |
-
# custom_role_conversions=None,
|
| 102 |
-
# api_key=os.environ.get(model_providers[selected_provider]["api_key_env_var"]) if model_providers[selected_provider]["api_key_env_var"] else None
|
| 103 |
-
# )
|
| 104 |
-
|
| 105 |
-
|
| 106 |
# Import tool from Hub
|
| 107 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 108 |
|
|
@@ -137,11 +124,6 @@ def launch_gradio_ui(additional_args=None):
|
|
| 137 |
|
| 138 |
model = HfApiModel(**model_kwargs)
|
| 139 |
|
| 140 |
-
odoo_documentation_search_tool = OdooDocumentationSearchTool()
|
| 141 |
-
odoo_code_agent_16_tool = OdooCodeAgent16(prompt_templates["system_prompt"])
|
| 142 |
-
odoo_code_agent_17_tool = OdooCodeAgent17(prompt_templates["system_prompt"])
|
| 143 |
-
odoo_code_agent_18_tool = OdooCodeAgent18(prompt_templates["system_prompt"])
|
| 144 |
-
|
| 145 |
agent = CodeAgent(
|
| 146 |
model=model,
|
| 147 |
tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone, job_search_tool, odoo_documentation_search_tool, odoo_code_agent_16_tool, odoo_code_agent_17_tool, odoo_code_agent_18_tool],
|
|
|
|
| 90 |
}
|
| 91 |
|
| 92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
# Import tool from Hub
|
| 94 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 95 |
|
|
|
|
| 124 |
|
| 125 |
model = HfApiModel(**model_kwargs)
|
| 126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
agent = CodeAgent(
|
| 128 |
model=model,
|
| 129 |
tools=[final_answer, visit_webpage, web_search, image_generation_tool, get_current_time_in_timezone, job_search_tool, odoo_documentation_search_tool, odoo_code_agent_16_tool, odoo_code_agent_17_tool, odoo_code_agent_18_tool],
|
tools/odoo_code_agent_16.py
CHANGED
|
@@ -2,19 +2,19 @@ from smolagents.tools import Tool
|
|
| 2 |
import requests
|
| 3 |
from typing import List, Dict
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
-
from transformers import pipeline # Requires transformers
|
| 6 |
import tempfile
|
| 7 |
from tools.odoo_documentation_search import OdooDocumentationSearchTool
|
| 8 |
import yaml
|
| 9 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
|
|
|
| 10 |
|
| 11 |
class OdooCodeAgent16(Tool):
|
| 12 |
name = "odoo_code_agent_16"
|
| 13 |
description = "Generates Odoo code for version 16 based on the user's query and Odoo documentation, using prompt templates."
|
| 14 |
|
| 15 |
def __init__(self, system_prompt: str):
|
| 16 |
-
|
| 17 |
-
self.summarizer = pipeline("summarization", model="google/flan-t5-small")
|
| 18 |
self.is_initialized = True
|
| 19 |
self.system_prompt = system_prompt
|
| 20 |
|
|
@@ -68,7 +68,6 @@ class OdooCodeAgent16(Tool):
|
|
| 68 |
prompt += "# No documentation found.\n"
|
| 69 |
|
| 70 |
truncated_prompt = prompt[:500]
|
| 71 |
-
|
| 72 |
-
code = self.summarizer(truncated_prompt, max_length=max_length, min_length=30, do_sample=False)[0]['summary_text']
|
| 73 |
|
| 74 |
return FinalAnswerTool(answer=f"```py\n{code}\n```", include_download=True)
|
|
|
|
| 2 |
import requests
|
| 3 |
from typing import List, Dict
|
| 4 |
from bs4 import BeautifulSoup
|
|
|
|
| 5 |
import tempfile
|
| 6 |
from tools.odoo_documentation_search import OdooDocumentationSearchTool
|
| 7 |
import yaml
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
+
from tools.summarizer_service import SummarizerService
|
| 10 |
+
|
| 11 |
|
| 12 |
class OdooCodeAgent16(Tool):
|
| 13 |
name = "odoo_code_agent_16"
|
| 14 |
description = "Generates Odoo code for version 16 based on the user's query and Odoo documentation, using prompt templates."
|
| 15 |
|
| 16 |
def __init__(self, system_prompt: str):
|
| 17 |
+
self.summarizer_service = SummarizerService()
|
|
|
|
| 18 |
self.is_initialized = True
|
| 19 |
self.system_prompt = system_prompt
|
| 20 |
|
|
|
|
| 68 |
prompt += "# No documentation found.\n"
|
| 69 |
|
| 70 |
truncated_prompt = prompt[:500]
|
| 71 |
+
code = self.summarizer_service.summarize(truncated_prompt)
|
|
|
|
| 72 |
|
| 73 |
return FinalAnswerTool(answer=f"```py\n{code}\n```", include_download=True)
|
tools/odoo_code_agent_17.py
CHANGED
|
@@ -2,19 +2,18 @@ from smolagents.tools import Tool
|
|
| 2 |
import requests
|
| 3 |
from typing import List, Dict
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
-
from transformers import pipeline # Requires transformers
|
| 6 |
import tempfile
|
| 7 |
from tools.odoo_documentation_search import OdooDocumentationSearchTool
|
| 8 |
import yaml
|
| 9 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 10 |
|
| 11 |
class OdooCodeAgent17(Tool):
|
| 12 |
name = "odoo_code_agent_17"
|
| 13 |
description = "Generates Odoo code for version 17 based on the user's query and Odoo documentation, using prompt templates."
|
| 14 |
|
| 15 |
def __init__(self, system_prompt: str):
|
| 16 |
-
|
| 17 |
-
self.summarizer = pipeline("summarization", model="google/flan-t5-small")
|
| 18 |
self.is_initialized = True
|
| 19 |
self.system_prompt = system_prompt
|
| 20 |
|
|
@@ -68,7 +67,6 @@ class OdooCodeAgent17(Tool):
|
|
| 68 |
prompt += "# No documentation found.\n"
|
| 69 |
|
| 70 |
truncated_prompt = prompt[:500]
|
| 71 |
-
|
| 72 |
-
code = self.summarizer(truncated_prompt, max_length=max_length, min_length=30, do_sample=False)[0]['summary_text']
|
| 73 |
|
| 74 |
return FinalAnswerTool(answer=f"```py\n{code}\n```", include_download=True)
|
|
|
|
| 2 |
import requests
|
| 3 |
from typing import List, Dict
|
| 4 |
from bs4 import BeautifulSoup
|
|
|
|
| 5 |
import tempfile
|
| 6 |
from tools.odoo_documentation_search import OdooDocumentationSearchTool
|
| 7 |
import yaml
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
+
from tools.summarizer_service import SummarizerService
|
| 10 |
|
| 11 |
class OdooCodeAgent17(Tool):
|
| 12 |
name = "odoo_code_agent_17"
|
| 13 |
description = "Generates Odoo code for version 17 based on the user's query and Odoo documentation, using prompt templates."
|
| 14 |
|
| 15 |
def __init__(self, system_prompt: str):
|
| 16 |
+
self.summarizer_service = SummarizerService()
|
|
|
|
| 17 |
self.is_initialized = True
|
| 18 |
self.system_prompt = system_prompt
|
| 19 |
|
|
|
|
| 67 |
prompt += "# No documentation found.\n"
|
| 68 |
|
| 69 |
truncated_prompt = prompt[:500]
|
| 70 |
+
code = self.summarizer_service.summarize(truncated_prompt)
|
|
|
|
| 71 |
|
| 72 |
return FinalAnswerTool(answer=f"```py\n{code}\n```", include_download=True)
|
tools/odoo_code_agent_18.py
CHANGED
|
@@ -2,19 +2,18 @@ from smolagents.tools import Tool
|
|
| 2 |
import requests
|
| 3 |
from typing import List, Dict
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
-
from transformers import pipeline # Requires transformers
|
| 6 |
import tempfile
|
| 7 |
from tools.odoo_documentation_search import OdooDocumentationSearchTool
|
| 8 |
import yaml
|
| 9 |
from tools.final_answer import FinalAnswerTool
|
|
|
|
| 10 |
|
| 11 |
class OdooCodeAgent18(Tool):
|
| 12 |
name = "odoo_code_agent_18"
|
| 13 |
description = "Generates Odoo code for version 18 based on the user's query and Odoo documentation, using prompt templates."
|
| 14 |
|
| 15 |
def __init__(self, system_prompt: str):
|
| 16 |
-
|
| 17 |
-
self.summarizer = pipeline("summarization", model="google/flan-t5-small")
|
| 18 |
self.is_initialized = True
|
| 19 |
self.system_prompt = system_prompt
|
| 20 |
|
|
@@ -68,7 +67,6 @@ class OdooCodeAgent18(Tool):
|
|
| 68 |
prompt += "# No documentation found.\n"
|
| 69 |
|
| 70 |
truncated_prompt = prompt[:500]
|
| 71 |
-
|
| 72 |
-
code = self.summarizer(truncated_prompt, max_length=max_length, min_length=30, do_sample=False)[0]['summary_text']
|
| 73 |
|
| 74 |
return FinalAnswerTool(answer=f"```py\n{code}\n```", include_download=True)
|
|
|
|
| 2 |
import requests
|
| 3 |
from typing import List, Dict
|
| 4 |
from bs4 import BeautifulSoup
|
|
|
|
| 5 |
import tempfile
|
| 6 |
from tools.odoo_documentation_search import OdooDocumentationSearchTool
|
| 7 |
import yaml
|
| 8 |
from tools.final_answer import FinalAnswerTool
|
| 9 |
+
from tools.summarizer_service import SummarizerService
|
| 10 |
|
| 11 |
class OdooCodeAgent18(Tool):
|
| 12 |
name = "odoo_code_agent_18"
|
| 13 |
description = "Generates Odoo code for version 18 based on the user's query and Odoo documentation, using prompt templates."
|
| 14 |
|
| 15 |
def __init__(self, system_prompt: str):
|
| 16 |
+
self.summarizer_service = SummarizerService()
|
|
|
|
| 17 |
self.is_initialized = True
|
| 18 |
self.system_prompt = system_prompt
|
| 19 |
|
|
|
|
| 67 |
prompt += "# No documentation found.\n"
|
| 68 |
|
| 69 |
truncated_prompt = prompt[:500]
|
| 70 |
+
code = self.summarizer_service.summarize(truncated_prompt)
|
|
|
|
| 71 |
|
| 72 |
return FinalAnswerTool(answer=f"```py\n{code}\n```", include_download=True)
|