Skip to content
Snippets Groups Projects
Unverified Commit b4bd168c authored by Rodrigo Nogueira's avatar Rodrigo Nogueira Committed by GitHub
Browse files

community: fix maritalk notebook links and markdown cell type (#11290)

parent 934d0486
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
<a href="https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/llm/maritalk.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a> <a href="https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/examples/llm/maritalk.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>
# Maritalk # Maritalk
## Introduction ## Introduction
MariTalk is an assistant developed by the Brazilian company [Maritaca AI](www.maritaca.ai). MariTalk is an assistant developed by the Brazilian company [Maritaca AI](https://www.maritaca.ai).
MariTalk is based on language models that have been specially trained to understand Portuguese well. MariTalk is based on language models that have been specially trained to understand Portuguese well.
This notebook demonstrates how to use MariTalk with llama-index through a simple example. This notebook demonstrates how to use MariTalk with llama-index through a simple example.
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Installation ## Installation
If you're opening this Notebook on colab, you will probably need to install LlamaIndex. If you're opening this Notebook on colab, you will probably need to install LlamaIndex.
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
%pip install llama-index-llms-maritalk
!pip install llama-index !pip install llama-index
!pip install llama-index-llms-maritalk
``` ```
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## API Key ## API Key
You will need an API key that can be obtained from chat.maritaca.ai ("Chaves da API" section). You will need an API key that can be obtained from chat.maritaca.ai ("Chaves da API" section).
%% Cell type:markdown id: tags: %% Cell type:markdown id: tags:
## Usage ## Usage
### Chat ### Chat
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
from llama_index.core.llms import ChatMessage from llama_index.core.llms import ChatMessage
from llama_index.llms.maritalk import Maritalk from llama_index.llms.maritalk import Maritalk
# To customize your API key, do this # To customize your API key, do this
# otherwise it will lookup MARITALK_API_KEY from your env variable # otherwise it will lookup MARITALK_API_KEY from your env variable
# llm = Maritalk(api_key="<your_maritalk_api_key>") # llm = Maritalk(api_key="<your_maritalk_api_key>")
llm = Maritalk() llm = Maritalk()
# Call chat with a list of messages # Call chat with a list of messages
messages = [ messages = [
ChatMessage( ChatMessage(
role="system", role="system",
content="You are an assistant specialized in suggesting pet names. Given the animal, you must suggest 4 names.", content="You are an assistant specialized in suggesting pet names. Given the animal, you must suggest 4 names.",
), ),
ChatMessage(role="user", content="I have a dog."), ChatMessage(role="user", content="I have a dog."),
] ]
response = llm.chat(messages) response = llm.chat(messages)
print(response) print(response)
``` ```
%% Cell type:code id: tags: %% Cell type:markdown id: tags:
```
### Few-shot examples ### Few-shot examples
We recommend using the `llm.complete()` method when using the model with few-shot examples We recommend using the `llm.complete()` method when using the model with few-shot examples
```
%% Cell type:code id: tags: %% Cell type:code id: tags:
``` ```
prompt = """Classifique a resenha de filme como "positiva" ou "negativa". prompt = """Classifique a resenha de filme como "positiva" ou "negativa".
Resenha: Gostei muito do filme, é o melhor do ano! Resenha: Gostei muito do filme, é o melhor do ano!
Classe: positiva Classe: positiva
Resenha: O filme deixa muito a desejar. Resenha: O filme deixa muito a desejar.
Classe: negativa Classe: negativa
Resenha: Apesar de longo, valeu o ingresso.. Resenha: Apesar de longo, valeu o ingresso..
Classe:""" Classe:"""
response = llm.complete(prompt, stopping_tokens=["\n"]) response = llm.complete(prompt, stopping_tokens=["\n"])
print(response) print(response)
``` ```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment