-
-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Parallel Function Calls with List[Union[T]]
#378
Conversation
List[Union[T]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes requested.
Something look wrong? You can customize Ellipsis by editing the ellipsis.yaml for this repository.
Generated with ❤️ by ellipsis.dev
instructor/dsl/parallel.py
Outdated
#! We expect this from the OpenAISchema class, We should address | ||
#! this with a protocol or an abstract class... @jxnlco | ||
assert mode == Mode.PARALLEL_TOOLS, "Mode must be PARALLEL_TOOLS" | ||
print(response.choices[0].message) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a print statement on line 24 which seems to be for debugging purposes. It's a good practice to remove such statements before merging the code to the main branch.
print(response.choices[0].message) | |
# print(response.choices[0].message) |
Would a change from Iterable[Union[…]] to tuple[…] or even just (…) be to your liking aesthetically? Happy to figure out the implementation and update this PR if you’re aligned |
its not a tuple. its |
I agree that that's the correct type, I'm updating my suggestion to passing a list of |
we're going to use generics to reflect the type to the response. resp: [T1, T2, T3] = create(response_model=[T1, T2, T3]) is not a thing |
Summary:
This PR introduces parallel function calls using a list of union types, modifies the instructor's patching mechanism to handle these calls, and includes tests for the new functionality.
Key points:
PARALLEL_TOOLS
toMode
enum ininstructor/function_calls.py
.ParallelBase
class ininstructor/dsl/parallel.py
to handle parallel function calls.instructor/patch.py
to handlePARALLEL_TOOLS
mode and useParallelBase
for response processing.tests/openai/test_parallel.py
.examples/patching/pcalls.py
.Generated with ❤️ by ellipsis.dev