DSPy: The framework for programming—not prompting—language models
Python
Update python_interpreter.py with DSPy's modifications
arnavsinghvi11329bc1b90de1
diff --git a/dspy/primitives/python_interpreter.py b/dspy/primitives/python_interpreter.pyindex 48a97cf6a..c47da27f0 100644--- a/dspy/primitives/python_interpreter.py+++ b/dspy/primitives/python_interpreter.py@@ -47,10 +47,11 @@ class PythonInterpreter():.. highlight:: none- This class is adapted from the hugging face implementation- `python_interpreter.py <https://github.com/huggingface/transformers/blob/8f- 093fb799246f7dd9104ff44728da0c53a9f67a/src/transformers/tools/python_interp- reter.py>`_. The original license applies::+ This class is adapted from the Camel adaptation https://github.com/camel-ai/+ camel/blob/9a9d71874944e9736c55cdaed3df469a8becec05/camel/utils/python_interpreter.py+ which adapts from the hugging face implementation `python_interpreter.py+ <https://github.com/huggingface/transformers/blob/8f093fb799246f7dd9104ff44728da0c53a9f67a+ /src/transformers/tools/python_interpreter.py>`_. The original license applies::Copyright 2023 The HuggingFace Inc. team. All rights reserved.@@ -66,13 +67,20 @@ class PythonInterpreter():implied. See the License for the specific language governingpermissions and limitations under the License.- We have modified the original code to suit our requirements. We have+ Camel's modifications:+ "We have modified the original code to suit our requirements. We haveencapsulated the original functions within a class and saved theinterpreter state after execution. We have added support for "import"statements, "for" statements, and several binary and unary operators. Wehave added import white list to keep `import` statement safe. Additionally,we have modified the variable matching logic and introduced the- :obj:`fuzz_state` for fuzzy matching.+ :obj:`fuzz_state` for fuzzy matching."++ DSPy's modifications:+ "We expanded upon the Camel libraries modifications by adding additional+ support for "Mapping" statements, "conditional" operators, and including+ the "CodePrompt" and "TextPrompt" classes for code execution.+Modifications copyright (C) 2023 CAMEL-AI.org@@ -585,4 +593,4 @@ class CodePrompt(TextPrompt):interpreter = PythonInterpreter(action_space=globals())execution_res = interpreter.execute(self, fuzz_state=user_variable,keep_state=True)- return execution_res, interpreter\ No newline at end of file+ return execution_res, interpreter