Skip to content

Commit

Permalink
updated notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
ohdearquant committed Mar 26, 2024
1 parent 6ffb5c1 commit ef88c96
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 90 deletions.
2 changes: 2 additions & 0 deletions lionagi/core/direct/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from .predict import predict
from .select import select
from .score import score
from .vote import vote

__all__ = [
"predict",
"select",
"score",
"vote"
]
6 changes: 2 additions & 4 deletions lionagi/core/direct/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def __init__(
self,
sentence=None,
choices=None,
num_choices=1,
instruction=None,
reason=False,
confidence_score=False,
Expand All @@ -27,7 +26,7 @@ def __init__(

self.sentence = sentence
self.choices = choices
self.task = f"select {num_choices} item(s), from provided choices {choices}."
self.task = f"select 1 item, from provided choices {choices}."
if instruction:
self.task += f"objetive {instruction}."

Expand All @@ -41,7 +40,6 @@ def __init__(
async def select(
sentence,
choices=None,
num_choices=1,
instruction=None,
confidence_score=False,
reason=False,
Expand Down Expand Up @@ -79,7 +77,6 @@ async def select(
_template = SelectTemplate(
sentence=sentence,
choices=choices,
num_choices=num_choices,
instruction=instruction,
confidence_score=confidence_score,
reason=reason,
Expand All @@ -97,6 +94,7 @@ async def select(
)

ans = _template.answer

if ans not in _template.choices:
_template.answer = StringMatch.choose_most_similar(ans, _template.choices)

Expand Down
3 changes: 2 additions & 1 deletion lionagi/core/direct/vote.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from lionagi.libs import func_call
import numpy as np
from .predict import predict
from .score import score

# for example, directive=predict

async def vote(sentence, directive, num_generations=5, num_output=1, num_scorer=5, score_range=(0,100), num_digit=2, scorer_instruction=None, **kwargs):
async def vote(sentence, directive=predict, num_generations=5, num_output=1, num_scorer=5, score_range=(0,100), num_digit=2, scorer_instruction=None, **kwargs):

async def _inner(i):
out_ = await directive(sentence, **kwargs)
Expand Down
Loading

0 comments on commit ef88c96

Please sign in to comment.