Skip to content
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

pass stuff to pre-run-hook #890

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

pass stuff to pre-run-hook #890

wants to merge 1 commit into from

Conversation

zzstoatzz
Copy link
Collaborator

@zzstoatzz zzstoatzz commented Mar 27, 2024

In [1]: from marvin.beta.assistants import Assistant


In [2]:

In [2]: class MyAssistant(Assistant):
   ...:     def pre_run_hook(self, assistant, run, run_kwargs):
   ...:         print(assistant.instructions)
   ...:         print(getattr(assistant, "state", None)) # none for normal assistant
   ...:         print(run_kwargs)
   ...:

In [3]: def add(a: int, b: int) -> int:
   ...:     return a + b
   ...:

In [4]: with MyAssistant(name="mathbot", tools=[add], instructions="add numbers") as ai:
   ...:     ai.say("whats a million + 2312341324?")
   ...:
add numbers
None
{'instructions': 'add numbers', 'tools': [{'type': 'function', 'function': {'name': 'add', 'description': None, 'parameters': {'additionalProperties': False, 'properties': {'a': {'title':
'A', 'type': 'integer'}, 'b': {'title': 'B', 'type': 'integer'}}, 'required': ['a', 'b'], 'type': 'object'}}}], 'model': 'gpt-4-1106-preview'}

@@ -200,7 +200,9 @@ async def run_async(self) -> "Run":
handler = event_handler_class(**self.event_handler_kwargs)

try:
self.assistant.pre_run_hook()
self.assistant.pre_run_hook(
assistant=self.assistant, run=self, run_kwargs=run_kwargs
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah, good point

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant