File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ package-lock.json
44scratch.js
55bots /** /action-code /**
66bots /** /
7- config .json
7+ keys .json
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ This project allows an AI model to write/execute code on your computer that may
1414
1515## Installation
1616
17- Rename ` config .example.json` to ` config .json` and fill in the desired API keys
17+ Rename ` keys .example.json` to ` keys .json` and fill in the desired API keys
1818| API | Config Variable | Example Model name | Docs |
1919| ------| ------| ------| ------|
2020| OpenAI | ` OPENAI_API_KEY ` | ` gpt-3.5-turbo ` | [ docs] ( https://platform.openai.com/docs/models ) | (optionally add ` OPENAI_ORG_ID ` )
File renamed without changes.
Original file line number Diff line number Diff line change 11import Anthropic from '@anthropic-ai/sdk' ;
2- import configJson from "../../config .json" assert { type : "json " } ;
2+ import configJson from "../../keys .json" assert { type : "json " } ;
33
44
55export class Claude {
@@ -11,8 +11,10 @@ export class Claude {
1111 config . baseURL = url ;
1212 if ( configJson . ANTHROPIC_API_KEY )
1313 config . apiKey = configJson . ANTHROPIC_API_KEY ;
14+ else if ( process . env . ANTHROPIC_API_KEY )
15+ config . apiKey = process . env . ANTHROPIC_API_KEY ;
1416 else
15- throw new Error ( 'Anthropic API key missing! Make sure you set your ANTHROPIC_API_KEY in your config .json.' ) ;
17+ throw new Error ( 'Anthropic API key missing! Make sure you set your ANTHROPIC_API_KEY in your keys .json.' ) ;
1618
1719 this . anthropic = new Anthropic ( config ) ;
1820 }
Original file line number Diff line number Diff line change 11import { GoogleGenerativeAI } from '@google/generative-ai' ;
22import { toSinglePrompt } from '../utils/text.js' ;
3- import configJson from "../../config .json" assert { type : "json " } ;
3+ import configJson from "../../keys .json" assert { type : "json " } ;
44
55export class Gemini {
66 constructor ( model_name , url ) {
77 this . model_name = model_name ;
88 this . url = url ;
99
10- if ( ! configJson . GEMINI_API_KEY ) {
11- throw new Error ( 'Gemini API key missing! Make sure you set your GEMINI_API_KEY in your config.json.' ) ;
12- }
13- this . genAI = new GoogleGenerativeAI ( configJson . GEMINI_API_KEY ) ;
10+ if ( configJson . GEMINI_API_KEY )
11+ this . genAI = new GoogleGenerativeAI ( configJson . GEMINI_API_KEY ) ;
12+ else if ( process . env . GEMINI_API_KEY )
13+ this . genAI = new GoogleGenerativeAI ( process . env . GEMINI_API_KEY ) ;
14+ else
15+ throw new Error ( 'Gemini API key missing! Make sure you set your GEMINI_API_KEY in your keys.json.' ) ;
1416 }
1517
1618 async sendRequest ( turns , systemMessage ) {
Original file line number Diff line number Diff line change 11import OpenAIApi from 'openai' ;
2- import configJson from "../../config .json" assert { type : "json " } ;
2+ import configJson from "../../keys .json" assert { type : "json " } ;
33
44export class GPT {
55 constructor ( model_name , url ) {
@@ -8,12 +8,18 @@ export class GPT {
88 let config = { } ;
99 if ( url )
1010 config . baseURL = url ;
11+
1112 if ( configJson . OPENAI_ORG_ID )
12- config . organization = configJson . OPENAI_ORG_ID ;
13+ config . apiKey = configJson . OPENAI_ORG_ID ;
14+ else if ( process . env . OPENAI_ORG_ID )
15+ config . apiKey = process . env . OPENAI_ORG_ID ;
16+
1317 if ( configJson . OPENAI_API_KEY )
1418 config . apiKey = configJson . OPENAI_API_KEY ;
19+ else if ( process . env . OPENAI_API_KEY )
20+ config . apiKey = process . env . OPENAI_API_KEY ;
1521 else
16- throw new Error ( 'OpenAI API key missing! Make sure you set your OPENAI_API_KEY in your config .json.' ) ;
22+ throw new Error ( 'OpenAI API key missing! Make sure you set your OPENAI_API_KEY in your keys .json.' ) ;
1723
1824 this . openai = new OpenAIApi ( config ) ;
1925 }
Original file line number Diff line number Diff line change 11import Replicate from 'replicate' ;
22import { toSinglePrompt } from '../utils/text.js' ;
3- import configJson from "../../config .json" assert { type : "json " } ;
3+ import configJson from "../../keys .json" assert { type : "json " } ;
44
55// llama, mistral
66export class ReplicateAPI {
@@ -12,13 +12,16 @@ export class ReplicateAPI {
1212 console . warn ( 'Replicate API does not support custom URLs. Ignoring provided URL.' ) ;
1313 }
1414
15- if ( ! configJson . REPLICATE_API_KEY ) {
16- throw new Error ( 'Replicate API key missing! Make sure you set your REPLICATE_API_KEY in your config.json.' ) ;
17- }
18-
19- this . replicate = new Replicate ( {
20- auth : configJson . REPLICATE_API_KEY ,
21- } ) ;
15+ if ( configJson . REPLICATE_API_KEY )
16+ this . replicate = new Replicate ( {
17+ auth : configJson . REPLICATE_API_KEY ,
18+ } ) ;
19+ else if ( process . env . REPLICATE_API_KEY )
20+ this . replicate = new Replicate ( {
21+ auth : process . env . REPLICATE_API_KEY ,
22+ } ) ;
23+ else
24+ throw new Error ( 'Replicate API key missing! Make sure you set your REPLICATE_API_KEY in your keys.json.' ) ;
2225 }
2326
2427 async sendRequest ( turns , systemMessage ) {
You can’t perform that action at this time.
0 commit comments