Skip to content

Commit

Permalink
Add default for GriptapeCloudEventListenerDriver.api_key
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanholmes committed Jul 16, 2024
1 parent 71a499d commit b97af18
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docs-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
GOOGLE_AUTH_URI: ${{ secrets.INTEG_GOOGLE_AUTH_URI }}
GOOGLE_TOKEN_URI: ${{ secrets.INTEG_GOOGLE_TOKEN_URI }}
GOOGLE_AUTH_PROVIDER_X509_CERT_URL: ${{ secrets.INTEG_GOOGLE_AUTH_PROVIDER_X509_CERT_URL }}
GT_CLOUD_API_KEY: ${{ secrets.INTEG_GRIPTAPE_CLOUD_API_KEY }}
GRIPTAPE_CLOUD_API_KEY: ${{ secrets.INTEG_GRIPTAPE_CLOUD_API_KEY }}
GRIPTAPE_CLOUD_STRUCTURE_ID: ${{ secrets.INTEG_GRIPTAPE_CLOUD_STRUCTURE_ID }}
GRIPTAPE_CLOUD_BASE_URL: ${{ secrets.INTEG_GRIPTAPE_CLOUD_BASE_URL }}
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Native function calling support to `OpenAiChatPromptDriver`, `AzureOpenAiChatPromptDriver`, `AnthropicPromptDriver`, `AmazonBedrockPromptDriver`, `GooglePromptDriver`, and `CoherePromptDriver`.
- `OllamaEmbeddingDriver` for generating embeddings with Ollama.
- `GriptapeCloudKnowledgeBaseVectorStoreDriver` to query Griptape Cloud Knowledge Bases.
- `GriptapeCloudEventListenerDriver.api_key` defaults to the value in the `GT_CLOUD_API_KEY` environment variable.

### Changed
- **BREAKING**: `BaseVectorStoreDriver.upsert_text_artifacts` optional arguments are now keyword-only arguments.
Expand Down
12 changes: 6 additions & 6 deletions docs/griptape-framework/drivers/event-listener-drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ from griptape.drivers import GriptapeCloudEventListenerDriver
from griptape.events import FinishStructureRunEvent
from griptape.artifacts import TextArtifact

event_driver = GriptapeCloudEventListenerDriver(
api_key=os.environ["GRIPTAPE_CLOUD_API_KEY"]
)
# By default, GriptapeCloudEventListenerDriver uses the api key provided
# in the GT_CLOUD_API_KEY environment variable.
event_driver = GriptapeCloudEventListenerDriver()

done_event = FinishStructureRunEvent(
output_task_input=TextArtifact("Just started!"),
Expand Down Expand Up @@ -173,9 +173,9 @@ agent = Agent(
event_listeners=[
EventListener(
event_types=[FinishStructureRunEvent],
driver=GriptapeCloudEventListenerDriver(
api_key=os.environ["GRIPTAPE_CLOUD_API_KEY"],
),
# By default, GriptapeCloudEventListenerDriver uses the api key provided
# in the GT_CLOUD_API_KEY environment variable.
driver=GriptapeCloudEventListenerDriver(),
),
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GriptapeCloudEventListenerDriver(BaseEventListenerDriver):
default=Factory(lambda: os.getenv("GT_CLOUD_BASE_URL", "https://cloud.griptape.ai")),
kw_only=True,
)
api_key: str = field(kw_only=True)
api_key: str = field(default=Factory(lambda: os.getenv("GT_CLOUD_API_KEY")), kw_only=True)
headers: dict = field(
default=Factory(lambda self: {"Authorization": f"Bearer {self.api_key}"}, takes_self=True),
kw_only=True,
Expand Down
2 changes: 1 addition & 1 deletion griptape/tools/calculator/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Calculator(BaseTool):
},
)
def calculate(self, params: dict) -> BaseArtifact:
import numexpr
import numexpr # pyright: ignore[reportMissingImports]

try:
expression = params["values"]["expression"]
Expand Down

0 comments on commit b97af18

Please sign in to comment.