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

docs: add local quickstart #218

Closed
wants to merge 18 commits into from
Closed

docs: add local quickstart #218

wants to merge 18 commits into from

Conversation

twishabansal
Copy link
Contributor

This quickstart helps users to onboard to toolbox quickly.

Copy link
Contributor

@twishabansal twishabansal marked this pull request as ready for review January 16, 2025 08:52
@twishabansal twishabansal requested a review from a team as a code owner January 16, 2025 08:52
Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor


---

## Step 1: Set up a database
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should their be a "before you begin" step? Are we assuming the user has any tools installed or running a specific environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now, we're not assuming anything about the user environment, except that they have python installed.
We're going over the whole process from scratch.

Comment on lines 11 to 15
[Install postgres and configure a
database](https://neon.tech/postgresql/postgresql-getting-started) for your
system.

This process creates a database `postgres` with superuser `postgres`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like to see if we can capture this set up ourselves, without requiring the user to go to a new page. I think using docker might also be useful in streamlining?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case, can we assume basic familiarity with docker and have docker installation as a prerequisite?
Do you think the friction of docker installation is worth ignoring?

Comment on lines 206 to 254
1. Create a LangGraph [ReAct
agent](https://langchain-ai.github.io/langgraph/reference/prebuilt/#langgraph.prebuilt.chat_agent_executor.create_react_agent).

```python
from langgraph.prebuilt import create_react_agent
from langchain_google_vertexai import ChatVertexAI
from langgraph.checkpoint.memory import MemorySaver

model = ChatVertexAI(model_name="gemini-pro", project="my-project") # Change the GCP project here
agent = create_react_agent(model, tools, checkpointer=MemorySaver())
```

1. Define the initial prompt and user queries.

```python
prompt = """
You're a helpful hotel assistant. You handle hotel searching, booking and
cancellations. When the user searches for a hotel, mention it's name, id,
location and price tier. Always mention hotel ids while performing any
searches. This is very important for any operations. For any bookings or
cancellations, please provide the appropriate confirmation.
Don't ask for confirmations from the user.
"""

queries = [
"Find hotels in Basel with Basel in it's name.",
"Can you book the Hilton Basel for me?",
"Oh wait, this is too expensive. Please cancel it and book the Hyatt Regency instead.",
"My check in dates would be from April 10, 2024 to April 19, 2024.",
]
```

1. Run the queries and observe the output!

```python
config = {"configurable": {"thread_id": "thread-1"}}

for query in queries:
inputs = {"messages": [("user", prompt + query)]}
response = await agent.ainvoke(inputs, stream_mode="values", config=config)
print(response["messages"][-1].content)
```

To verify the agent's actions, you can examine the hotels table. You should
observe that the `booked` column for the `Hyatt Regency Basel` has changed
from `0` to `1`, indicating that the hotel has been successfully booked.
Additionally, the `checkin_date` and `checkout_date` have been updated to
`2024-04-10` and `2024-04-19` from `2024-04-02` and `2024-04-20`
respectively.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be better to combine this into a single file users can copy and hack on locally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This structure could help users understand and customize the steps involved.
However, we could upload the code and YAML files into the github repo and add a link for users to access them.

We could add a note at the beginning, like:

The code and configuration files used in this quickstart are available [here](link_to_files).

What do you think?

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

Copy link
Contributor

@kurtisvg kurtisvg changed the title docs: added a quickstart for toolbox docs: add local quickstart Jan 17, 2025
```python
prompt = """
You're a helpful hotel assistant. You handle hotel searching, booking and
cancellations. When the user searches for a hotel, mention it's name, id,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cancellations. When the user searches for a hotel, mention it's name, id,
cancellations. When the user searches for a hotel, mention its name, id,

"""

queries = [
"Find hotels in Basel with Basel in it's name.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Find hotels in Basel with Basel in it's name.",
"Find hotels in Basel with Basel in its name.",

"Find hotels in Basel with Basel in it's name.",
"Can you book the Hilton Basel for me?",
"Oh wait, this is too expensive. Please cancel it and book the Hyatt Regency instead.",
"My check in dates would be from April 10, 2024 to April 19, 2024.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"My check in dates would be from April 10, 2024 to April 19, 2024.",
"My check-in dates would be from April 10, 2024 to April 19, 2024.",

@kurtisvg
Copy link
Collaborator

Superseded by #232

kurtisvg added a commit that referenced this pull request Jan 24, 2025
This is a continuation of #218, which add a local quickstart for running
Toolbox with Python and LangGraph.

---------

Co-authored-by: Twisha Bansal <twishabansal@google.com>
Co-authored-by: Anubhav Dhawan <anubhav756@gmail.com>
Copy link
Contributor

🧨 Preview deployments removed.

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.

3 participants