Open jacksonhu opened 11 months ago
Hey @jacksonhu, this is the old guidance handlebars syntax that isn't supported in the new version of the library (v0.1+
). We're currently maintaining the more pythonic version of the codebase. Your best bet is to run examples from our README -- in your case, here: https://github.com/guidance-ai/guidance#guidance-acceleration
Make sure you initialize new models in the new format too: https://github.com/guidance-ai/guidance#openai
I feel new syntax is making it little harder to incorporate guidance into things like autogen. I'm having a hard time mixing, or even visualizing, the two together... and both are Microsoft products :(
at least up to this point in time, I felt guidance could've been the hope and gap-filler for open source LLMs. I mean openai handles things well and majority of examples are and builds on it. But once you move away from it, not only there are less resource but open LLMs have a functional gap that makes using any agent framework less useful. or at least I'm having trouble making it useful...
@Harsha-Nori how would i create 3 different characters? below is only producing the same thing 3 times with only the id being different: @guidance def character_maker(lm, id, description, valid_weapons): lm += f"""\ The following is a character profile for an RPG game in JSON format.
{{
"id": "{id}",
"description": "{description}",
"name": "{gen('name', stop='"')}",
"age": {gen('age', regex='[0-9]+', stop=',')},
"armor": "{select(options=['leather', 'chainmail', 'plate'], name='armor')}",
"weapon": "{select(options=valid_weapons, name='weapon')}",
"class": "{gen('class', stop='"')}",
"mantra": "{gen('mantra', stop='"')}",
"strength": {gen('strength', regex='[0-9]+', stop=',')},
"items": ["{gen('item', list_append=True, stop='"')}", "{gen('item', list_append=True, stop='"')}", "{gen('item', list_append=True, stop='"')}"]
}}```"""
return lm
for x in range(3):
llama2 += character_maker(x, 'A nimble fighter', ['axe', 'sword', 'bow'])
print(llama2)
my code is below:
and I got error : Traceback (most recent call last): File "/Users/loganhu/Documents/eclipse_workspace/ai4dataops/py-server/ai4dataops/guidance/Test2.py", line 21, in
character_maker = guidance("""The following is a character profile for an RPG game in JSON format.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/loganhu/Documents/eclipse_workspace/ai4dataops/py-server/venv/lib/python3.11/site-packages/guidance-0.1.7-py3.11-macosx-12-x86_64.egg/guidance/init.py", line 25, in call
return _decorator(f, stateless=stateless, cache=cache, dedent=dedent, model=model)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/loganhu/Documents/eclipse_workspace/ai4dataops/py-server/venv/lib/python3.11/site-packages/guidance-0.1.7-py3.11-macosx-12-x86_64.egg/guidance/init.py", line 43, in _decorator
f = strip_multiline_string_indents(f)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/loganhu/Documents/eclipse_workspace/ai4dataops/py-server/venv/lib/python3.11/site-packages/guidance-0.1.7-py3.11-macosx-12-x86_64.egg/guidance/_utils.py", line 75, in strip_multiline_string_indents
source = textwrap.dedent(inspect.getsource(f))
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1262, in getsource
lines, lnum = getsourcelines(object)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1244, in getsourcelines
lines, lnum = findsource(object)
^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 1063, in findsource
file = getsourcefile(object)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 940, in getsourcefile
filename = getfile(object)
^^^^^^^^^^^^^^^
File "/Users/loganhu/Documents/eclipse_workspace/ai4dataops/py-server/venv/lib/python3.11/site-packages/torch/package/package_importer.py", line 696, in _patched_getfile
return _orig_getfile(object)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py", line 920, in getfile
raise TypeError('module, class, method, function, traceback, frame, or '
TypeError: module, class, method, function, traceback, frame, or code object was expected, got str
guidance version 0.1.7 openai sdk version is 1.3.8 how could I fix this problem?