Skip to content

Commit e0ce28c

Browse files
committed
ruff y u so rough
1 parent fa4d0e7 commit e0ce28c

17 files changed

Lines changed: 223 additions & 351 deletions

examples/ag2/async_human_input.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@
7070
"outputs": [],
7171
"source": [
7272
"agentops.init(auto_start_session=False)\n",
73-
"tracer = agentops.start_trace(trace_name=\"AG2 Agent chat with Async Human Inputs\", tags=[\"ag2-chat-async-human-inputs\", \"agentops-example\"])"
73+
"tracer = agentops.start_trace(\n",
74+
" trace_name=\"AG2 Agent chat with Async Human Inputs\", tags=[\"ag2-chat-async-human-inputs\", \"agentops-example\"]\n",
75+
")"
7476
]
7577
},
7678
{

examples/ag2/tools_wikipedia_search.ipynb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@
7171
"outputs": [],
7272
"source": [
7373
"agentops.init(auto_start_session=False)\n",
74-
"tracer = agentops.start_trace(trace_name=\"AG2 Wikipedia Search Tools\", tags=[\"ag2-wikipedia-search-tools\", \"agentops-example\"])"
74+
"tracer = agentops.start_trace(\n",
75+
" trace_name=\"AG2 Wikipedia Search Tools\", tags=[\"ag2-wikipedia-search-tools\", \"agentops-example\"]\n",
76+
")"
7577
]
7678
},
7779
{

examples/autogen/AgentChat.ipynb

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@
9999
"source": [
100100
"# When initializing AgentOps, you can pass in optional tags to help filter sessions\n",
101101
"agentops.init(auto_start_session=False)\n",
102-
"tracer = agentops.start_trace(trace_name=\"Microsoft Agent Chat Example\", tags=[\"autogen-chat\", \"microsoft-autogen\", \"agentops-example\"])"
102+
"tracer = agentops.start_trace(\n",
103+
" trace_name=\"Microsoft Agent Chat Example\", tags=[\"autogen-chat\", \"microsoft-autogen\", \"agentops-example\"]\n",
104+
")"
103105
]
104106
},
105107
{
@@ -133,7 +135,7 @@
133135
"outputs": [],
134136
"source": [
135137
"# Define model and API key\n",
136-
"model_name = \"gpt-4-turbo\" # Or \"gpt-4o\" / \"gpt-4o-mini\" as per migration guide examples\n",
138+
"model_name = \"gpt-4-turbo\" # Or \"gpt-4o\" / \"gpt-4o-mini\" as per migration guide examples\n",
137139
"api_key = os.getenv(\"OPENAI_API_KEY\")\n",
138140
"\n",
139141
"# Create the model client\n",
@@ -142,26 +144,27 @@
142144
"# Create the agent that uses the LLM.\n",
143145
"assistant = AssistantAgent(\n",
144146
" name=\"assistant\",\n",
145-
" system_message=\"You are a helpful assistant.\", # Added system message for clarity\n",
146-
" model_client=model_client\n",
147+
" system_message=\"You are a helpful assistant.\", # Added system message for clarity\n",
148+
" model_client=model_client,\n",
147149
")\n",
148150
"\n",
149151
"user_proxy_initiator = UserProxyAgent(\"user_initiator\")\n",
150152
"\n",
153+
"\n",
151154
"async def main():\n",
152-
" termination = MaxMessageTermination(max_messages=2) \n",
155+
" termination = MaxMessageTermination(max_messages=2)\n",
153156
"\n",
154157
" group_chat = RoundRobinGroupChat(\n",
155-
" [user_proxy_initiator, assistant], # Corrected: agents as positional argument\n",
156-
" termination_condition=termination\n",
158+
" [user_proxy_initiator, assistant], # Corrected: agents as positional argument\n",
159+
" termination_condition=termination,\n",
157160
" )\n",
158-
" \n",
161+
"\n",
159162
" chat_task = \"How can I help you today?\"\n",
160163
" print(f\"User Initiator: {chat_task}\")\n",
161164
"\n",
162165
" try:\n",
163166
" stream = group_chat.run_stream(task=chat_task)\n",
164-
" await Console().run(stream) \n",
167+
" await Console().run(stream)\n",
165168
" agentops.end_trace(tracer, end_state=\"Success\")\n",
166169
"\n",
167170
" except StdinNotImplementedError:\n",
@@ -174,14 +177,16 @@
174177
" finally:\n",
175178
" await model_client.close()\n",
176179
"\n",
177-
"if __name__ == '__main__':\n",
180+
"\n",
181+
"if __name__ == \"__main__\":\n",
178182
" try:\n",
179183
" loop = asyncio.get_running_loop()\n",
180184
" except RuntimeError:\n",
181185
" loop = None\n",
182186
"\n",
183187
" if loop and loop.is_running():\n",
184188
" import nest_asyncio\n",
189+
"\n",
185190
" nest_asyncio.apply()\n",
186191
" asyncio.run(main())\n",
187192
" else:\n",

examples/autogen/MathAgent.ipynb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@
9696
"outputs": [],
9797
"source": [
9898
"agentops.init(auto_start_session=False)\n",
99-
"tracer = agentops.start_trace(trace_name=\"Microsoft Autogen Tool Example\", tags=[\"autogen-tool\", \"microsoft-autogen\", \"agentops-example\"])"
99+
"tracer = agentops.start_trace(\n",
100+
" trace_name=\"Microsoft Autogen Tool Example\", tags=[\"autogen-tool\", \"microsoft-autogen\", \"agentops-example\"]\n",
101+
")"
100102
]
101103
},
102104
{
@@ -139,6 +141,7 @@
139141
"\n",
140142
"Operator = Literal[\"+\", \"-\", \"*\", \"/\"]\n",
141143
"\n",
144+
"\n",
142145
"def calculator(a: int, b: int, operator: Annotated[Operator, \"operator\"]) -> int:\n",
143146
" if operator == \"+\":\n",
144147
" return a + b\n",
@@ -151,29 +154,29 @@
151154
" else:\n",
152155
" raise ValueError(\"Invalid operator\")\n",
153156
"\n",
157+
"\n",
154158
"async def main():\n",
155159
" assistant = AssistantAgent(\n",
156160
" name=\"Assistant\",\n",
157161
" system_message=\"You are a helpful AI assistant. You can help with simple calculations. Return 'TERMINATE' when the task is done.\",\n",
158162
" model_client=model_client,\n",
159163
" tools=[calculator],\n",
160-
" reflect_on_tool_use=True\n",
164+
" reflect_on_tool_use=True,\n",
161165
" )\n",
162166
"\n",
163167
" initial_task_message = \"What is (1423 - 123) / 3 + (32 + 23) * 5?\"\n",
164168
" print(f\"User Task: {initial_task_message}\")\n",
165169
"\n",
166170
" try:\n",
167171
" from autogen_core import CancellationToken\n",
168-
" \n",
172+
"\n",
169173
" response = await assistant.on_messages(\n",
170-
" [TextMessage(content=initial_task_message, source=\"user\")],\n",
171-
" CancellationToken()\n",
174+
" [TextMessage(content=initial_task_message, source=\"user\")], CancellationToken()\n",
172175
" )\n",
173-
" \n",
176+
"\n",
174177
" final_response_message = response.chat_message\n",
175178
" if final_response_message:\n",
176-
" print(f\"Assistant: {final_response_message.to_text()}\")\n",
179+
" print(f\"Assistant: {final_response_message.to_text()}\")\n",
177180
" else:\n",
178181
" print(\"Assistant did not provide a final message.\")\n",
179182
"\n",
@@ -188,14 +191,16 @@
188191
" finally:\n",
189192
" await model_client.close()\n",
190193
"\n",
191-
"if __name__ == '__main__':\n",
194+
"\n",
195+
"if __name__ == \"__main__\":\n",
192196
" try:\n",
193197
" loop = asyncio.get_running_loop()\n",
194198
" except RuntimeError:\n",
195199
" loop = None\n",
196200
"\n",
197201
" if loop and loop.is_running():\n",
198202
" import nest_asyncio\n",
203+
"\n",
199204
" nest_asyncio.apply()\n",
200205
" asyncio.run(main())\n",
201206
" else:\n",

examples/crewai/job_posting.ipynb

Lines changed: 3 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,9 @@
3232
},
3333
{
3434
"cell_type": "code",
35-
"execution_count": null,
3635
"metadata": {},
3736
"outputs": [],
38-
"source": [
39-
"from crewai import Crew, Agent, Task\n",
40-
"from crewai_tools.tools import WebsiteSearchTool, SerperDevTool, FileReadTool\n",
41-
"import agentops\n",
42-
"import os\n",
43-
"from dotenv import load_dotenv"
44-
]
37+
"source": "from crewai import Crew, Agent, Task\nfrom crewai_tools.tools import WebsiteSearchTool, SerperDevTool, FileReadTool\nimport agentops\nimport os\nfrom dotenv import load_dotenv\nfrom textwrap import dedent"
4538
},
4639
{
4740
"cell_type": "markdown",
@@ -123,83 +116,9 @@
123116
},
124117
{
125118
"cell_type": "code",
126-
"execution_count": null,
127119
"metadata": {},
128120
"outputs": [],
129-
"source": [
130-
"from textwrap import dedent\n",
131-
"\n",
132-
"\n",
133-
"class Tasks:\n",
134-
" def research_company_culture_task(self, agent, company_description, company_domain):\n",
135-
" return Task(\n",
136-
" description=dedent(\n",
137-
" f\"\"\"\\\n",
138-
"\t\t\t\t\t\t\t\tAnalyze the provided company website and the hiring manager's company's domain {company_domain}, description: \"{company_description}\". Focus on understanding the company's culture, values, and mission. Identify unique selling points and specific projects or achievements highlighted on the site.\n",
139-
"\t\t\t\t\t\t\t\tCompile a report summarizing these insights, specifically how they can be leveraged in a job posting to attract the right candidates.\"\"\"\n",
140-
" ),\n",
141-
" expected_output=dedent(\n",
142-
" \"\"\"\\\n",
143-
"\t\t\t\t\t\t\t\tA comprehensive report detailing the company's culture, values, and mission, along with specific selling points relevant to the job role. Suggestions on incorporating these insights into the job posting should be included.\"\"\"\n",
144-
" ),\n",
145-
" agent=agent,\n",
146-
" )\n",
147-
"\n",
148-
" def research_role_requirements_task(self, agent, hiring_needs):\n",
149-
" return Task(\n",
150-
" description=dedent(\n",
151-
" f\"\"\"\\\n",
152-
"\t\t\t\t\t\t\t\tBased on the hiring manager's needs: \"{hiring_needs}\", identify the key skills, experiences, and qualities the ideal candidate should possess for the role. Consider the company's current projects, its competitive landscape, and industry trends. Prepare a list of recommended job requirements and qualifications that align with the company's needs and values.\"\"\"\n",
153-
" ),\n",
154-
" expected_output=dedent(\n",
155-
" \"\"\"\\\n",
156-
"\t\t\t\t\t\t\t\tA list of recommended skills, experiences, and qualities for the ideal candidate, aligned with the company's culture, ongoing projects, and the specific role's requirements.\"\"\"\n",
157-
" ),\n",
158-
" agent=agent,\n",
159-
" )\n",
160-
"\n",
161-
" def draft_job_posting_task(self, agent, company_description, hiring_needs, specific_benefits):\n",
162-
" return Task(\n",
163-
" description=dedent(\n",
164-
" f\"\"\"\\\n",
165-
"\t\t\t\t\t\t\t\tDraft a job posting for the role described by the hiring manager: \"{hiring_needs}\". Use the insights on \"{company_description}\" to start with a compelling introduction, followed by a detailed role description, responsibilities, and required skills and qualifications. Ensure the tone aligns with the company's culture and incorporate any unique benefits or opportunities offered by the company.\n",
166-
"\t\t\t\t\t\t\t\tSpecfic benefits: \"{specific_benefits}\"\"\"\n",
167-
" ),\n",
168-
" expected_output=dedent(\n",
169-
" \"\"\"\\\n",
170-
"\t\t\t\t\t\t\t\tA detailed, engaging job posting that includes an introduction, role description, responsibilities, requirements, and unique company benefits. The tone should resonate with the company's culture and values, aimed at attracting the right candidates.\"\"\"\n",
171-
" ),\n",
172-
" agent=agent,\n",
173-
" )\n",
174-
"\n",
175-
" def review_and_edit_job_posting_task(self, agent, hiring_needs):\n",
176-
" return Task(\n",
177-
" description=dedent(\n",
178-
" f\"\"\"\\\n",
179-
"\t\t\t\t\t\t\t\tReview the draft job posting for the role: \"{hiring_needs}\". Check for clarity, engagement, grammatical accuracy, and alignment with the company's culture and values. Edit and refine the content, ensuring it speaks directly to the desired candidates and accurately reflects the role's unique benefits and opportunities. Provide feedback for any necessary revisions.\"\"\"\n",
180-
" ),\n",
181-
" expected_output=dedent(\n",
182-
" \"\"\"\\\n",
183-
"\t\t\t\t\t\t\t\tA polished, error-free job posting that is clear, engaging, and perfectly aligned with the company's culture and values. Feedback on potential improvements and final approval for publishing. Formated in markdown.\"\"\"\n",
184-
" ),\n",
185-
" agent=agent,\n",
186-
" output_file=\"job_posting.md\",\n",
187-
" )\n",
188-
"\n",
189-
" def industry_analysis_task(self, agent, company_domain, company_description):\n",
190-
" return Task(\n",
191-
" description=dedent(\n",
192-
" f\"\"\"\\\n",
193-
"\t\t\t\t\t\t\t\tConduct an in-depth analysis of the industry related to the company's domain: \"{company_domain}\". Investigate current trends, challenges, and opportunities within the industry, utilizing market reports, recent developments, and expert opinions. Assess how these factors could impact the role being hired for and the overall attractiveness of the position to potential candidates.\n",
194-
"\t\t\t\t\t\t\t\tConsider how the company's position within this industry and its response to these trends could be leveraged to attract top talent. Include in your report how the role contributes to addressing industry challenges or seizing opportunities.\"\"\"\n",
195-
" ),\n",
196-
" expected_output=dedent(\n",
197-
" \"\"\"\\\n",
198-
"\t\t\t\t\t\t\t\tA detailed analysis report that identifies major industry trends, challenges, and opportunities relevant to the company's domain and the specific job role. This report should provide strategic insights on positioning the job role and the company as an attractive choice for potential candidates.\"\"\"\n",
199-
" ),\n",
200-
" agent=agent,\n",
201-
" )"
202-
]
121+
"source": "class Tasks:\n def research_company_culture_task(self, agent, company_description, company_domain):\n return Task(\n description=dedent(\n f\"\"\"\\\n\t\t\t\t\t\t\t\tAnalyze the provided company website and the hiring manager's company's domain {company_domain}, description: \"{company_description}\". Focus on understanding the company's culture, values, and mission. Identify unique selling points and specific projects or achievements highlighted on the site.\n\t\t\t\t\t\t\t\tCompile a report summarizing these insights, specifically how they can be leveraged in a job posting to attract the right candidates.\"\"\"\n ),\n expected_output=dedent(\n \"\"\"\\\n\t\t\t\t\t\t\t\tA comprehensive report detailing the company's culture, values, and mission, along with specific selling points relevant to the job role. Suggestions on incorporating these insights into the job posting should be included.\"\"\"\n ),\n agent=agent,\n )\n\n def research_role_requirements_task(self, agent, hiring_needs):\n return Task(\n description=dedent(\n f\"\"\"\\\n\t\t\t\t\t\t\t\tBased on the hiring manager's needs: \"{hiring_needs}\", identify the key skills, experiences, and qualities the ideal candidate should possess for the role. Consider the company's current projects, its competitive landscape, and industry trends. Prepare a list of recommended job requirements and qualifications that align with the company's needs and values.\"\"\"\n ),\n expected_output=dedent(\n \"\"\"\\\n\t\t\t\t\t\t\t\tA list of recommended skills, experiences, and qualities for the ideal candidate, aligned with the company's culture, ongoing projects, and the specific role's requirements.\"\"\"\n ),\n agent=agent,\n )\n\n def draft_job_posting_task(self, agent, company_description, hiring_needs, specific_benefits):\n return Task(\n description=dedent(\n f\"\"\"\\\n\t\t\t\t\t\t\t\tDraft a job posting for the role described by the hiring manager: \"{hiring_needs}\". Use the insights on \"{company_description}\" to start with a compelling introduction, followed by a detailed role description, responsibilities, and required skills and qualifications. Ensure the tone aligns with the company's culture and incorporate any unique benefits or opportunities offered by the company.\n\t\t\t\t\t\t\t\tSpecfic benefits: \"{specific_benefits}\"\"\"\n ),\n expected_output=dedent(\n \"\"\"\\\n\t\t\t\t\t\t\t\tA detailed, engaging job posting that includes an introduction, role description, responsibilities, requirements, and unique company benefits. The tone should resonate with the company's culture and values, aimed at attracting the right candidates.\"\"\"\n ),\n agent=agent,\n )\n\n def review_and_edit_job_posting_task(self, agent, hiring_needs):\n return Task(\n description=dedent(\n f\"\"\"\\\n\t\t\t\t\t\t\t\tReview the draft job posting for the role: \"{hiring_needs}\". Check for clarity, engagement, grammatical accuracy, and alignment with the company's culture and values. Edit and refine the content, ensuring it speaks directly to the desired candidates and accurately reflects the role's unique benefits and opportunities. Provide feedback for any necessary revisions.\"\"\"\n ),\n expected_output=dedent(\n \"\"\"\\\n\t\t\t\t\t\t\t\tA polished, error-free job posting that is clear, engaging, and perfectly aligned with the company's culture and values. Feedback on potential improvements and final approval for publishing. Formated in markdown.\"\"\"\n ),\n agent=agent,\n output_file=\"job_posting.md\",\n )\n\n def industry_analysis_task(self, agent, company_domain, company_description):\n return Task(\n description=dedent(\n f\"\"\"\\\n\t\t\t\t\t\t\t\tConduct an in-depth analysis of the industry related to the company's domain: \"{company_domain}\". Investigate current trends, challenges, and opportunities within the industry, utilizing market reports, recent developments, and expert opinions. Assess how these factors could impact the role being hired for and the overall attractiveness of the position to potential candidates.\n\t\t\t\t\t\t\t\tConsider how the company's position within this industry and its response to these trends could be leveraged to attract top talent. Include in your report how the role contributes to addressing industry challenges or seizing opportunities.\"\"\"\n ),\n expected_output=dedent(\n \"\"\"\\\n\t\t\t\t\t\t\t\tA detailed analysis report that identifies major industry trends, challenges, and opportunities relevant to the company's domain and the specific job role. This report should provide strategic insights on positioning the job role and the company as an attractive choice for potential candidates.\"\"\"\n ),\n agent=agent,\n )"
203122
},
204123
{
205124
"cell_type": "code",
@@ -276,4 +195,4 @@
276195
},
277196
"nbformat": 4,
278197
"nbformat_minor": 2
279-
}
198+
}

0 commit comments

Comments
 (0)