Skip to content

Commit

Permalink
Merge branch 'main' into issue-1522/-wrong-menuitem-focus-in-human-ev…
Browse files Browse the repository at this point in the history
…al-view
  • Loading branch information
bekossy committed Apr 19, 2024
2 parents 780ebf7 + b003005 commit 7b5d696
Show file tree
Hide file tree
Showing 9 changed files with 1,917 additions and 238 deletions.
11 changes: 6 additions & 5 deletions agenta-backend/agenta_backend/models/api/evaluation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,15 @@ class LLMRunRateLimit(BaseModel):

class LMProvidersEnum(str, Enum):
openai = "OPENAI_API_KEY"
replicate = "REPLICATE_API_KEY"
mistralai = "MISTRAL_API_KEY"
cohere = "COHERE_API_KEY"
hugging_face = "HUGGING_FACE_API_KEY"
anthropic = "ANTHROPIC_API_KEY"
azure_base = "AZURE_API_BASE"
azure_key = "AZURE_API_KEY"
anyscale = "ANYSCALE_API_KEY"
perplexityai = "PERPLEXITYAI_API_KEY"
deepinfra = "DEEPINFRA_API_KEY"
togetherai = "TOGETHERAI_API_KEY"
mistralai = "MISTRAL_API_KEY"
alephalpha = "ALEPHALPHA_API_KEY"
openrouter = "OPENROUTER_API_KEY"


