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

Need a clean interface to define Triggers, events that auto-run the Assistant #821

Open
andreibondarev opened this issue Oct 11, 2024 · 1 comment
Labels
assistants Related to Langchain::Assistant class enhancement New feature or request thoughtbot-open-summit-2024 https://thoughtbot.com/events/open-summit

Comments

@andreibondarev
Copy link
Collaborator

andreibondarev commented Oct 11, 2024

Description

Currently the Assistant can only be run manually by calling .run on it. We should define a way to trigger it automatically via "triggers". The Assistant can observe a schedule (cron) or state changes.

What should the DSL look like for this?

@andreibondarev andreibondarev added assistants Related to Langchain::Assistant class enhancement New feature or request labels Oct 11, 2024
@andreibondarev andreibondarev added the thoughtbot-open-summit-2024 https://thoughtbot.com/events/open-summit label Oct 24, 2024
@andreibondarev andreibondarev changed the title Need a mechanism to run the Assistant via other method than manually calling ".run" Need a clean interface to define Triggers, events that auto-run the Assistant Oct 24, 2024
@sergiobayona
Copy link
Contributor

For cron jobs, it could be something similar to the whenever gem, like:

llm = Langchain::LLM::OpenAI.new(api_key: ENV["OPENAI_API_KEY"])
assistant = Langchain::Assistant.new(
  llm: llm,
  instructions: "You're a helpful AI assistant",
  tools: [Langchain::Tool::NewsRetriever.new(api_key: ENV["NEWS_API_KEY"])]
)

schedule = Langchain::Scheduler.new

schedule.every :day, at: '12pm' do
  assistant.add_message_and_run content: "What's new in Artificial Intelligence?", auto_tool_execution: true
  puts assistant.messages.last.content
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assistants Related to Langchain::Assistant class enhancement New feature or request thoughtbot-open-summit-2024 https://thoughtbot.com/events/open-summit
Projects
None yet
Development

No branches or pull requests

2 participants