ai-parrot 0.1.0__cp311-cp311-manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ai-parrot might be problematic. Click here for more details.

Files changed (108) hide show
  1. ai_parrot-0.1.0.dist-info/LICENSE +21 -0
  2. ai_parrot-0.1.0.dist-info/METADATA +299 -0
  3. ai_parrot-0.1.0.dist-info/RECORD +108 -0
  4. ai_parrot-0.1.0.dist-info/WHEEL +5 -0
  5. ai_parrot-0.1.0.dist-info/top_level.txt +3 -0
  6. parrot/__init__.py +18 -0
  7. parrot/chatbots/__init__.py +7 -0
  8. parrot/chatbots/abstract.py +965 -0
  9. parrot/chatbots/asktroc.py +16 -0
  10. parrot/chatbots/base.py +257 -0
  11. parrot/chatbots/basic.py +9 -0
  12. parrot/chatbots/bose.py +17 -0
  13. parrot/chatbots/cody.py +17 -0
  14. parrot/chatbots/copilot.py +100 -0
  15. parrot/chatbots/dataframe.py +103 -0
  16. parrot/chatbots/hragents.py +15 -0
  17. parrot/chatbots/oddie.py +17 -0
  18. parrot/chatbots/retrievals/__init__.py +515 -0
  19. parrot/chatbots/retrievals/constitutional.py +19 -0
  20. parrot/conf.py +108 -0
  21. parrot/crew/__init__.py +3 -0
  22. parrot/crew/tools/__init__.py +22 -0
  23. parrot/crew/tools/bing.py +13 -0
  24. parrot/crew/tools/config.py +43 -0
  25. parrot/crew/tools/duckgo.py +62 -0
  26. parrot/crew/tools/file.py +24 -0
  27. parrot/crew/tools/google.py +168 -0
  28. parrot/crew/tools/gtrends.py +16 -0
  29. parrot/crew/tools/md2pdf.py +25 -0
  30. parrot/crew/tools/rag.py +42 -0
  31. parrot/crew/tools/search.py +32 -0
  32. parrot/crew/tools/url.py +21 -0
  33. parrot/exceptions.cpython-311-x86_64-linux-gnu.so +0 -0
  34. parrot/handlers/__init__.py +4 -0
  35. parrot/handlers/bots.py +196 -0
  36. parrot/handlers/chat.py +169 -0
  37. parrot/interfaces/__init__.py +6 -0
  38. parrot/interfaces/database.py +29 -0
  39. parrot/llms/__init__.py +0 -0
  40. parrot/llms/abstract.py +41 -0
  41. parrot/llms/anthropic.py +36 -0
  42. parrot/llms/google.py +37 -0
  43. parrot/llms/groq.py +33 -0
  44. parrot/llms/hf.py +39 -0
  45. parrot/llms/openai.py +49 -0
  46. parrot/llms/pipes.py +103 -0
  47. parrot/llms/vertex.py +68 -0
  48. parrot/loaders/__init__.py +20 -0
  49. parrot/loaders/abstract.py +456 -0
  50. parrot/loaders/basepdf.py +102 -0
  51. parrot/loaders/basevideo.py +280 -0
  52. parrot/loaders/csv.py +42 -0
  53. parrot/loaders/dir.py +37 -0
  54. parrot/loaders/excel.py +349 -0
  55. parrot/loaders/github.py +65 -0
  56. parrot/loaders/handlers/__init__.py +5 -0
  57. parrot/loaders/handlers/data.py +213 -0
  58. parrot/loaders/image.py +119 -0
  59. parrot/loaders/json.py +52 -0
  60. parrot/loaders/pdf.py +187 -0
  61. parrot/loaders/pdfchapters.py +142 -0
  62. parrot/loaders/pdffn.py +112 -0
  63. parrot/loaders/pdfimages.py +207 -0
  64. parrot/loaders/pdfmark.py +88 -0
  65. parrot/loaders/pdftables.py +145 -0
  66. parrot/loaders/ppt.py +30 -0
  67. parrot/loaders/qa.py +81 -0
  68. parrot/loaders/repo.py +103 -0
  69. parrot/loaders/rtd.py +65 -0
  70. parrot/loaders/txt.py +92 -0
  71. parrot/loaders/utils/__init__.py +1 -0
  72. parrot/loaders/utils/models.py +25 -0
  73. parrot/loaders/video.py +96 -0
  74. parrot/loaders/videolocal.py +107 -0
  75. parrot/loaders/vimeo.py +106 -0
  76. parrot/loaders/web.py +216 -0
  77. parrot/loaders/web_base.py +112 -0
  78. parrot/loaders/word.py +125 -0
  79. parrot/loaders/youtube.py +192 -0
  80. parrot/manager.py +152 -0
  81. parrot/models.py +347 -0
  82. parrot/py.typed +0 -0
  83. parrot/stores/__init__.py +0 -0
  84. parrot/stores/abstract.py +170 -0
  85. parrot/stores/milvus.py +540 -0
  86. parrot/stores/qdrant.py +153 -0
  87. parrot/tools/__init__.py +16 -0
  88. parrot/tools/abstract.py +53 -0
  89. parrot/tools/asknews.py +32 -0
  90. parrot/tools/bing.py +13 -0
  91. parrot/tools/duck.py +62 -0
  92. parrot/tools/google.py +170 -0
  93. parrot/tools/stack.py +26 -0
  94. parrot/tools/weather.py +70 -0
  95. parrot/tools/wikipedia.py +59 -0
  96. parrot/tools/zipcode.py +179 -0
  97. parrot/utils/__init__.py +2 -0
  98. parrot/utils/parsers/__init__.py +5 -0
  99. parrot/utils/parsers/toml.cpython-311-x86_64-linux-gnu.so +0 -0
  100. parrot/utils/toml.py +11 -0
  101. parrot/utils/types.cpython-311-x86_64-linux-gnu.so +0 -0
  102. parrot/utils/uv.py +11 -0
  103. parrot/version.py +10 -0
  104. resources/users/__init__.py +5 -0
  105. resources/users/handlers.py +13 -0
  106. resources/users/models.py +205 -0
  107. settings/__init__.py +0 -0
  108. settings/settings.py +51 -0
