From 67e4433dc282644ba7e8146f0ab3e676b8cbd2a7 Mon Sep 17 00:00:00 2001 From: Thiago Moretto Date: Mon, 5 Aug 2024 13:29:39 -0300 Subject: [PATCH 1/3] Fix flaky test due to suppressed error on on_llm_start callback --- src/crewai/utilities/token_counter_callback.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/crewai/utilities/token_counter_callback.py b/src/crewai/utilities/token_counter_callback.py index 51200f37e..c5f632d5f 100644 --- a/src/crewai/utilities/token_counter_callback.py +++ b/src/crewai/utilities/token_counter_callback.py @@ -10,24 +10,24 @@ from crewai.agents.agent_builder.utilities.base_token_process import TokenProces class TokenCalcHandler(BaseCallbackHandler): model_name: str = "" token_cost_process: TokenProcess + encoding: tiktoken.Encoding def __init__(self, model_name, token_cost_process): self.model_name = model_name self.token_cost_process = token_cost_process + try: + self.encoding = tiktoken.encoding_for_model(self.model_name) + except KeyError as e: + self.encoding = tiktoken.get_encoding("cl100k_base") def on_llm_start( self, serialized: Dict[str, Any], prompts: List[str], **kwargs: Any ) -> None: - try: - encoding = tiktoken.encoding_for_model(self.model_name) - except KeyError: - encoding = tiktoken.get_encoding("cl100k_base") - if self.token_cost_process is None: return for prompt in prompts: - self.token_cost_process.sum_prompt_tokens(len(encoding.encode(prompt))) + self.token_cost_process.sum_prompt_tokens(len(self.encoding.encode(prompt))) async def on_llm_new_token(self, token: str, **kwargs) -> None: self.token_cost_process.sum_completion_tokens(1) From f3b3d321e5799153efbf9ba81c73b97f9ed04d3a Mon Sep 17 00:00:00 2001 From: Thiago Moretto Date: Mon, 5 Aug 2024 13:34:03 -0300 Subject: [PATCH 2/3] Fix lint issue --- src/crewai/utilities/token_counter_callback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crewai/utilities/token_counter_callback.py b/src/crewai/utilities/token_counter_callback.py index c5f632d5f..dc0cef71d 100644 --- a/src/crewai/utilities/token_counter_callback.py +++ b/src/crewai/utilities/token_counter_callback.py @@ -17,7 +17,7 @@ class TokenCalcHandler(BaseCallbackHandler): self.token_cost_process = token_cost_process try: self.encoding = tiktoken.encoding_for_model(self.model_name) - except KeyError as e: + except KeyError: self.encoding = tiktoken.get_encoding("cl100k_base") def on_llm_start( From 498e96a419ae34917edae87ae4c0ef01abec0c12 Mon Sep 17 00:00:00 2001 From: Eduardo Chiarotti Date: Tue, 6 Aug 2024 14:47:00 -0300 Subject: [PATCH 3/3] Update issue templates (#1067) * Update issue templates Add both Bug and Feature templates * Update feature_request.md --- .github/ISSUE_TEMPLATE/bug_report.md | 35 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 21 ++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..4ccb3b71a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,35 @@ +--- +name: Bug report +about: Create a report to help us improve CrewAI +title: "[BUG]" +labels: bug +assignees: '' + +--- + +**Description** +Provide a clear and concise description of what the bug is. + +**Steps to Reproduce** +Provide a step-by-step process to reproduce the behavior: + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots/Code snippets** +If applicable, add screenshots or code snippets to help explain your problem. + +**Environment Details:** +- **Operating System**: [e.g., Ubuntu 20.04, macOS Catalina, Windows 10] +- **Python Version**: [e.g., 3.8, 3.9, 3.10] +- **crewAI Version**: [e.g., 0.30.11] +- **crewAI Tools Version**: [e.g., 0.2.6] + +**Logs** +Include relevant logs or error messages if applicable. + +**Possible Solution** +Have a solution in mind? Please suggest it here, or write "None". + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 000000000..c578e8daa --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Suggest a Feature to improve CrewAI +title: "[FEAT]" +labels: feature-request, improvement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] +If possible attach the Issue related to it + +**Describe the solution you'd like / Use-case** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here.