Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Update test deps #233

Merged
merged 9 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/load-query-and-chat-marqo.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
```python
```python title="PYTEST_IGNORE"
import os
from griptape import utils
from griptape.drivers import MarqoVectorStoreDriver
Expand Down
1 change: 1 addition & 0 deletions docs/griptape-framework/drivers/embedding-drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ driver = HuggingFaceHubEmbeddingDriver(
api_token=os.environ["HUGGINGFACE_HUB_ACCESS_TOKEN"],
model="sentence-transformers/all-MiniLM-L6-v2",
tokenizer=HuggingFaceTokenizer(
max_output_tokens=512,
tokenizer=AutoTokenizer.from_pretrained(
"sentence-transformers/all-MiniLM-L6-v2"
)
Expand Down
4 changes: 3 additions & 1 deletion docs/griptape-framework/engines/image-query-engines.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ from griptape.drivers import OpenAiVisionImageQueryDriver
from griptape.engines import ImageQueryEngine
from griptape.loaders import ImageLoader

driver = OpenAiVisionImageQueryDriver()
driver = OpenAiVisionImageQueryDriver(
model="gpt-4-vision-preview",
)

engine = ImageQueryEngine(
image_query_driver=driver,
Expand Down
8 changes: 4 additions & 4 deletions docs/griptape-framework/misc/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ from griptape.events import (
BaseEvent,
StartTaskEvent,
FinishTaskEvent,
StartActionSubtaskEvent,
FinishActionSubtaskEvent,
StartActionsSubtaskEvent,
FinishActionsSubtaskEvent,
StartPromptEvent,
FinishPromptEvent,
EventListener
Expand All @@ -27,8 +27,8 @@ agent = Agent(
EventListener(handler, event_types=[
StartTaskEvent,
FinishTaskEvent,
StartActionSubtaskEvent,
FinishActionSubtaskEvent,
StartActionsSubtaskEvent,
FinishActionsSubtaskEvent,
StartPromptEvent,
FinishPromptEvent
])
Expand Down
48 changes: 29 additions & 19 deletions docs/griptape-framework/misc/tokenizers.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ from griptape.tokenizers import OpenAiTokenizer

tokenizer = OpenAiTokenizer(model="gpt-4")

print(tokenizer.count_tokens("Hello world!")) # 3
print(tokenizer.count_tokens_left("Hello world!")) # 8181
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```

### Cohere
Expand All @@ -30,8 +31,9 @@ tokenizer = CohereTokenizer(
model="command", client=Client(os.environ["COHERE_API_KEY"])
)

print(tokenizer.count_tokens("Hello world!")) # 3
print(tokenizer.count_tokens_left("Hello world!")) # 2045
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```

### Anthropic
Expand All @@ -42,8 +44,9 @@ from griptape.tokenizers import AnthropicTokenizer

tokenizer = AnthropicTokenizer(model="claude-3-opus-20240229")

print(tokenizer.count_tokens("Hello world!")) # 2
print(tokenizer.count_tokens_left("Hello world!")) # 99997
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```

### Hugging Face
Expand All @@ -53,11 +56,13 @@ from griptape.tokenizers import HuggingFaceTokenizer


tokenizer = HuggingFaceTokenizer(
max_output_tokens=512,
tokenizer=AutoTokenizer.from_pretrained("sentence-transformers/all-MiniLM-L6-v2")
)

print(tokenizer.count_tokens("Hello world!")) # 5
print(tokenizer.count_tokens_left("Hello world!")) # 507
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```

### Bedrock
Expand All @@ -69,8 +74,9 @@ from griptape.tokenizers import BedrockClaudeTokenizer

tokenizer = BedrockClaudeTokenizer(model="anthropic.claude-3-sonnet-20240229-v1:0")

print(tokenizer.count_tokens("Hello world!")) # 2
print(tokenizer.count_tokens_left("Hello world!")) # 4094
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```

#### Amazon Titan
Expand All @@ -80,8 +86,9 @@ from griptape.tokenizers import BedrockTitanTokenizer

tokenizer = BedrockTitanTokenizer(model="amazon.titan-text-express-v1")

print(tokenizer.count_tokens("Hello world!")) # 5
print(tokenizer.count_tokens_left("Hello world!")) # 4091
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```

#### Meta Llama 2
Expand All @@ -91,8 +98,9 @@ from griptape.tokenizers import BedrockLlamaTokenizer

tokenizer = BedrockLlamaTokenizer(model="meta.llama2-13b-chat-v1")

print(tokenizer.count_tokens("Hello world!")) # 2
print(tokenizer.count_tokens_left("Hello world!")) # 2046
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```

#### Ai21 Jurassic
Expand All @@ -102,8 +110,9 @@ from griptape.tokenizers import BedrockJurassicTokenizer

tokenizer = BedrockJurassicTokenizer(model="ai21.j2-ultra-v1")

print(tokenizer.count_tokens("Hello world!")) # 3
print(tokenizer.count_tokens_left("Hello world!")) # 8189
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```


Expand All @@ -113,8 +122,9 @@ Not all LLM providers have a public tokenizer API. In this case, you can use the
```python
from griptape.tokenizers import SimpleTokenizer

tokenizer = SimpleTokenizer(max_tokens=1024, characters_per_token=6)
tokenizer = SimpleTokenizer(max_input_tokens=1024, max_output_tokens=1024, characters_per_token=6)

print(tokenizer.count_tokens("Hello world!")) # 2
print(tokenizer.count_tokens_left("Hello world!")) # 1022
print(tokenizer.count_tokens("Hello world!"))
print(tokenizer.count_input_tokens_left("Hello world!"))
print(tokenizer.count_output_tokens_left("Hello world!"))
```
1 change: 1 addition & 0 deletions docs/griptape-framework/structures/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ from griptape.structures import Pipeline

# Create a driver configured to use OpenAI's GPT-4 Vision model.
driver = OpenAiVisionImageQueryDriver(
model="gpt-4-vision-preview",
max_tokens=100,
)

Expand Down
4 changes: 3 additions & 1 deletion docs/griptape-tools/official-tools/image-query-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ from griptape.drivers import OpenAiVisionImageQueryDriver
from griptape.engines import ImageQueryEngine

# Create an Image Query Driver.
driver = OpenAiVisionImageQueryDriver()
driver = OpenAiVisionImageQueryDriver(
model="gpt-4-vision-preview"
)

# Create an Image Query Engine configured to use the driver.
engine = ImageQueryEngine(
Expand Down
791 changes: 578 additions & 213 deletions poetry.lock

Large diffs are not rendered by default.

Loading