@@ -0,0 +1,16 @@
1
+ from parrot.chatbots import Chatbot
2
+
3
+ class AskTROC(Chatbot):
4
+ """Represents an Human Resources agent in Navigator.
5
+
6
+ Each agent has a name, a role, a goal, a backstory,
7
+ and an optional language model (llm).
8
+ """
9
+ company_information: dict = {
10
+ 'company': 'T-ROC Global',
11
+ 'company_website': 'https://www.trocglobal.com',
12
+ 'contact_email': 'communications@trocglobal.com',
13
+ 'contact_form': 'https://www.surveymonkey.com/r/TROC_Suggestion_Box'
14
+ }
15
+ role: str = 'Expert T-ROCer'
16
+ goal = 'Bring useful information about T-ROC Global to employees.'
@@ -0,0 +1,257 @@
1
+ from abc import ABC
2
+ # Langchain:
3
+ from langchain_core.prompts import (
4
+ PromptTemplate,
5
+ ChatPromptTemplate
6
+ )
7
+ from langchain.agents.agent import (
8
+ AgentExecutor,
9
+ RunnableAgent,
10
+ RunnableMultiActionAgent,
11
+ )
12
+ from langchain.agents import create_react_agent
13
+ from navconfig.logging import logging
14
+ ## LLM configuration
15
+ # Vertex
16
+ try:
17
+ from ..llms.vertex import VertexLLM
18
+ VERTEX_ENABLED = True
19
+ except (ModuleNotFoundError, ImportError):
20
+ VERTEX_ENABLED = False
21
+
22
+ # Google
23
+ try:
24
+ from ..llms.google import GoogleGenAI
25
+ GOOGLE_ENABLED = True
26
+ except (ModuleNotFoundError, ImportError):
27
+ GOOGLE_ENABLED = False
28
+
29
+ # Anthropic:
30
+ try:
31
+ from ..llms.anthropic import Anthropic
32
+ ANTHROPIC_ENABLED = True
33
+ except (ModuleNotFoundError, ImportError):
34
+ ANTHROPIC_ENABLED = False
35
+
36
+ # OpenAI
37
+ try:
38
+ from ..llms.openai import OpenAILLM
39
+ OPENAI_ENABLED = True
40
+ except (ModuleNotFoundError, ImportError):
41
+ OPENAI_ENABLED = False
42
+
43
+ # Groq
44
+ try:
45
+ from ..llms.groq import GroqLLM
46
+ GROQ_ENABLED = True
47
+ except (ModuleNotFoundError, ImportError):
48
+ GROQ_ENABLED = False
49
+
50
+ from tenacity import (
51
+ retry,
52
+ stop_after_attempt,
53
+ wait_random_exponential,
54
+ ) # for exponential backoff
55
+ from ..interfaces import DBInterface
56
+ from ..models import AgentResponse
57
+
58
+
59
+ BASEPROMPT = """
60
+ Your name is {name}, You are a helpful assistant built to provide comprehensive guidance and support on data calculations and various aspects of payroll, such as earnings, deductions, salary information, and payroll tax. The goal is to ensure accurate, timely, and compliant payroll processing.
61
+
62
+ **Your Capabilities:**
63
+
64
+ 1. **Earnings Calculation:**
65
+ - Calculate regular earnings based on hourly rates or salaries.
66
+ - Handle overtime calculations, including differentials and double-time as needed.
67
+ - Include bonuses, commissions, and other incentive earnings.
68
+
69
+ 2. **Deductions:**
70
+ - Calculate mandatory deductions including federal, state, and local taxes.
71
+ - Handle other withholdings such as Social Security, Medicare, disability insurance, and unemployment insurance.
72
+ - Process voluntary deductions (e.g., health insurance premiums, retirement plan contributions, charitable donations).
73
+
74
+ 3. **Salary Information:**
75
+ - Provide gross and net salary breakdowns.
76
+ - Assist in setting up and adjusting salary structures.
77
+ - Manage payroll for part-time, full-time, and contract employees.
78
+
79
+ These keywords must never be translated and transformed:
80
+ - Action:
81
+ - Thought:
82
+ - Action Input:
83
+ because they are part of the thinking process instead of the output.
84
+
85
+ You are working with {num_dfs} pandas dataframes in Python named df1, df2, etc. You should use the tools below to answer the question posed to you:
86
+
87
+ - python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.
88
+ - {tools}
89
+
90
+ To use a tool, please use the following format:
91
+
92
+ ```
93
+ Question: the input question you must answer.
94
+ Thought: You should always think about what to do, don't try to reason out the answer on your own.
95
+ Action: the action to take, should be one of [python_repl_ast,{tool_names}] if using a tool, otherwise answer on your own.
96
+ Action Input: the input to the action.
97
+ Observation: the result of the action.
98
+ ... (this Thought/Action/Action Input/Observation can repeat N times)
99
+ Final Thought: I now know the final answer.
100
+ Final Answer: the final answer to the original input question.
101
+ ```
102
+
103
+
104
+ ```
105
+ This is the result of `print(df1.head())` for each dataframe:
106
+ {dfs_head}
107
+ ```
108
+
109
+ Begin!
110
+
111
+ Question: {input}
112
+ {agent_scratchpad}
113
+ """
114
+
115
+
116
+ class BaseAgent(ABC, DBInterface):
117
+ """Base Agent Interface.
118
+
119
+ This is the base class for all Agent Chatbots. It is an abstract class that
120
+ must be implemented by all Agent Chatbots.
121
+
122
+ """
123
+ def __init__(
124
+ self,
125
+ name: str = 'Agent',
126
+ llm: str = 'vertexai',
127
+ tools: list = None,
128
+ prompt_template: str = None,
129
+ **kwargs
130
+ ):
131
+ self.name = name
132
+ self.tools = tools
133
+ self.prompt_template = prompt_template
134
+ if not self.prompt_template:
135
+ self.prompt_template = BASEPROMPT
136
+ self.llm = self.llm_chain(llm, **kwargs)
137
+ self.prompt = self.get_prompt(self.prompt_template)
138
+ self.kwargs = kwargs
139
+ # Bot:
140
+ self._agent = None
141
+ self.agent = None
142
+ # Logger:
143
+ self.logger = logging.getLogger('Parrot.Agent')
144
+
145
+ def get_prompt(self, prompt, **kwargs):
146
+ partial_prompt = ChatPromptTemplate.from_template(prompt)
147
+ return partial_prompt.partial(tools=self.tools, name=self.name, **kwargs)
148
+
149
+ def create_agent(self, **kwargs):
150
+ # Create a ReAct Agent:
151
+ self.agent = RunnableAgent(
152
+ runnable=create_react_agent(
153
+ self.llm,
154
+ self.tools,
155
+ prompt=self.prompt,
156
+ ), # type: ignore
157
+ input_keys_arg=["input"],
158
+ return_keys_arg=["output"],
159
+ )
160
+ return self.agent
161
+
162
+ @retry(wait=wait_random_exponential(min=1, max=60), stop=stop_after_attempt(6))
163
+ def llm_chain(
164
+ self, llm: str = "vertexai", **kwargs
165
+ ):
166
+ """llm_chain.
167
+
168
+ Args:
169
+ llm (str): The language model to use.
170
+
171
+ Returns:
172
+ str: The language model to use.
173
+
174
+ """
175
+ if llm == 'openai':
176
+ mdl = OpenAILLM(model="gpt-3.5-turbo", **kwargs)
177
+ elif llm == 'vertexai':
178
+ mdl = VertexLLM(model="gemini-1.5-pro", **kwargs)
179
+ elif llm == 'anthropic':
180
+ mdl = Anthropic(model="claude-3-opus-20240229", **kwargs)
181
+ elif llm == 'groq':
182
+ mdl = GroqLLM(model="llama3-70b-8192", **kwargs)
183
+ elif llm == 'mixtral':
184
+ mdl = GroqLLM(model="mixtral-8x7b-32768", **kwargs)
185
+ elif llm == 'google':
186
+ mdl = GoogleGenAI(model="models/gemini-1.5-pro-latest", **kwargs)
187
+ else:
188
+ raise ValueError(f"Invalid llm: {llm}")
189
+
190
+ # get the LLM:
191
+ return mdl.get_llm()
192
+
193
+ def get_executor(self, agent: RunnableAgent, tools: list, verbose: bool = True):
194
+ return AgentExecutor(
195
+ agent=agent,
196
+ tools=tools,
197
+ # callback_manager=callback_manager,
198
+ verbose=verbose,
199
+ return_intermediate_steps=True,
200
+ max_iterations=5,
201
+ max_execution_time=360,
202
+ handle_parsing_errors=True,
203
+ # memory=self.memory,
204
+ # early_stopping_method='generate',
205
+ **(self.kwargs or {}),
206
+ )
207
+
208
+ def get_chatbot(self):
209
+ return self.get_executor(self.agent, self.tools)
210
+
211
+
212
+ def __enter__(self):
213
+ return self
214
+
215
+ def __exit__(self, exc_type, exc_val, exc_tb):
216
+ self._agent = None
217
+
218
+ def get_conversation(self):
219
+ # Create the agent:
220
+ self.create_agent()
221
+ # define conversation:
222
+ self._agent = self.get_chatbot()
223
+ return self
224
+
225
+ def invoke(self, query: str):
226
+ """invoke.
227
+
228
+ Args:
229
+ query (str): The query to ask the chatbot.
230
+
231
+ Returns:
232
+ str: The response from the chatbot.
233
+
234
+ """
235
+ input_question = {
236
+ "input": query
237
+ }
238
+ result = self._agent.invoke(input_question)
239
+ try:
240
+ response = AgentResponse(question=query, **result)
241
+ try:
242
+ return self.as_markdown(
243
+ response
244
+ ), response
245
+ except Exception as exc:
246
+ self.logger.exception(
247
+ f"Error on response: {exc}"
248
+ )
249
+ return result.get('output', None), None
250
+ except Exception as e:
251
+ return result, e
252
+
253
+ def as_markdown(self, response: AgentResponse) -> str:
254
+ markdown_output = f"**Question**: {response.question} \n"
255
+ markdown_output += f"**Answer**: {response.output} \n"
256
+ markdown_output += "```"
257
+ return markdown_output
@@ -0,0 +1,9 @@
1
+ from .abstract import AbstractChatbot
2
+
3
+
4
+ class Chatbot(AbstractChatbot):
5
+ """Represents an Chatbot in Navigator.
6
+
7
+ Each Chatbot has a name, a role, a goal, a backstory,
8
+ and an optional language model (llm).
9
+ """
@@ -0,0 +1,17 @@
1
+ from .basic import Chatbot
2
+
3
+
4
+ class BoseBot(Chatbot):
5
+ """Represents an agent in Navigator.
6
+ https://eminent-kiwi-trusty.ngrok-free.app/api/bose/messages
7
+ Each agent has a name, a role, a goal, a backstory,
8
+ and an optional language model (llm).
9
+ """
10
+ name: str = 'BoseBot'
11
+ company: str = 'T-ROC Global'
12
+ company_website: str = 'https://www.trocglobal.com'
13
+ contact_information = 'communications@trocglobal.com'
14
+ contact_form = 'https://bose.trocdigital.io/bose/bose_ticketing_system'
15
+ role: str = 'Bose Sound Systems Expert Technician and Consultant.'
16
+ goal = 'Bring useful information to Bose Technicians and Consultants.'
17
+ specialty_area = 'Bose endcap displays that are used to showcase Bose products'
@@ -0,0 +1,17 @@
1
+ from parrot.chatbots import Chatbot
2
+
3
+ class Cody(Chatbot):
4
+ """Represents a Python expert in Navigator.
5
+
6
+ Each expert has a name, a role, a goal, a backstory,
7
+ and an optional language model (llm).
8
+ """
9
+ name: str = 'Cody'
10
+ company_information: dict = {
11
+ 'company': 'T-ROC Global',
12
+ 'company_website': 'https://www.trocglobal.com',
13
+ 'contact_email': 'communications@trocglobal.com',
14
+ 'contact_form': 'https://www.surveymonkey.com/r/TROC_Suggestion_Box'
15
+ }
16
+ role: str = 'Python Expert'
17
+ goal = 'Provide useful information about Python programming to employees.'
@@ -0,0 +1,100 @@
1
+ from langchain_experimental.tools.python.tool import PythonAstREPLTool
2
+ from .base import BaseAgent
3
+
4
+
5
+ BASEPROMPT = """
6
+ Your name is {name}. You are a helpful and advanced AI assistant equipped with various tools to help users find information and solve problems efficiently.
7
+ You are designed to be able to assist with a wide range of tasks.
8
+ Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics.
9
+ Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist.
10
+
11
+
12
+ **Has access to the following tools:**
13
+
14
+ - {tools}
15
+ - Google Web Search: Perform web searches to retrieve the latest and most relevant information from the internet.
16
+ - google_maps_location_finder: Find location information, including latitude, longitude, and other geographical details.
17
+ - Wikipedia: Access detailed and verified information from Wikipedia.
18
+ - WikiData: Fetch structured data from WikiData for precise and factual details.
19
+ - Bing Search: Search the web using Microsoft Bing Search, conduct searches using Bing for alternative perspectives and sources.
20
+ - DuckDuckGo Web Search: Search the web using DuckDuckGo Search.
21
+ - zipcode_distance: Calculate the distance between two zip codes.
22
+ - zipcode_location: Obtain geographical information about a specific zip code.
23
+ - zipcodes_by_radius: Find all US zip codes within a given radius of a zip code.
24
+ - asknews_search: Search for up-to-date news and historical news on AskNews site.
25
+ - StackExchangeSearch: Search for questions and answers on Stack Exchange.
26
+ - openweather_tool: Get current weather conditions based on specific location, providing latitude and longitude.
27
+ - OpenWeatherMap: Get weather information about a location.
28
+ - yahoo_finance_news: Retrieve the latest financial news from Yahoo Finance.
29
+ - python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.
30
+ - youtube_search: Search for videos on YouTube based on specific keywords.
31
+
32
+
33
+ Use these tools effectively to provide accurate and comprehensive responses.
34
+
35
+ **Instructions:**
36
+ 1. Understand the Query: Comprehend the user's request.
37
+ 2. Determine Confidence: If confident (90%+), provide the answer directly within the Thought process.
38
+ 3. Choose Tool: If needed, select the most suitable tool, using one of [{tool_names}].
39
+ 4. Collect Information: Use the tool to gather data.
40
+ 5. Analyze Information: Identify patterns, relationships, and insights.
41
+ 6. Synthesize Response: Combine the information into a clear response.
42
+ 7. Cite Sources: Mention the sources of the information.
43
+
44
+ ** Your Style: **
45
+ - Maintain a professional and friendly tone.
46
+ - Be clear and concise in your explanations.
47
+ - Use simple language for complex topics to ensure user understanding.
48
+
49
+ To respond directly, use the following format:
50
+ ```
51
+ Question: the input question you must answer.
52
+ Thought: Explain your reasoning.
53
+ Final Thought: Summarize your findings.
54
+ Final Answer: Provide a clear and structured answer to the original question with relevant details.
55
+ ```
56
+
57
+
58
+ To use a tool, please use the following format:
59
+ ```
60
+ Question: the input question you must answer.
61
+ Thought: Explain your reasoning, including whether you need to use a tool.
62
+ Action: the action to take, should be one of [{tool_names}].
63
+ - If using a tool: Specify the tool name (e.g., "Google Web Search") and the input.
64
+ Action Input: the input to the action.
65
+ Observation: the result of the action.
66
+ ... (this Thought/Action/Action Input/Observation can repeat N times)
67
+ Final Thought: Summarize your findings.
68
+ Final Answer: Provide a clear and structured answer to the original question with relevant details.
69
+ Detailed Result: Include the detailed result from the tool here if applicable.
70
+ ```
71
+
72
+ Remember: Strictly adhere to this format for each step. If unsure, prioritize answering directly to avoid potential errors.
73
+
74
+ Begin!
75
+
76
+ Question: {input}
77
+ {agent_scratchpad}
78
+ """
79
+
80
+ class CopilotAgent(BaseAgent):
81
+ """CopilotAgent Agent.
82
+
83
+ This is Agent Base class for AI Copilots.
84
+ """
85
+ def __init__(
86
+ self,
87
+ name: str = 'Agent',
88
+ llm: str = 'vertexai',
89
+ tools: list = None,
90
+ prompt_template: str = None,
91
+ **kwargs
92
+ ):
93
+ super().__init__(name, llm, tools, prompt_template, **kwargs)
94
+ prompt_template = BASEPROMPT
95
+ # self.tools = [PythonAstREPLTool(locals=df_locals)] + list(tools)
96
+ self.tools = tools
97
+ self.prompt = self.get_prompt(
98
+ prompt_template
99
+ )
100
+ # print('PROMPT > ', self.prompt)
@@ -0,0 +1,103 @@
1
+ from typing import Union
2
+ import pandas as pd
3
+ from langchain_experimental.tools.python.tool import PythonAstREPLTool
4
+ from .base import BaseAgent
5
+
6
+
7
+ BASEPROMPT = """
8
+ Your name is {name}, You are a helpful assistant built to provide comprehensive guidance and support on data calculations and various aspects of payroll, such as earnings, deductions, salary information, and payroll tax. The goal is to ensure accurate, timely, and compliant payroll processing.
9
+
10
+ **Your Capabilities:**
11
+
12
+ 1. **Earnings Calculation:**
13
+ - Calculate regular earnings based on hourly rates or salaries.
14
+ - Handle overtime calculations, including differentials and double-time as needed.
15
+ - Include bonuses, commissions, and other incentive earnings.
16
+
17
+ 2. **Deductions:**
18
+ - Calculate mandatory deductions including federal, state, and local taxes.
19
+ - Handle other withholdings such as Social Security, Medicare, disability insurance, and unemployment insurance.
20
+ - Process voluntary deductions (e.g., health insurance premiums, retirement plan contributions, charitable donations).
21
+
22
+ 3. **Salary Information:**
23
+ - Provide gross and net salary breakdowns.
24
+ - Assist in setting up and adjusting salary structures.
25
+ - Manage payroll for part-time, full-time, and contract employees.
26
+
27
+ These keywords must never be translated and transformed:
28
+ - Action:
29
+ - Thought:
30
+ - Action Input:
31
+ because they are part of the thinking process instead of the output.
32
+
33
+ You are working with {num_dfs} pandas dataframes in Python named df1, df2, etc. You should use the tools below to answer the question posed to you:
34
+
35
+ - python_repl_ast: A Python shell. Use this to execute python commands. Input should be a valid python command. When using this tool, sometimes output is abbreviated - make sure it does not look abbreviated before using it in your answer.
36
+ - {tools}
37
+
38
+ To use a tool, please use the following format:
39
+
40
+ ```
41
+ Question: the input question you must answer.
42
+ Thought: You should always think about what to do, don't try to reason out the answer on your own.
43
+ Action: the action to take, should be one of [python_repl_ast,{tool_names}] if using a tool, otherwise answer on your own.
44
+ Action Input: the input to the action.
45
+ Observation: the result of the action.
46
+ ... (this Thought/Action/Action Input/Observation can repeat N times)
47
+ Final Thought: I now know the final answer.
48
+ Final Answer: the final answer to the original input question.
49
+ ```
50
+
51
+
52
+ ```
53
+ This is the result of `print(df1.head())` for each dataframe:
54
+ {dfs_head}
55
+ ```
56
+
57
+ Begin!
58
+
59
+ Question: {input}
60
+ {agent_scratchpad}
61
+ """
62
+
63
+
64
+ class DataFrameAgent(BaseAgent):
65
+ """Dataframe Agent.
66
+
67
+ This is the Pandas Agent Chatbot.
68
+ """
69
+ def __init__(
70
+ self,
71
+ name: str = 'Agent',
72
+ llm: str = 'vertexai',
73
+ tools: list = None,
74
+ df: Union[list[pd.DataFrame], pd.DataFrame] = None,
75
+ prompt_template: str = None,
76
+ **kwargs
77
+ ):
78
+ super().__init__(name, llm, tools, prompt_template, **kwargs)
79
+ for _df in df if isinstance(df, list) else [df]:
80
+ if not isinstance(_df, pd.DataFrame):
81
+ raise ValueError(
82
+ f"Expected pandas DataFrame, got {type(_df)}"
83
+ )
84
+ self.df = df
85
+ df_locals = {}
86
+ dfs_head = ""
87
+ num_dfs = 1
88
+ if isinstance(df, pd.DataFrame):
89
+ df = [df]
90
+ num_dfs = len(df)
91
+ for i, dataframe in enumerate(df):
92
+ df_locals[f"df{i + 1}"] = dataframe
93
+ dfs_head += (
94
+ f"\n\n- This is the result of `print(df{i + 1}.head())`:\n"
95
+ + dataframe.head().to_markdown() + "\n"
96
+ )
97
+ prompt_template = BASEPROMPT
98
+ self.tools = [PythonAstREPLTool(locals=df_locals)] + list(tools)
99
+ self.prompt = self.get_prompt(
100
+ prompt_template,
101
+ num_dfs=num_dfs,
102
+ dfs_head=dfs_head
103
+ )
@@ -0,0 +1,15 @@
1
+ from parrot.chatbots import Chatbot
2
+
3
+ class HRAgent(Chatbot):
4
+ """Represents an Human Resources agent in Navigator.
5
+
6
+ Each agent has a name, a role, a goal, a backstory,
7
+ and an optional language model (llm).
8
+ """
9
+ name: str = 'TROCers'
10
+ company: str = 'T-ROC Global'
11
+ company_website: str = 'https://www.trocglobal.com'
12
+ contact_information = 'communications@trocglobal.com'
13
+ contact_form = 'https://www.surveymonkey.com/r/TROC_Suggestion_Box'
14
+ role: str = 'Human Resources Assistant'
15
+ goal = 'Bring useful information to employees'
@@ -0,0 +1,17 @@
1
+ from .basic import Chatbot
2
+
3
+
4
+ class OddieBot(Chatbot):
5
+ """Represents an agent in Navigator.
6
+
7
+ Each agent has a name, a role, a goal, a backstory,
8
+ and an optional language model (llm).
9
+ """
10
+ name: str = 'Oddie'
11
+ company: str = 'T-ROC Global'
12
+ company_website: str = 'https://www.trocglobal.com'
13
+ contact_information = 'communications@trocglobal.com'
14
+ contact_form = 'https://www.surveymonkey.com/r/TROC_Suggestion_Box'
15
+ role = "Odoo and ERP Specialist and Odoo Programmer"
16
+ goal = "To provide information and support on Odoo and ERP systems, help with troubleshooting, and answer any questions you may have about any Odoo and ERP systems implementation."
17
+ specialty_area = 'Bring useful information about Odoo ERP, documentation, usage, samples, etc.'