Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cog 970 refactor tokenizing #468
Cog 970 refactor tokenizing #468
Changes from all commits
93249c7
294ed1d
b686376
b25a82e
1319944
6d5679f
7dea1d5
844d99c
902979c
77a7285
0a9f134
49f6097
3db7f85
b6e21ea
4154436
e0b7be7
dc0450d
4e56cd6
3e29c3d
6f8cbdb
710ca78
a8644e0
8602186
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use configured max_tokens instead of hardcoded value
The constructor accepts
max_tokens
but theacreate_structured_output
method uses a hardcoded value of 4096.Apply this diff to use the configured value:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
🛠️ Refactor suggestion
Confirmed: max_tokens parameter not utilized in API calls
The
max_tokens
parameter is added to the constructor but not used in theacreate_structured_output
method across all LLM adapters. This leads to inconsistent token limits:Apply this fix to utilize the max_tokens parameter consistently:
async def acreate_structured_output( self, text_input: str, system_prompt: str, response_model: Type[BaseModel] ) -> BaseModel: """Generate a response from a user query.""" return await self.aclient.chat.completions.create( model=self.model, + max_tokens=self.max_tokens, messages=[ { "role": "user",
🔗 Analysis chain
Utilize max_tokens parameter in API calls
The
max_tokens
parameter is added to the constructor but not used in theacreate_structured_output
method. This could lead to inconsistent token limits.Apply this diff to utilize the max_tokens parameter:
async def acreate_structured_output( self, text_input: str, system_prompt: str, response_model: Type[BaseModel] ) -> BaseModel: """Generate a response from a user query.""" return await self.aclient.chat.completions.create( model=self.model, + max_tokens=self.max_tokens, messages=[ { "role": "user",
🏁 Scripts executed
The following scripts were executed for the analysis:
Error: No shell scripts found
Script:
Length of output: 10481
Script:
Length of output: 9076
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for configuration retrieval and API setup.
The configuration retrieval and API setup lack error handling. Consider adding try-catch blocks to handle potential configuration errors gracefully.
📝 Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for token counting.
The
count_tokens
method should handle potential API errors and validate inputs.📝 Committable suggestion