Skip to content

Commit

Permalink
updated example for chain in vertexai Readme (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
vreyespue authored Mar 14, 2024
1 parent cbb73ab commit 75e6891
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions libs/vertexai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ llm.invoke("Sing a ballad of LangChain.")
```

You can use other models, e.g. `chat-bison`:

```python
from langchain_google_vertexai import ChatVertexAI

Expand Down Expand Up @@ -58,7 +59,6 @@ The value of `image_url` can be any of the following:
- A local file path
- A base64 encoded image (e.g., `data:image/png;base64,abcd124`)


## Embeddings

You can use Google Cloud's embeddings models as:
Expand All @@ -71,24 +71,27 @@ embeddings.embed_query("hello, world!")
```

## LLMs

You can use Google Cloud's generative AI models as Langchain LLMs:

```python
from langchain.prompts import PromptTemplate
from langchain_google_vertexai import VertexAI
from langchain_core.prompts import PromptTemplate
from langchain_google_vertexai import ChatVertexAI

template = """Question: {question}
Answer: Let's think step by step."""
prompt = PromptTemplate.from_template(template)

llm = ChatVertexAI(model_name="gemini-pro")
chain = prompt | llm

question = "Who was the president in the year Justin Beiber was born?"
question = "Who was the president of the USA in 1994?"
print(chain.invoke({"question": question}))
```

You can use Gemini and Palm models, including code-generations ones:

```python
from langchain_google_vertexai import VertexAI

Expand Down

0 comments on commit 75e6891

Please sign in to comment.