Skip to content

Commit

Permalink
Use Anthropic (claude) (#2403)
Browse files Browse the repository at this point in the history
* OPENAI_API_KEY -> ANTHROPIC_API_KEY

* changelog

* ai: rename api key -> anthropic-api-key

* ai: docs

* this, no? (#2473)

---------

Co-authored-by: Taylor Downs <[email protected]>
  • Loading branch information
josephjclark and taylordowns2000 authored Dec 19, 2024
1 parent 6dbf880 commit 9770964
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ and this project adheres to

### Changed

- Added Claude integration in job chat
- OPENAI_API_KEY renamed to AI_ASSISTANT_API_KEY

### Fixed

## [v2.10.8] - 2024-12-18
Expand Down
3 changes: 2 additions & 1 deletion DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ the Apollo AI service.

The following environment variables are required:

- `OPENAI_API_KEY` - your OpenAI API key.
- `AI_ASSISTANT_API_KEY` - API key to use the assistant. This currently requires
an Anthropic key.
- `APOLLO_ENDPOINT` - the endpoint for the OpenFn Apollo AI service.

### Kafka Triggers
Expand Down
2 changes: 1 addition & 1 deletion lib/lightning/ai_assistant/ai_assistant.ex
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ defmodule Lightning.AiAssistant do
@spec enabled?() :: boolean()
def enabled? do
endpoint = Lightning.Config.apollo(:endpoint)
api_key = Lightning.Config.apollo(:openai_api_key)
api_key = Lightning.Config.apollo(:ai_assistant_api_key)

is_binary(endpoint) && is_binary(api_key)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/lightning/apollo_client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defmodule Lightning.ApolloClient do
@spec query(String.t(), context(), list()) :: Tesla.Env.result()
def query(content, context \\ %{}, history \\ []) do
payload = %{
"api_key" => Lightning.Config.apollo(:openai_api_key),
"api_key" => Lightning.Config.apollo(:ai_assistant_api_key),
"content" => content,
"context" => context,
"history" => history
Expand Down
2 changes: 1 addition & 1 deletion lib/lightning/config/bootstrap.ex
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ defmodule Lightning.Config.Bootstrap do
:string,
Utils.get_env([:lightning, :apollo, :endpoint])
),
openai_api_key: env!("OPENAI_API_KEY", :string, nil)
ai_assistant_api_key: env!("AI_ASSISTANT_API_KEY", :string, nil)

config :lightning, Lightning.Runtime.RuntimeManager,
start:
Expand Down
4 changes: 2 additions & 2 deletions test/lightning/ai_assistant/ai_assistant_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defmodule Lightning.AiAssistantTest do
Mox.stub(Lightning.MockConfig, :apollo, fn key ->
case key do
:endpoint -> "http://localhost:3000"
:openai_api_key -> "api_key"
:ai_assistant_api_key -> "api_key"
end
end)

Expand Down Expand Up @@ -73,7 +73,7 @@ defmodule Lightning.AiAssistantTest do
Mox.stub(Lightning.MockConfig, :apollo, fn key ->
case key do
:endpoint -> "http://localhost:3000"
:openai_api_key -> "api_key"
:ai_assistant_api_key -> "api_key"
end
end)

Expand Down
2 changes: 1 addition & 1 deletion test/lightning/apollo_client_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Lightning.ApolloClientTest do
Mox.stub(Lightning.MockConfig, :apollo, fn key ->
case key do
:endpoint -> "http://localhost:3000"
:openai_api_key -> "api_key"
:ai_assistant_api_key -> "api_key"
end
end)

Expand Down
18 changes: 9 additions & 9 deletions test/lightning_web/live/workflow_live/edit_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do
# when not configured properly
Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> nil
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

{:ok, view, _html} =
Expand All @@ -1811,7 +1811,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do
# when configured properly
Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> "http://localhost:4001"
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

{:ok, view, _html} =
Expand All @@ -1836,7 +1836,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do
} do
Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> "http://localhost:4001"
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

# when disclaimer hasn't been read and no session exists
Expand Down Expand Up @@ -1933,7 +1933,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do

Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> apollo_endpoint
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

Mox.stub(
Expand Down Expand Up @@ -2160,7 +2160,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do

Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> apollo_endpoint
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

Mox.stub(
Expand Down Expand Up @@ -2233,7 +2233,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do

Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> apollo_endpoint
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

expected_question = "Can you help me with this?"
Expand Down Expand Up @@ -2314,7 +2314,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do

Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> apollo_endpoint
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

Mox.stub(
Expand Down Expand Up @@ -2366,7 +2366,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do

Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> apollo_endpoint
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

Mox.stub(
Expand Down Expand Up @@ -2416,7 +2416,7 @@ defmodule LightningWeb.WorkflowLive.EditTest do
} do
Mox.stub(Lightning.MockConfig, :apollo, fn
:endpoint -> "http://localhost:4001/health_check"
:openai_api_key -> "openai_api_key"
:ai_assistant_api_key -> "ai_assistant_api_key"
end)

error_message = "You have reached your quota of AI queries"
Expand Down

0 comments on commit 9770964

Please sign in to comment.