Skip to content

Commit

Permalink
Merge branch 'main' into AGE-1343/-implement-home-view-onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-agenta committed Dec 8, 2024
2 parents 750e26b + 413bf0f commit 22deb4a
Show file tree
Hide file tree
Showing 24 changed files with 107 additions and 42 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,15 @@
"bug",
"infra"
]
},
{
"login": "morenobonaventura",
"name": "Moreno Bonaventura",
"avatar_url": "https://avatars.githubusercontent.com/u/2118854?v=4",
"profile": "https://github.com/morenobonaventura",
"contributions": [
"bug"
]
}
],
"contributorsPerLine": 7,
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ Check out our [Contributing Guide](https://docs.agenta.ai/misc/contributing/gett
## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-48-orange.svg?style=flat-square)](#contributors-)

[![All Contributors](https://img.shields.io/badge/all_contributors-49-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Expand Down Expand Up @@ -212,6 +210,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://ashrafchowdury.me"><img src="https://avatars.githubusercontent.com/u/87828904?v=4?s=100" width="100px;" alt="Ashraf Chowdury"/><br /><sub><b>Ashraf Chowdury</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/issues?q=author%3Aashrafchowdury" title="Bug reports">🐛</a> <a href="https://github.com/Agenta-AI/agenta/commits?author=ashrafchowdury" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jp-agenta"><img src="https://avatars.githubusercontent.com/u/174311389?v=4?s=100" width="100px;" alt="jp-agenta"/><br /><sub><b>jp-agenta</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/commits?author=jp-agenta" title="Code">💻</a> <a href="https://github.com/Agenta-AI/agenta/issues?q=author%3Ajp-agenta" title="Bug reports">🐛</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://mrunhap.github.io"><img src="https://avatars.githubusercontent.com/u/24653356?v=4?s=100" width="100px;" alt="Mr Unhappy"/><br /><sub><b>Mr Unhappy</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/issues?q=author%3Amrunhap" title="Bug reports">🐛</a> <a href="#infra-mrunhap" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/morenobonaventura"><img src="https://avatars.githubusercontent.com/u/2118854?v=4?s=100" width="100px;" alt="Moreno Bonaventura"/><br /><sub><b>Moreno Bonaventura</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/issues?q=author%3Amorenobonaventura" title="Bug reports">🐛</a></td>
</tr>
</tbody>
</table>
Expand Down
15 changes: 14 additions & 1 deletion agenta-backend/agenta_backend/core/shared/dtos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@


class LifecycleDTO(BaseModel):
created_at: datetime
created_at: Optional[datetime] = None
updated_at: Optional[datetime] = None

updated_by_id: Optional[UUID] = None


class IdentifierDTO(BaseModel):
id: UUID


class SlugDTO(BaseModel):
slug: str


class HeaderDTO(BaseModel):
name: Optional[str] = None
description: Optional[str] = None
36 changes: 35 additions & 1 deletion agenta-backend/agenta_backend/dbs/postgres/shared/dbas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from sqlalchemy import Column, UUID, TIMESTAMP, func
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy import Column, String, UUID, TIMESTAMP, func, Integer


class ProjectScopeDBA:
Expand Down Expand Up @@ -27,3 +28,36 @@ class LifecycleDBA:
UUID(as_uuid=True),
nullable=True,
)


class IdentifierDBA:
__abstract__ = True

id = Column(UUID(as_uuid=True), nullable=False)


class SlugDBA:
__abstract__ = True

slug = Column(String, nullable=False)


class HeaderDBA:
__abstract__ = True

name = Column(String, nullable=True)
description = Column(String, nullable=True)


class VersionedDBA:
__abstract__ = True

slug = Column(String, nullable=False)
version = Column(Integer, nullable=False)
id = Column(UUID(as_uuid=True), nullable=False)


class TagsDBA:
__abstract__ = True

tags = Column(JSONB(none_as_null=True), nullable=True)
3 changes: 1 addition & 2 deletions agenta-backend/agenta_backend/services/app_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,12 @@ async def start_variant(

try:
logger.debug(
"Starting variant %s with image name %s and tags %s and app_name %s and organization %s and workspace %s",
"Starting variant %s with image name %s and tags %s and app_name %s",
db_app_variant.variant_name,
db_app_variant.image.docker_id,
db_app_variant.image.tags,
db_app_variant.app.app_name,
)
logger.debug("App name is %s", db_app_variant.app.app_name)
# update the env variables
domain_name = os.environ.get("DOMAIN_NAME")
if domain_name is None or domain_name == "http://localhost":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ def diff(ground_truth: Any, app_output: Any, compare_schema_only: bool) -> float
llm_app_output_value = flattened_app_output.get(key, None)

key_score = 0.0
if ground_truth_value and llm_app_output_value:
if ground_truth_value is not None and llm_app_output_value is not None:
key_score = diff(
{key: ground_truth_value},
{key: llm_app_output_value},
Expand Down
2 changes: 1 addition & 1 deletion agenta-cli/agenta/sdk/decorators/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def handle_failure(self, error: Exception):
log.warning(format_exc().strip("\n"))
log.warning("--------------------------------------------------")

status_code = error.status_code if hasattr(error, "status_code") else 500
status_code = 500
message = str(error)
stacktrace = format_exception(error, value=error, tb=error.__traceback__) # type: ignore
detail = {"message": message, "stacktrace": stacktrace}
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/components/ChatInputs/ChatInputs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {ChatMessage, ChatRole, JSSTheme} from "@/lib/Types"
import {MinusOutlined, PlusOutlined} from "@ant-design/icons"
import {Button, Input, Select, Space, Tooltip} from "antd"
import {cloneDeep} from "lodash"
import cloneDeep from "lodash/cloneDeep"
import React, {useEffect, useRef, useState} from "react"
import {createUseStyles} from "react-jss"
import {useUpdateEffect} from "usehooks-ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {testsetRowToChatMessages} from "@/lib/helpers/testset"
import EvaluationVotePanel from "../Evaluations/EvaluationCardView/EvaluationVotePanel"
import VariantAlphabet from "../Evaluations/EvaluationCardView/VariantAlphabet"
import {ParamsFormWithRun} from "./SingleModelEvaluationTable"
import {debounce} from "lodash"
import debounce from "lodash/debounce"
import {variantNameWithRev} from "@/lib/helpers/variantHelper"
import {isBaseResponse, isFuncResponse} from "@/lib/helpers/playgroundResp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
getStringOrJson,
} from "@/lib/helpers/utils"
import {testsetRowToChatMessages} from "@/lib/helpers/testset"
import {debounce} from "lodash"
import debounce from "lodash/debounce"
import EvaluationVotePanel from "../Evaluations/EvaluationCardView/EvaluationVotePanel"
import ParamsForm from "../Playground/ParamsForm/ParamsForm"
import SaveTestsetModal from "../SaveTestsetModal/SaveTestsetModal"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {ABTestingEvaluationTableRow} from "@/components/EvaluationTable/ABTestin
import AlertPopup from "@/components/AlertPopup/AlertPopup"
import {useLocalStorage} from "usehooks-ts"
import {testsetRowToChatMessages} from "@/lib/helpers/testset"
import {debounce} from "lodash"
import debounce from "lodash/debounce"
import {EvaluationType} from "@/lib/enums"
import ParamsForm from "@/components/Playground/ParamsForm/ParamsForm"
import {useVariants} from "@/lib/hooks/useVariant"
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/components/Filters/Filters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {ArrowCounterClockwise, CaretDown, Funnel, Plus, Trash, X} from "@phospho
import {Button, Divider, Input, Popover, Select, Space, Typography} from "antd"
import {createUseStyles} from "react-jss"
import {useUpdateEffect} from "usehooks-ts"
import {isEqual} from "lodash"
import isEqual from "lodash/isEqual"

const useStyles = createUseStyles((theme: JSSTheme) => ({
popover: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import React, {useCallback, useEffect, useLayoutEffect, useRef, useState} from "
import {createUseStyles} from "react-jss"
import {useLocalStorage, useUpdateEffect} from "usehooks-ts"
import ChatInputs from "@/components/ChatInputs/ChatInputs"
import _ from "lodash"
import cloneDeep from "lodash/cloneDeep"
import clone from "lodash/clone"

const useStyles = createUseStyles({
footer: {
Expand Down Expand Up @@ -56,16 +57,16 @@ function flatToTurn({
chat?: ChatMessage[]
correct_answer?: ChatMessage | string
}) {
const flatChat = _.cloneDeep(chat || [])
const flatChat = cloneDeep(chat || [])
if (correct_answer && typeof correct_answer !== "string")
flatChat.push(_.cloneDeep(correct_answer))
flatChat.push(cloneDeep(correct_answer))

const turns: {chat: ChatMessage[]; correct_answer: ChatMessage}[] = []
let currentTurn: ChatMessage[] = []
flatChat.forEach((item) => {
if (item.role !== ChatRole.User) {
turns.push({
chat: _.clone(currentTurn || []),
chat: clone(currentTurn || []),
correct_answer: item,
})
}
Expand All @@ -75,7 +76,7 @@ function flatToTurn({
}

function turnToFlat(turns: {chat: ChatMessage[]; correct_answer: ChatMessage}[]) {
const flat = _.cloneDeep(turns.at(-1))
const flat = cloneDeep(turns.at(-1))
return {
chat: flat?.chat || [],
correct_answer: flat?.correct_answer || "",
Expand Down Expand Up @@ -125,8 +126,8 @@ const AddToTestSetDrawer: React.FC<Props> = ({params, isChatVariant, ...props})

//reset to defaults
form.resetFields()
chatParams.chat = _.cloneDeep(params.chat || [])
chatParams.correct_answer = _.cloneDeep(params.correct_answer || "")
chatParams.chat = cloneDeep(params.chat || [])
chatParams.correct_answer = cloneDeep(params.correct_answer || "")
setTurnModeChat(null)
setShouldRender(true)
} else {
Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/components/Playground/Views/TestView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {v4 as uuidv4} from "uuid"
import {testsetRowToChatMessages} from "@/lib/helpers/testset"
import ParamsForm from "../ParamsForm/ParamsForm"
import {TestContext} from "../TestContextProvider"
import {isEqual} from "lodash"
import isEqual from "lodash/isEqual"
import {useAppTheme} from "@/components/Layout/ThemeContextProvider"
import dayjs from "dayjs"
import relativeTime from "dayjs/plugin/relativeTime"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {runningStatuses, statusMapper} from "../../evaluations/cellRenderers/cel
import {useUpdateEffect} from "usehooks-ts"
import {shortPoll} from "@/lib/helpers/utils"
import {getFilterParams} from "./Filters/SearchFilter"
import {uniqBy} from "lodash"
import uniqBy from "lodash/uniqBy"
import EvaluationErrorPopover from "../EvaluationErrorProps/EvaluationErrorPopover"
import dayjs from "dayjs"
import {convertToCsv, downloadCsv} from "@/lib/helpers/fileManipulations"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {MinusCircleOutlined, PlusOutlined} from "@ant-design/icons"
import {Form} from "antd"
import Editor from "@monaco-editor/react"
import {createUseStyles} from "react-jss"
import {isEqual} from "lodash"
import isEqual from "lodash/isEqual"

const {TextArea} = Input

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {evaluatorsAtom} from "@/lib/atoms/evaluation"
import CompareOutputDiff from "@/components/CompareOutputDiff/CompareOutputDiff"
import {formatCurrency, formatLatency} from "@/lib/helpers/formatters"
import FilterColumns, {generateFilterItems} from "../FilterColumns/FilterColumns"
import _ from "lodash"
import uniqBy from "lodash/uniqBy"
import {variantNameWithRev} from "@/lib/helpers/variantHelper"
import {escapeNewlines} from "@/lib/helpers/fileManipulations"
import EvaluationErrorModal from "../EvaluationErrorProps/EvaluationErrorModal"
Expand Down Expand Up @@ -512,7 +512,7 @@ const EvaluationCompareMode: React.FC<Props> = () => {
<Space size={10}>
<FilterColumns
items={generateFilterItems(
_.uniqBy(
uniqBy(
colDefs.filter((item) => !item.headerName?.startsWith("Input")),
"headerName",
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import CompareOutputDiff from "@/components/CompareOutputDiff/CompareOutputDiff"
import {formatCurrency, formatLatency} from "@/lib/helpers/formatters"
import EvaluationErrorModal from "../EvaluationErrorProps/EvaluationErrorModal"
import EvaluationErrorText from "../EvaluationErrorProps/EvaluationErrorText"
import _ from "lodash"
import uniqBy from "lodash/uniqBy"
import FilterColumns, {generateFilterItems} from "../FilterColumns/FilterColumns"
import {variantNameWithRev} from "@/lib/helpers/variantHelper"
import {escapeNewlines} from "@/lib/helpers/fileManipulations"
Expand Down Expand Up @@ -85,10 +85,7 @@ const EvaluationScenarios: React.FC<Props> = () => {
}
}

const uniqueCorrectAnswers: CorrectAnswer[] = _.uniqBy(
scenarios[0]?.correct_answers || [],
"key",
)
const uniqueCorrectAnswers: CorrectAnswer[] = uniqBy(scenarios[0]?.correct_answers || [], "key")
const [modalErrorMsg, setModalErrorMsg] = useState({message: "", stackTrace: ""})
const [isErrorModalOpen, setIsErrorModalOpen] = useState(false)

Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/hooks/useDeepCompareEffect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isEqual} from "lodash"
import isEqual from "lodash/isEqual"
import React, {useEffect, useRef} from "react"
import {useUpdateEffect} from "usehooks-ts"

Expand Down
2 changes: 1 addition & 1 deletion agenta-web/src/lib/helpers/axiosConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {getErrorMessage, globalErrorHandler} from "./errorHandler"
import {signOut} from "supertokens-auth-react/recipe/session"
import router from "next/router"
import {getAgentaApiUrl} from "./utils"
import {isObject} from "lodash"
import isObject from "lodash/isObject"
import AlertPopup from "@/components/AlertPopup/AlertPopup"

export const PERMISSION_ERR_MSG =
Expand Down
3 changes: 2 additions & 1 deletion agenta-web/src/lib/helpers/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {convertToCsv, downloadCsv} from "./fileManipulations"
import {fetchEvaluatonIdsByResource} from "@/services/evaluations/api"
import {getAppValues} from "@/contexts/app.context"
import AlertPopup from "@/components/AlertPopup/AlertPopup"
import {capitalize, round} from "lodash"
import capitalize from "lodash/capitalize"
import round from "lodash/round"
import dayjs from "dayjs"
import {runningStatuses} from "@/components/pages/evaluations/cellRenderers/cellRenderers"
import {formatCurrency, formatLatency} from "./formatters"
Expand Down
4 changes: 2 additions & 2 deletions agenta-web/src/lib/helpers/llmProviders.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import _ from "lodash"
import cloneDeep from "lodash/cloneDeep"
import {camelToSnake} from "./utils"

const llmAvailableProvidersToken = "llmAvailableProvidersToken"
Expand Down Expand Up @@ -59,7 +59,7 @@ export const getLlmProviderKey = (providerName: string) =>
getAllProviderLlmKeys().find((item: LlmProvider) => item.title === providerName)?.key

export const getAllProviderLlmKeys = () => {
const providers = _.cloneDeep(llmAvailableProviders)
const providers = cloneDeep(llmAvailableProviders)
try {
if (typeof window !== "undefined") {
const providersInStorage: LlmProvider[] = JSON.parse(
Expand Down
20 changes: 16 additions & 4 deletions agenta-web/src/services/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ export async function callVariant(
return response
})
.catch(async (error) => {
console.log("Unsecure call to LLM App failed:", error?.status)
console.log("Unsecure call to LLM App failed:", error)

if (error?.response?.status !== 401) {
throw error
}

let response = await axios
.post(secure_url, requestBody, {
Expand All @@ -163,7 +167,9 @@ export async function callVariant(
return response
})
.catch((error) => {
console.log("Secure call to LLM App failed:", error?.status)
console.log("Secure call to LLM App failed:", error)

throw error
})

return response
Expand Down Expand Up @@ -200,7 +206,11 @@ export const fetchVariantParametersFromOpenAPI = async (
return response
})
.catch(async (error) => {
console.log("Unsecure call to LLM App failed:", error?.status)
console.log("Unsecure call to LLM App failed:", error)

if (error?.response?.status !== 401) {
throw error
}

let response = await axios
.get(secure_url, {
Expand All @@ -211,7 +221,9 @@ export const fetchVariantParametersFromOpenAPI = async (
return response
})
.catch((error) => {
console.log("Secure call to LLM App failed:", error?.status)
console.log("Secure call to LLM App failed:", error)

throw error
})

return response
Expand Down
Loading

0 comments on commit 22deb4a

Please sign in to comment.