Skip to content

Commit

Permalink
Amazon Bedrock Support (#955)
Browse files Browse the repository at this point in the history
* deps: add boto3

* deps: upgrade litellm from 1.29.4 to 13.5.2

* feat(backend): add amazon bedrock

* feat(ui): add amazon bedrock

* Update version

---------

Co-authored-by: Ismail Pelaseyed <homanp@gmail.com>
  • Loading branch information
elisalimli and homanp committed Apr 13, 2024
1 parent e77ae82 commit f4cd7e1
Show file tree
Hide file tree
Showing 9 changed files with 129 additions and 19 deletions.
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
2 changes: 1 addition & 1 deletion libs/superagent/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
title="Superagent",
docs_url="/",
description="🥷 Run AI-agents with an API",
version="0.2.27",
version="0.2.29",
servers=[{"url": config("SUPERAGENT_API_URL")}],
)

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
5 changes: 3 additions & 2 deletions libs/superagent/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "superagent"
version = "0.2.27"
version = "0.2.29"
description = "🥷 Run AI-agents with an API"
authors = ["Ismail Pelaseyed"]
readme = "../../README.md"
Expand Down 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

0 comments on commit f4cd7e1

Please sign in to comment.