Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon Bedrock Support #955

Merged
merged 5 commits into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libs/superagent/app/agents/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ def get_llm_params(self):
return {
"temperature": options.get("temperature"),
"max_tokens": options.get("max_tokens"),
"aws_access_key_id": options.get("aws_access_key_id"),
"aws_secret_access_key": options.get("aws_secret_access_key"),
"aws_region_name": options.get("aws_region_name"),
}

async def _get_prompt(self):
Expand Down
2 changes: 2 additions & 0 deletions libs/superagent/app/api/workflow_configs/saml_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class LLMAgentTool(BaseAgentToolModel, LLMAgent):
LLMProvider.PERPLEXITY.value,
LLMProvider.TOGETHER_AI.value,
LLMProvider.ANTHROPIC.value,
LLMProvider.BEDROCK.value,
]


Expand All @@ -157,6 +158,7 @@ class Workflow(BaseModel):
# ~~OSS LLM providers~~
perplexity: Optional[LLMAgent]
together_ai: Optional[LLMAgent]
bedrock: Optional[LLMAgent]
anthropic: Optional[LLMAgent]
llm: Optional[LLMAgent] = Field(
description="Deprecated! Use LLM providers instead. e.g. `perplexity` or `together_ai`"
Expand Down
83 changes: 76 additions & 7 deletions libs/superagent/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterEnum
ALTER TYPE "LLMProvider" ADD VALUE 'BEDROCK';
1 change: 1 addition & 0 deletions libs/superagent/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum LLMProvider {
PERPLEXITY
TOGETHER_AI
ANTHROPIC
BEDROCK
}

enum LLMModel {
Expand Down
3 changes: 2 additions & 1 deletion libs/superagent/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ openai = "^1.1.1"
langchain-experimental = "^0.0.37"
pydub = "^0.25.1"
algoliasearch = "^3.0.0"
litellm = "^1.29.4"
litellm = "1.35.2"
weaviate-client = "^3.25.3"
qdrant-client = "^1.6.9"
vecs = "^0.4.2"
Expand All @@ -66,6 +66,7 @@ langsmith = "^0.1.9"
langfuse = "2.21.3"
tavily-python = "^0.3.1"
scrapingbee = "^2.0.1"
boto3 = "^1.34.83"



Expand Down
13 changes: 11 additions & 2 deletions libs/ui/app/integrations/llm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,17 @@ const azureSchema = z.object({
azure_deployment: z.string().nonempty("Deployment cannnot be empty"),
})

const bedrockSchema = z.object({
aws_access_key_id: z.string().nonempty("Access key ID cannot be empty"),
aws_secret_access_key: z
.string()
.nonempty("Secret access key cannot be empty"),
aws_region: z.string().nonempty("Region cannot be empty"),
})

const formSchema = z.object({
apiKey: z.string().nonempty("API key is mandatory"),
options: azureSchema.optional(),
apiKey: z.string().optional(),
options: z.union([azureSchema, bedrockSchema]),
})

export default function LLM({
Expand All @@ -59,6 +67,7 @@ export default function LLM({
},
})

console.log("form", form.formState.errors)
async function onSubmit(values: z.infer<typeof formSchema>) {
const payload = {
...values,
Expand Down
37 changes: 30 additions & 7 deletions libs/ui/config/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export const siteConfig = {
},
],
},
{
{
value: "ADVANCED_SCRAPER",
title: "Advanced Web extractor",
metadata: [
Expand Down Expand Up @@ -486,15 +486,25 @@ export const siteConfig = {
],
},
{
disabled: true,
formDescription: "Please enter your HF API key.",
provider: "HUGGINGFACE",
name: "Hugging Face",
disabled: false,
formDescription: "Please enter your AWS credentials.",
provider: "BEDROCK",
name: "Amazon Bedrock",
metadata: [
{
key: "apiKey",
key: "options.aws_access_key_id",
type: "input",
label: "HF API Key",
label: "AWS Access Key",
},
{
key: "options.aws_secret_access_key",
type: "input",
label: "AWS Secret Access Key",
},
{
key: "options.aws_region_name",
type: "input",
label: "AWS Region",
},
],
},
Expand Down Expand Up @@ -526,6 +536,19 @@ export const siteConfig = {
},
],
},
{
disabled: true,
formDescription: "Please enter your HF API key.",
provider: "HUGGINGFACE",
name: "Hugging Face",
metadata: [
{
key: "apiKey",
type: "input",
label: "HF API Key",
},
],
},
],
vectorDbs: [
{
Expand Down