patched-codes / patchwork

Automate code reviews, patching and documentation with self-hosted LLM workflows.
https://patched.codes
GNU Affero General Public License v3.0
965 stars 59 forks source link

Simplified LLM step #332

Closed CTY-git closed 3 months ago

patched-admin commented 3 months ago
The code changes involve removing unnecessary import statements for `hashlib` and `uuid`, updating type annotations from `Annotated[str, IS_CONFIG]` to just `str`, simplifying type hinting using `str` instead of `Annotated`, changing data types from string to dictionary, adding new classes and methods, importing and utilizing various modules for specific functionalities, updating the project version, and adding test functions to test the behavior of specific classes with different input configurations. Additionally, unnecessary parentheses around import statements are removed in some test files. ------
* File changed: [patchwork/common/client/patched.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-0998e5a615567a2c44e0de84a938c4d225e27ae97018e06f32775aa08db9a091) [The diff in the patched.py file removes two import statements related to hashlib and uuid libraries.](https://github.com/patched-codes/patchwork/pull/332/files#diff-0998e5a615567a2c44e0de84a938c4d225e27ae97018e06f32775aa08db9a091)
* File changed: [patchwork/common/utils/utils.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-f3466dc43f091cee836042d9954f12a719cf38d5ede82bd0ad66fd68095f0ab3) [The diff in `utils.py` removes unnecessary import statements for `hashlib` and `uuid`, while adding a new function `exclude_none_dict()` that filters out keys with a `None` value from a dictionary.](https://github.com/patched-codes/patchwork/pull/332/files#diff-f3466dc43f091cee836042d9954f12a719cf38d5ede82bd0ad66fd68095f0ab3)
* File changed: [patchwork/steps/CreateIssue/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-420cbe90b0d0a1c1c583967e9f3126742b24adb5c55b183f3b68701266268ce8) [In the file `typed.py` in the `CreateIssue` module of the `patchwork` project, the type of `issue_text` has been changed from `Annotated[str, IS_CONFIG]` to just `str`.](https://github.com/patched-codes/patchwork/pull/332/files#diff-420cbe90b0d0a1c1c583967e9f3126742b24adb5c55b183f3b68701266268ce8)
* File changed: [patchwork/steps/CreateIssueComment/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-bfa35e5abf689e4b59cf8df582fc552001dfee6b1a3524ccd155b5ebcfde734a) [In the file typed.py within the CreateIssueComment module, the type annotation for the issue_text attribute in the __CreateIssueCommentRequiredInputs class has been changed from Annotated[str, IS_CONFIG] to just str.](https://github.com/patched-codes/patchwork/pull/332/files#diff-bfa35e5abf689e4b59cf8df582fc552001dfee6b1a3524ccd155b5ebcfde734a)
* File changed: [patchwork/steps/ExtractCodeContexts/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-d8eecbb3f8fa7ec847484357e85e0804faa3f570bc6c1f336a9735a7e31649ba) [In the file typed.py within the ExtractCodeContexts module, the data type annotation for the base_path attribute in the ExtractCodeContextsInputs class has been changed from Annotated[str, IS_CONFIG] to just str.](https://github.com/patched-codes/patchwork/pull/332/files#diff-d8eecbb3f8fa7ec847484357e85e0804faa3f570bc6c1f336a9735a7e31649ba)
* File changed: [patchwork/steps/ExtractCodeMethodForCommentContexts/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-578219c0a72cc57e3d957bde0d2116b8758726b9874566a3fef6dce00ccb0eae) [The import statements for "Annotated" and "IS_CONFIG" types from typing_extensions have been removed, and the usage of "Annotated" for type hinting in the class attributes has been simplified to just using "str" in the ExtractCodeMethodForCommentContexts class in the typed.py file.](https://github.com/patched-codes/patchwork/pull/332/files#diff-578219c0a72cc57e3d957bde0d2116b8758726b9874566a3fef6dce00ccb0eae)
* File changed: [patchwork/steps/ExtractPackageManagerFile/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-89d8ddc4136c84ccac973b18c0c0108bd4fbbf556228028afcc035aea050c02f) [The import statement for `Iterable` was removed from the code, and the `Annotated` type hint was removed from the `sbom_vdr_values` attribute while the `files_to_patch` attribute was updated to use `list` instead of `Iterable`.](https://github.com/patched-codes/patchwork/pull/332/files#diff-89d8ddc4136c84ccac973b18c0c0108bd4fbbf556228028afcc035aea050c02f)
* File changed: [patchwork/steps/LLM/LLM.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-62bc493f205830a467a8debcf3544ed237d317db71d88cc288e4f70e23f07af8) [The code in LLM.py has been modified to remove the reference to LLMInputs as a class attribute by using a static method in LLMInputs instead. Additionally, the return statement in the run method has been updated to use a utility function called exclude_none_dict to filter out None values from the dictionary being returned.](https://github.com/patched-codes/patchwork/pull/332/files#diff-62bc493f205830a467a8debcf3544ed237d317db71d88cc288e4f70e23f07af8)
* File changed: [patchwork/steps/PR/PR.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-3170c8da7925b4e4d70e399d5f31d29beeda75c57ca1b7a330b3865a0351748e) [A new import statement from the `exclude_none_dict` function is added from the `utils.py` module. The `return` statement now utilizes this imported function to ensure any `None` values are excluded from the dictionary before the method returns the output.](https://github.com/patched-codes/patchwork/pull/332/files#diff-3170c8da7925b4e4d70e399d5f31d29beeda75c57ca1b7a330b3865a0351748e)
* File changed: [patchwork/steps/QueryEmbeddings/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-c3e145f6838c6c2978161f27ad80cefeb64c9a35d3e484fc2cb02f8150433e36) [The diff involves changing the data type annotation for the "embedding_name" attribute in the "__QueryEmbeddingsRequiredInputs" class from Annotated[str, IS_CONFIG] to just str.](https://github.com/patched-codes/patchwork/pull/332/files#diff-c3e145f6838c6c2978161f27ad80cefeb64c9a35d3e484fc2cb02f8150433e36)
* File changed: [patchwork/steps/ScanDepscan/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-a2edab78802b1fffb21854873bbf007b13225bacceb2f0e1e033008f68233fe1) [The data type of the attribute "sbom_vdr_values" in the class "ScanDepscanOutputs" has been changed from a string to a dictionary in the file typed.py in the ScanDepscan directory.](https://github.com/patched-codes/patchwork/pull/332/files#diff-a2edab78802b1fffb21854873bbf007b13225bacceb2f0e1e033008f68233fe1)
* File changed: [patchwork/steps/SimplifiedLLM/SimplifiedLLM.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-f73ff142d98861fb66a6eebbfcfc772506c4ea9fe26336704a4135bd7c57e2b3) [This diff adds a new Python script `SimplifiedLLM.py` which includes a class `SimplifiedLLM` that extends a `Step` class. The `SimplifiedLLM` class includes methods for initializing data, running operations, and returning cleaned up output data through JSON loading and excluding None values. Various other modules like `CallLLM`, `PreparePrompt`, and `ExtractModelResponse` are imported and utilized within the class for specific functionalities.](https://github.com/patched-codes/patchwork/pull/332/files#diff-f73ff142d98861fb66a6eebbfcfc772506c4ea9fe26336704a4135bd7c57e2b3)
* File changed: [patchwork/steps/SimplifiedLLM/__init__.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-907e7274210c032ae5174da1ab13c1c9221bbd10b0a24c69ff2ce6b6af52f8e7) [There were no changes made to the file __init__.py in the SimplifiedLLM module under the patchwork/steps directory.](https://github.com/patched-codes/patchwork/pull/332/files#diff-907e7274210c032ae5174da1ab13c1c9221bbd10b0a24c69ff2ce6b6af52f8e7)
* File changed: [patchwork/steps/SimplifiedLLM/typed.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-ca05591855b1036af9bdaed433da4d2dace8917d6716106564b70d0679635f7a) [This patch adds new typed classes in the "SimplifiedLLM" module related to inputs and outputs for a process. It includes definitions for inputs like prompt values and outputs like extracted responses, utilizing annotations and typing extensions for configuration settings.](https://github.com/patched-codes/patchwork/pull/332/files#diff-ca05591855b1036af9bdaed433da4d2dace8917d6716106564b70d0679635f7a)
* File changed: [patchwork/steps/__init__.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-f31de71df95e57998018a4108a0780a90d8e790683810803959e17e72412f513) [This diff in the `__init__.py` file of the `patchwork/steps` directory adds imports and includes new steps such as `CreateIssue`, `ExtractCodeContexts`, `ExtractCodeMethodForCommentContexts`, and `SimplifiedLLM`. Additionally, `CallAPI` and `PR` are also added to the list of available steps in the module.](https://github.com/patched-codes/patchwork/pull/332/files#diff-f31de71df95e57998018a4108a0780a90d8e790683810803959e17e72412f513)
* File changed: [pyproject.toml](https://github.com/patched-codes/patchwork/pull/332/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711) [The version of the project in the `pyproject.toml` file has been updated from 0.0.25 to 0.0.26.](https://github.com/patched-codes/patchwork/pull/332/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711)
* File changed: [tests/steps/test_CallAPI.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-c46e9dd1f6b159f8daf0772e63a5d40b86750e6a29788db3d13720150e653df1) [The diff in the test_CallAPI.py file involves removing unnecessary parentheses around the import of CallAPI from the CallAPI module under patchwork.steps.CallAPI.](https://github.com/patched-codes/patchwork/pull/332/files#diff-c46e9dd1f6b159f8daf0772e63a5d40b86750e6a29788db3d13720150e653df1)
* File changed: [tests/steps/test_SimplifiedLLM.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-a0332adbca7e2e3aed15dc96dbdb749075aa22f79c91838136274cb356d48a62) [This diff file adds test functions to test the behavior of the SimplifiedLLM class with different input configurations, including testing for invalid input values, non-JSON and JSON run configurations. The tests verify specific method calls and inputs on mocked objects related to preparing prompts, calling the LLM model, and extracting model responses within the SimplifiedLLM class.](https://github.com/patched-codes/patchwork/pull/332/files#diff-a0332adbca7e2e3aed15dc96dbdb749075aa22f79c91838136274cb356d48a62)
* File changed: [tests/steps/test_SlackMessage.py](https://github.com/patched-codes/patchwork/pull/332/files#diff-8376b3ee47dbdcae872a4909cd5e0ccc522619f02339f1ed77d0591f7363c88b) [The diff in the "test_SlackMessage.py" file involves removing unnecessary parentheses around the import statement for the "SlackMessage" class from the "SlackMessage.py" module.](https://github.com/patched-codes/patchwork/pull/332/files#diff-8376b3ee47dbdcae872a4909cd5e0ccc522619f02339f1ed77d0591f7363c88b)