class NewEvaluation(BaseModel):
Expand Down
7 changes: 7 additions & 0 deletions agenta-backend/agenta_backend/routers/app_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,13 @@ async def create_app_and_variant_from_template(
"OPENAI_API_KEY",
"MISTRAL_API_KEY",
"COHERE_API_KEY",
"ANTHROPIC_API_KEY",
"ANYSCALE_API_KEY",
"PERPLEXITYAI_API_KEY",
"DEEPINFRA_API_KEY",
"TOGETHERAI_API_KEY",
"ALEPHALPHA_API_KEY",
"OPENROUTER_API_KEY",
]
missing_keys = [
key for key in supported_llm_prodviders_keys if not os.environ.get(key)
Expand Down
2 changes: 2 additions & 0 deletions agenta-web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const nextConfig = {
reactStrictMode: true,
pageExtensions: ["ts", "tsx", "js", "jsx", "md", "mdx"],
productionBrowserSourceMaps: true,
transpilePackages: ["@lobehub/icons"],
swcMinify: true,

async redirects() {
return [
Expand Down
1,942 changes: 1,764 additions & 178 deletions agenta-web/package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions agenta-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@headlessui/react": "^1.7.18",
"@headlessui/tailwindcss": "^0.2.0",
"@heroicons/react": "^2.0.17",
"@lobehub/icons": "^1.18.0",
"@mdx-js/loader": "^2.3.0",
"@mdx-js/react": "^2.3.0",
"@monaco-editor/react": "^4.5.2",
Expand Down Expand Up @@ -59,7 +60,7 @@
"jotai": "^2.5.0",
"js-beautify": "^1.14.8",
"lodash": "^4.17.21",
"next": "13.3.4",
"next": "^13.5.6",
"nextjs-cors": "^2.1.2",
"papaparse": "^5.4.1",
"postcss": "^8.4.35",
Expand All @@ -86,9 +87,11 @@
"uuid": "^9.0.1"
},
"devDependencies": {
"@swc/cli": "^0.3.12",
"@swc/core": "^1.4.15",
"@types/node": "^20.8.10",
"cypress": "^13.4.0",
"node-mocks-http": "^1.12.2",
"prettier": "^3.0.0"
"prettier": "^3.2.5"
}
}
97 changes: 97 additions & 0 deletions agenta-web/src/components/Playground/Views/GroupedSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React from "react"
import {createUseStyles} from "react-jss"
import {Select} from "antd"

import {
IconType,
OpenAI,
Mistral,
Cohere,
Anthropic,
Perplexity,
Together,
OpenRouter,
Fireworks,
} from "@lobehub/icons"

const useStyles = createUseStyles({
select: {
width: "100%",
},
option: {
display: "flex",
alignItems: "center",
gap: "8px",
},
})

interface IconMap {
[key: string]: IconType
}

interface GroupedSelectProps {
choices: {[group: string]: string[]}
defaultValue: string
handleChange: (value: string) => void
}

const iconMap: {[key: string]: React.ComponentType<any>} = {
"Open AI": OpenAI,
"Mistral AI": Mistral.Color,
Cohere: Cohere.Color,
Anthropic: Anthropic,
"Perplexity AI": Perplexity.Color,
"Together AI": Together.Color,
OpenRouter: OpenRouter,
}

const getTextContent = (element: React.ReactNode): string => {
if (typeof element === "string") {
return element
} else if (React.isValidElement(element) && element.props.children) {
return React.Children.toArray(element.props.children).reduce<string>(
(acc, child) => acc + getTextContent(child),
"",
)
}
return ""
}

const filterOption = (input: string, option?: {label: React.ReactNode; value: string}) =>
getTextContent(option?.label).toLowerCase().includes(input.toLowerCase())

export const GroupedSelect: React.FC<GroupedSelectProps> = ({
choices,
defaultValue,
handleChange,
}) => {
const classes = useStyles()

const options = Object.entries(choices).map(([groupLabel, groupChoices]) => ({
label: (
<div className={classes.option}>
{iconMap[groupLabel] ? React.createElement(iconMap[groupLabel]) : null}
{groupLabel}
</div>
),
options: groupChoices.map((choice) => ({
label: (
<div className={classes.option}>
{iconMap[groupLabel] ? React.createElement(iconMap[groupLabel]) : null}
{choice}
</div>
),
value: choice,
})),
}))
return (
<Select
showSearch
defaultValue={defaultValue}
className={classes.select}
onChange={handleChange}
filterOption={filterOption}
options={options as any}
/>
)
}
74 changes: 27 additions & 47 deletions agenta-web/src/components/Playground/Views/ParametersCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {createUseStyles} from "react-jss"
import {renameVariables} from "@/lib/helpers/utils"
import {Parameter, InputParameter} from "@/lib/Types"
import {DownOutlined} from "@ant-design/icons"

import {
Row,
Card,
Expand All @@ -17,6 +18,7 @@ import {
Menu,
Space,
} from "antd"
import {GroupedSelect} from "./GroupedSelect"

const useStyles = createUseStyles({
row1: {
Expand Down Expand Up @@ -66,38 +68,14 @@ const useStyles = createUseStyles({
marginBottom: 8,
},
inputNumber: {
margin: "0 16px",
width: "100%",
margin: "0 0 0 16px",
width: "calc(100% - 16px)",
},
select: {
width: "100%",
},
})

interface GroupedSelectProps {
choices: {[group: string]: string[]}
defaultValue: string
handleChange: (value: string) => void
}

const GroupedSelect: React.FC<GroupedSelectProps> = ({choices, defaultValue, handleChange}) => {
const classes = useStyles()
return (
<Select
defaultValue={defaultValue}
className={classes.select}
onChange={handleChange}
options={Object.entries(choices).map(([groupLabel, groupChoices]) => ({
label: groupLabel,
options: groupChoices.map((choice) => ({
label: choice,
value: choice,
})),
}))}
/>
)
}

interface ModelParametersProps {
optParams: Parameter[] | null
onChange: (param: Parameter, value: number | string) => void
Expand Down Expand Up @@ -135,7 +113,7 @@ export const ModelParameters: React.FC<ModelParametersProps> = ({
{renameVariables(param.name)}
</h4>
</Col>
<Col span={8}>
<Col span={param.type === "grouped_choice" ? 10 : 8}>
{param.type === "number" && (
<Slider
min={param.minimum}
Expand Down Expand Up @@ -197,26 +175,28 @@ export const ModelParameters: React.FC<ModelParametersProps> = ({
/>
)}
</Col>
<Col>
{param.type === "number" && (
<InputNumber
min={0}
max={10000}
className={classes.inputNumber}
value={param.default}
onChange={(value) => onChange(param, value)}
/>
)}
{param.type === "integer" && (
<InputNumber
min={param.minimum}
max={param.maximum}
className={classes.inputNumber}
value={param.default}
onChange={(value) => onChange(param, value)}
/>
)}
</Col>
{param.type !== "grouped_choice" && (
<Col span={2}>
{param.type === "number" && (
<InputNumber
min={0}
max={10000}
className={classes.inputNumber}
value={param.default}
onChange={(value) => onChange(param, value)}
/>
)}
{param.type === "integer" && (
<InputNumber
min={param.minimum}
max={param.maximum}
className={classes.inputNumber}
value={param.default}
onChange={(value) => onChange(param, value)}
/>
)}
</Col>
)}
<Row />
</Row>
))}
Expand Down
10 changes: 6 additions & 4 deletions agenta-web/src/lib/helpers/llmProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ export type LlmProvider = {

export const llmAvailableProviders: LlmProvider[] = [
{title: "OpenAI", key: "", name: "OPENAI_API_KEY"},
{title: "Replicate", key: "", name: "REPLICATE_API_KEY"},
{title: "Hugging Face", key: "", name: "HUGGING_FACE_API_KEY"},
{title: "Mistral AI", key: "", name: "MISTRAL_API_KEY"},
{title: "Cohere", key: "", name: "COHERE_API_KEY"},
{title: "Anthropic", key: "", name: "ANTHROPIC_API_KEY"},
{title: "Azure", key: "", name: "AZURE_API_KEY"},
{title: "Anyscale", key: "", name: "ANYSCALE_API_KEY"},
{title: "Perplexity AI", key: "", name: "PERPLEXITYAI_API_KEY"},
{title: "DeepInfra", key: "", name: "DEEPINFRA_API_KEY"},
{title: "TogetherAI", key: "", name: "TOGETHERAI_API_KEY"},
{title: "Mistral AI", key: "", name: "MISTRAL_API_KEY"},
{title: "Aleph Alpha", key: "", name: "ALEPHALPHA_API_KEY"},
{title: "OpenRouter", key: "", name: "OPENROUTER_API_KEY"},
]

export const getApikeys = () => {
Expand Down
5 changes: 3 additions & 2 deletions docker-compose.gh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ services:
- agenta-network

celery_worker:
build: ./agenta-backend
container_name: celery-worker-1
image: ghcr.io/agenta-ai/agenta-backend
command: >
watchmedo auto-restart --directory=./agenta_backend --pattern=*.py --recursive -- celery -A agenta_backend.main.celery_app worker --concurrency=1 --loglevel=INFO
celery -A agenta_backend.main.celery_app worker --concurrency=1 --loglevel=INFO
environment:
- MONGODB_URI=mongodb://username:password@mongo:27017
- REDIS_URL=redis://redis:6379/0
Expand Down

0 comments on commit 7b5d696

Please sign in to comment.