Skip to content

Commit bc3b549

Browse files
committed
Optionally record logs
1 parent 4f5a3cf commit bc3b549

File tree

5 files changed

+72
-11
lines changed

5 files changed

+72
-11
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"immer": "^9.0.21",
3030
"lodash": "^4.17.21",
3131
"openai": "^4.78.1",
32+
"openpipe": "^0.43.0",
3233
"prettier": "^2.8.4",
3334
"react": "^18.2.0",
3435
"react-dom": "^18.2.0",

src/common/SetAPIKey.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const ModelDropdown = () => {
88
}));
99

1010
const [openAIKey, setOpenAIKey] = React.useState('');
11+
const [openPipeKey, setOpenPipeKey] = React.useState('');
1112
const [showPassword, setShowPassword] = React.useState(false);
1213

1314
return (
@@ -42,13 +43,27 @@ const ModelDropdown = () => {
4243
{showPassword ? 'Hide' : 'Show'}
4344
</Button>
4445
</HStack>
46+
<HStack w="full">
47+
<Input
48+
placeholder="OpenPipe API Key (optional)"
49+
value={openPipeKey}
50+
onChange={(event) => setOpenPipeKey(event.target.value)}
51+
type={showPassword ? 'text' : 'password'}
52+
/>
53+
<Button
54+
onClick={() => setShowPassword(!showPassword)}
55+
variant="outline"
56+
>
57+
{showPassword ? 'Hide' : 'Show'}
58+
</Button>
59+
</HStack>
4560
<Button
46-
onClick={() => updateSettings({ openAIKey })}
61+
onClick={() => updateSettings({ openAIKey, openPipeKey })}
4762
w="full"
4863
disabled={!openAIKey}
4964
colorScheme="blue"
5065
>
51-
Save Key
66+
Save Keys
5267
</Button>
5368
</VStack>
5469
);

src/helpers/determineNextAction.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OpenAI } from 'openai';
1+
import OpenAI from 'openpipe/openai';
22
import { useAppState } from '../state/store';
33
import { availableActions } from './availableActions';
44
import { ParsedResponseSuccess } from './parseResponse';
@@ -37,15 +37,19 @@ export async function determineNextAction(
3737
) {
3838
const model = useAppState.getState().settings.selectedModel;
3939
const prompt = formatPrompt(taskInstructions, previousActions, simplifiedDOM);
40-
const key = useAppState.getState().settings.openAIKey;
41-
if (!key) {
40+
const openAIKey = useAppState.getState().settings.openAIKey;
41+
const openPipeKey = useAppState.getState().settings.openPipeKey;
42+
if (!openAIKey) {
4243
notifyError?.('No OpenAI key found');
4344
return null;
4445
}
4546

4647
const openai = new OpenAI({
47-
apiKey: key,
48+
apiKey: openAIKey,
4849
dangerouslyAllowBrowser: true,
50+
openpipe: {
51+
apiKey: openPipeKey ?? undefined,
52+
},
4953
});
5054

5155
for (let i = 0; i < maxAttempts; i++) {
@@ -63,10 +67,9 @@ export async function determineNextAction(
6367
reasoning_effort: model === 'o1' ? 'low' : undefined,
6468
temperature: model === 'o1' ? undefined : 0,
6569
stop: ['</Action>'],
70+
store: openPipeKey ? true : false,
6671
});
6772

68-
console.log('completion', completion);
69-
7073
return {
7174
usage: completion.usage,
7275
prompt,

src/state/settings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import { MyStateCreator } from './store';
22

33
export type SettingsSlice = {
44
openAIKey: string | null;
5+
openPipeKey: string | null;
56
selectedModel: string;
67
actions: {
78
update: (values: Partial<SettingsSlice>) => void;
89
};
910
};
1011
export const createSettingsSlice: MyStateCreator<SettingsSlice> = (set) => ({
1112
openAIKey: null,
13+
openPipeKey: null,
1214
selectedModel: 'gpt-3.5-turbo',
1315
actions: {
1416
update: (values) => {

yarn.lock

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@
1010
"@jridgewell/gen-mapping" "^0.1.0"
1111
"@jridgewell/trace-mapping" "^0.3.9"
1212

13+
"@anthropic-ai/sdk@^0.32.1":
14+
version "0.32.1"
15+
resolved "https://registry.yarnpkg.com/@anthropic-ai/sdk/-/sdk-0.32.1.tgz#d22c8ebae2adccc59d78fb416e89de337ff09014"
16+
integrity sha512-U9JwTrDvdQ9iWuABVsMLj8nJVwAyQz6QXvgLsVhryhCEPkLsbcP/MXxm+jYcAwLoV8ESbaTTjnD4kuAFa+Hyjg==
17+
dependencies:
18+
"@types/node" "^18.11.18"
19+
"@types/node-fetch" "^2.6.4"
20+
abort-controller "^3.0.0"
21+
agentkeepalive "^4.2.1"
22+
form-data-encoder "1.7.2"
23+
formdata-node "^4.3.2"
24+
node-fetch "^2.6.7"
25+
1326
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.18.6":
1427
version "7.18.6"
1528
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.18.6.tgz#3b25d38c89600baa2dcc219edfa88a74eb2c427a"
@@ -3841,6 +3854,13 @@ encodeurl@~1.0.2:
38413854
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
38423855
integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==
38433856

3857+
3858+
version "0.1.13"
3859+
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.13.tgz#56574afdd791f54a8e9b2785c0582a2d26210fa9"
3860+
integrity sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==
3861+
dependencies:
3862+
iconv-lite "^0.6.2"
3863+
38443864
enhanced-resolve@^5.0.0, enhanced-resolve@^5.10.0:
38453865
version "5.12.0"
38463866
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.12.0.tgz#300e1c90228f5b570c4d35babf263f6da7155634"
@@ -4552,6 +4572,15 @@ [email protected]:
45524572
resolved "https://registry.yarnpkg.com/form-data-encoder/-/form-data-encoder-1.7.2.tgz#1f1ae3dccf58ed4690b86d87e4f57c654fbab040"
45534573
integrity sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==
45544574

4575+
4576+
version "4.0.1"
4577+
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.1.tgz#ba1076daaaa5bfd7e99c1a6cb02aa0a5cff90d48"
4578+
integrity sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==
4579+
dependencies:
4580+
asynckit "^0.4.0"
4581+
combined-stream "^1.0.8"
4582+
mime-types "^2.1.12"
4583+
45554584
form-data@^4.0.0:
45564585
version "4.0.0"
45574586
resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452"
@@ -5036,7 +5065,7 @@ [email protected]:
50365065
dependencies:
50375066
safer-buffer ">= 2.1.2 < 3"
50385067

5039-
[email protected], iconv-lite@^0.6.3:
5068+
[email protected], iconv-lite@^0.6.2, iconv-lite@^0.6.3:
50405069
version "0.6.3"
50415070
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501"
50425071
integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==
@@ -6284,7 +6313,7 @@ [email protected]:
62846313
resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5"
62856314
integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==
62866315

6287-
node-fetch@^2.6.7:
6316+
node-fetch@2.7.0, node-fetch@^2.6.7:
62886317
version "2.7.0"
62896318
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
62906319
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==
@@ -6438,7 +6467,7 @@ open@^8.0.9:
64386467
is-docker "^2.1.1"
64396468
is-wsl "^2.2.0"
64406469

6441-
openai@^4.78.1:
6470+
openai@^4.78.0, openai@^4.78.1:
64426471
version "4.78.1"
64436472
resolved "https://registry.yarnpkg.com/openai/-/openai-4.78.1.tgz#44c3b195d239891be9c9c53722539ad8a1fcc5f2"
64446473
integrity sha512-drt0lHZBd2lMyORckOXFPQTmnGLWSLt8VK0W9BhOKWpMFBEoHMoz5gxMPmVq5icp+sOrsbMnsmZTVHUlKvD1Ow==
@@ -6451,6 +6480,17 @@ openai@^4.78.1:
64516480
formdata-node "^4.3.2"
64526481
node-fetch "^2.6.7"
64536482

6483+
openpipe@^0.43.0:
6484+
version "0.43.0"
6485+
resolved "https://registry.yarnpkg.com/openpipe/-/openpipe-0.43.0.tgz#685184a5444b8460da191e24a4592ef2c0b4f2ad"
6486+
integrity sha512-kWUACzzUK5RLfgODJwknCVqtZ3E2At0Q88s9sEh09vMMvNRUnqk913Ax3XlKajCzyqQH6UNBs23tBjkyIi/0vQ==
6487+
dependencies:
6488+
"@anthropic-ai/sdk" "^0.32.1"
6489+
encoding "0.1.13"
6490+
form-data "4.0.1"
6491+
node-fetch "2.7.0"
6492+
openai "^4.78.0"
6493+
64546494
optionator@^0.8.1:
64556495
version "0.8.3"
64566496
resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"

0 commit comments

Comments
 (0)