-
Notifications
You must be signed in to change notification settings - Fork 56
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
Conversation
6eba3e1
to
67ee181
Compare
|
||
--- | ||
|
||
## Step 1: Set up a database |
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.
Should their be a "before you begin" step? Are we assuming the user has any tools installed or running a specific environment?
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.
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.
[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`. |
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.
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?
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.
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?
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. |
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.
Would it be better to combine this into a single file users can copy and hack on locally?
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.
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?
```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, |
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.
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.", |
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.
"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.", |
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.
"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.", |
Superseded by #232 |
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>
🧨 Preview deployments removed. |
This quickstart helps users to onboard to toolbox quickly.