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

Use permchain agent executor, Streaming, API docs #45

Merged
merged 34 commits into from
Nov 20, 2023
Merged

Conversation

nfcampos
Copy link
Contributor

@nfcampos nfcampos commented Nov 14, 2023

  • Figure out streaming output

@jthack
Copy link

jthack commented Nov 14, 2023

if yall get streaming, people will use this over Assistants imo

Copy link
Contributor

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

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

High picture all makes sense. some questions about apects of permchain i don't know :)

backend/packages/gizmo-agent/gizmo_agent/main.py Outdated Show resolved Hide resolved
def _create_function_message(
agent_action: AgentAction, observation: str
) -> FunctionMessage:
if not isinstance(observation, str):
Copy link
Contributor

Choose a reason for hiding this comment

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

can't see from current code but when is observation not str? maybe update type signature?

Copy link
Contributor

Choose a reason for hiding this comment

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

its often not (sadly)

type hints need updating

# TODO if this is last step, return stop message instead
return tool_chain
elif isinstance(message.additional_kwargs.get("agent"), AgentFinish):
return RunnablePassthrough()
Copy link
Contributor

Choose a reason for hiding this comment

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

Confirming -- this stops execution because there was no value update? How does it check for updates under the hood? Does it compare serialized representations? Is RunnablePassthrough() special?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It stops execution because it doesn't write to any channel (execution continues only when channels are written to)


def get_agent_executor(
tools: list[BaseTool],
agent: Runnable[dict[str, list[AnyMessage]], AgentAction | AgentFinish],
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm at some point we could add another executor to support also agents that return a list of AnyMessage (will help remove the boiler plate for working with something like openai directly)

@@ -33,7 +33,6 @@
[
("system", template),
MessagesPlaceholder(variable_name="messages"),
("ai", "{agent_scratchpad}"),
]
Copy link
Contributor

Choose a reason for hiding this comment

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

yay

channels={"messages": Topic(AnyMessage, accumulate=True)},
input=["messages"],
output=["messages"],
checkpoint=checkpoint,
Copy link
Contributor

Choose a reason for hiding this comment

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

When are values written to the checkpoint? And what is the content of checkpoint? Is a checkpoint taking place after each update iteration is completed? Is the content of checkpoint all the messages so far or just the new messages? (Seems like the former)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check the implementation in permchain, we have a choice of values being written to checkpoint storage either at the end of each step, or once at the end of the run. By default is end of each step

else:
return AIMessage(
content=output.return_values["output"],
additional_kwargs={"agent": output},
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens to these kwargs when we send them to the llm? do they get stripped out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our ChatModels dont use additional kwargs they dont know about


return Pregel(
chains={"executor": executor},
channels={"messages": Topic(AnyMessage, accumulate=True)},
Copy link
Contributor

Choose a reason for hiding this comment

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

How does accumulation work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nfcampos nfcampos marked this pull request as ready for review November 20, 2023 11:38
@nfcampos nfcampos changed the title WIP Use permchain agent executor Use permchain agent executor, Streaming, API docs Nov 20, 2023
@nfcampos nfcampos merged commit 94f7fee into main Nov 20, 2023
7 checks passed
@nfcampos nfcampos deleted the nc/permchain branch November 20, 2023 16:17
@nfcampos nfcampos mentioned this pull request Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants