Skip to content

Commit 22a0019

Browse files
authored
Feat/aws bedrock (#34)
This PR adds support for Amazon Bedrock (using Boto3) which gives users access to an additional 15 LLM's. The LLM's being added include: AI21 Labs / Jurassic-2 Ultra AI21 Labs / Jurassic-2 Mid Amazon / Titan Text Lite Amazon / Titan Text Express Amazon / Titan Text Embeddings Anthropic / Claude 2.1 Anthropic / Claude 2.0 Anthropic / Claude 1.3 Anthropic / Claude Instant Cohere / Command Cohere / Command Light Cohere / Embed - English Cohere / Embed - Multilingual Meta / Llama-2-13b-chat Meta / Llama-2-70b-chat
1 parent 83428d5 commit 22a0019

17 files changed

+1061
-7
lines changed

.envrc.example

+4
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@ export OPENAI_API_KEY=
22
export COHERE_API_KEY=
33
export EXTRA_RUN_OPTIONS=--reload
44

5+
export AWS_REGION=
6+
export AWS_PUBLIC_ACCESS_KEY=
7+
export AWS_PRIVATE_ACCESS_KEY=
8+
59
export DATABASE_URL=postgresql://postgres:postgres@postgres:5432/llm_gateway

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,35 @@ Per OpenAI's non-API consumer products [data usage policy](https://help.openai.c
1212

1313
Use `llm-gateway` to interact with OpenAI in a safe manner. The gateway also recreates the ChatGPT frontend using OpenAI's `/ChatCompletion` endpoint to keep all communication within the API.
1414

15+
## 📦 Supported Models
16+
17+
| Provider | Model |
18+
|:--------------:|:-------------------------:|
19+
| OpenAI | GPT 3.5 Turbo |
20+
| OpenAI | GPT 3.5 Turbo 16k |
21+
| OpenAI | GPT 4 |
22+
| AI21 Labs | Jurassic-2 Ultra |
23+
| AI21 Labs | Jurassic-2 Mid |
24+
| Amazon | Titan Text Lite |
25+
| Amazon | Titan Text Express |
26+
| Amazon | Titan Text Embeddings |
27+
| Anthropic | Claude 2.1 |
28+
| Anthropic | Claude 2.0 |
29+
| Anthropic | Claude 1.3 |
30+
| Anthropic | Claude Instant |
31+
| Cohere | Command |
32+
| Cohere | Command Light |
33+
| Cohere | Embed - English |
34+
| Cohere | Embed - Multilingual |
35+
| Meta | Llama-2-13b-chat |
36+
| Meta | Llama-2-70b-chat |
37+
1538
## ⚒️ Usage
1639

1740
The provider's API key needs to be saved as an environment variable (see setup further down). If you are communicating with OpenAI, set `OPENAI_API_KEY`.
1841

42+
For step-by-step setup instructions with Cohere, OpenAI, and AWS Bedrock, click [here](llm_gateway/README.md).
43+
1944
### API Usage
2045
[OpenAI] Example cURL to `/completion` endpoint:
2146
```

fixtures/init.sql

+12
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@ CREATE TABLE cohere_requests(
2121
created_at TIMESTAMP WITHOUT TIME ZONE,
2222
cohere_endpoint VARCHAR
2323
);
24+
25+
CREATE TABLE awsbedrock_requests(
26+
id serial primary key,
27+
user_input VARCHAR,
28+
user_email VARCHAR,
29+
awsbedrock_response JSON,
30+
awsbedrock_model VARCHAR,
31+
temperature FLOAT,
32+
created_at TIMESTAMP WITHOUT TIME ZONE,
33+
awsbedrock_endpoint VARCHAR
34+
extras JSON
35+
);

front_end/src/app/components/SettingsDialog/settingsDialog.tsx

+9
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ export const ModelSettingsDialog: React.FC<Props> = ({
122122
</b>
123123
{modelChoices[selectedOption].maxTokensLimit} tokens <br />
124124
</li>
125+
<li>
126+
<b>
127+
<span role="img" aria-label="blink">
128+
⚙️
129+
</span>{' '}
130+
Requirements:{' '}
131+
</b>
132+
{modelChoices[selectedOption].requirements} <br />
133+
</li>
125134
</ul>
126135
</details>
127136
<details>

front_end/src/app/interfaces.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export interface ModelInfo {
4646
advanceMetadata: ModelMetadata;
4747
supportFileUpload: boolean;
4848
initialPrompt: Message[];
49-
requestBody: (req: IRequestBody) => OpenAIRequestBody | CohereRequestBody;
49+
requirements: string,
50+
requestBody: (req: IRequestBody) => OpenAIRequestBody | CohereRequestBody | AWSBedrockRequestBody;
5051
responseHandler: (res: any) => string;
5152
}
5253

@@ -63,10 +64,24 @@ export interface CohereRequestBody {
6364
model: string;
6465
}
6566

67+
export interface AWSBedrockRequestBody {
68+
model: string;
69+
temperature: number;
70+
max_tokens: number;
71+
prompt?: string;
72+
embedding_texts?: string[];
73+
instructions?: string;
74+
model_kwargs?: ModelConfig;
75+
}
76+
6677
interface ModelMetadata {
6778
[key: string]: string;
6879
}
6980

81+
interface ModelConfig {
82+
[key: string]: any;
83+
}
84+
7085
export interface Models {
7186
[key: string]: ModelInfo;
7287
}

0 commit comments

Comments
 (0)