Skip to content

Commit

Permalink
Rename 'structured/query.py' to 'structured/prompting.py' to avoid na…
Browse files Browse the repository at this point in the history
…me conflict.

PiperOrigin-RevId: 568718503
  • Loading branch information
daiyip authored and langfun authors committed Sep 27, 2023
1 parent fc22207 commit 61b8727
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
10 changes: 4 additions & 6 deletions langfun/core/structured/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
# 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

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


Expand All @@ -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(
Expand All @@ -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),
Expand Down Expand Up @@ -145,7 +145,7 @@ def test_transform(self):
),
override_attrs=True,
):
l = query_lib.QueryStructurePython(
l = prompting.QueryStructurePython(
[Itinerary],
examples=[
mapping.MappingExample(
Expand Down Expand Up @@ -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(
Expand All @@ -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),
Expand Down Expand Up @@ -341,7 +341,7 @@ def test_transform(self):
),
override_attrs=True,
):
l = query_lib.QueryStructureJson(
l = prompting.QueryStructureJson(
[Itinerary],
examples=[
mapping.MappingExample(
Expand Down Expand Up @@ -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
)


Expand Down

0 comments on commit 61b8727

Please sign in to comment.