From ad59934376586ca0a0fc354cf96a5c760f33f5ef Mon Sep 17 00:00:00 2001 From: Daiyi Peng Date: Tue, 26 Sep 2023 20:02:15 -0700 Subject: [PATCH] Rename 'structured/query.py' to 'structured/prompting.py' to avoid name conflict. PiperOrigin-RevId: 568720314 --- langfun/core/structured/__init__.py | 10 ++++---- .../structured/{query.py => prompting.py} | 0 .../{query_test.py => prompting_test.py} | 24 +++++++++---------- 3 files changed, 16 insertions(+), 18 deletions(-) rename langfun/core/structured/{query.py => prompting.py} (100%) rename langfun/core/structured/{query_test.py => prompting_test.py} (95%) diff --git a/langfun/core/structured/__init__.py b/langfun/core/structured/__init__.py index d64cd0e..c6d66e5 100644 --- a/langfun/core/structured/__init__.py +++ b/langfun/core/structured/__init__.py @@ -55,12 +55,10 @@ from langfun.core.structured.parsing import ParseStructurePython from langfun.core.structured.parsing import parse -import langfun.core.structured.query as query_lib - -from langfun.core.structured.query import QueryStructure -from langfun.core.structured.query import QueryStructureJson -from langfun.core.structured.query import QueryStructurePython -from langfun.core.structured.query import query +from langfun.core.structured.prompting import QueryStructure +from langfun.core.structured.prompting import QueryStructureJson +from langfun.core.structured.prompting import QueryStructurePython +from langfun.core.structured.prompting import query from langfun.core.structured.description import DescribeStructure from langfun.core.structured.description import describe diff --git a/langfun/core/structured/query.py b/langfun/core/structured/prompting.py similarity index 100% rename from langfun/core/structured/query.py rename to langfun/core/structured/prompting.py diff --git a/langfun/core/structured/query_test.py b/langfun/core/structured/prompting_test.py similarity index 95% rename from langfun/core/structured/query_test.py rename to langfun/core/structured/prompting_test.py index 2a4c4f0..4058df7 100644 --- a/langfun/core/structured/query_test.py +++ b/langfun/core/structured/prompting_test.py @@ -11,7 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""Tests for structured query_lib.""" +"""Tests for structured prompting.""" import inspect import unittest @@ -19,7 +19,7 @@ import langfun.core as lf from langfun.core.llms import fake from langfun.core.structured import mapping -from langfun.core.structured import query as query_lib +from langfun.core.structured import prompting import pyglove as pg @@ -37,7 +37,7 @@ class Itinerary(pg.Object): class QueryStructurePythonTest(unittest.TestCase): def test_render_no_examples(self): - l = query_lib.QueryStructurePython(int) + l = prompting.QueryStructurePython(int) m = lf.AIMessage('Compute 12 / 6 + 2.') self.assertEqual( @@ -56,7 +56,7 @@ def test_render_no_examples(self): ) def test_render(self): - l = query_lib.QueryStructurePython( + l = prompting.QueryStructurePython( int, examples=[ mapping.MappingExample('What is the answer of 1 plus 1?', None, 2), @@ -145,7 +145,7 @@ def test_transform(self): ), override_attrs=True, ): - l = query_lib.QueryStructurePython( + l = prompting.QueryStructurePython( [Itinerary], examples=[ mapping.MappingExample( @@ -181,17 +181,17 @@ def test_bad_transform(self): mapping.MappingError, 'Cannot parse message text into structured output', ): - query_lib.query('Compute 1 + 2', int) + prompting.query('Compute 1 + 2', int) def test_query(self): lm = fake.StaticSequence(['1']) - self.assertEqual(query_lib.query('what is 1 + 0', int, lm=lm), 1) + self.assertEqual(prompting.query('what is 1 + 0', int, lm=lm), 1) class QueryStructureJsonTest(unittest.TestCase): def test_render_no_examples(self): - l = query_lib.QueryStructureJson(int) + l = prompting.QueryStructureJson(int) m = lf.AIMessage('Compute 12 / 6 + 2.') self.assertEqual( @@ -214,7 +214,7 @@ def test_render_no_examples(self): ) def test_render(self): - l = query_lib.QueryStructureJson( + l = prompting.QueryStructureJson( int, examples=[ mapping.MappingExample('What is the answer of 1 plus 1?', None, 2), @@ -341,7 +341,7 @@ def test_transform(self): ), override_attrs=True, ): - l = query_lib.QueryStructureJson( + l = prompting.QueryStructureJson( [Itinerary], examples=[ mapping.MappingExample( @@ -377,12 +377,12 @@ def test_bad_transform(self): mapping.MappingError, 'Cannot parse message text into structured output', ): - query_lib.query('Compute 1 + 2', int, protocol='json') + prompting.query('Compute 1 + 2', int, protocol='json') def test_query(self): lm = fake.StaticSequence(['{"result": 1}']) self.assertEqual( - query_lib.query('what is 1 + 0', int, lm=lm, protocol='json'), 1 + prompting.query('what is 1 + 0', int, lm=lm, protocol='json'), 1 )