Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-agenta committed Nov 22, 2024
2 parents a6225ed + b8fb3a3 commit 0f0ead7
Show file tree
Hide file tree
Showing 107 changed files with 45,572 additions and 17,403 deletions.
25 changes: 18 additions & 7 deletions agenta-web/src/code_snippets/endpoints/fetch_config/curl.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
export default function cURLCode(baseId: string, env_name: string): string {
return `
curl -X GET "${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/configs?base_id=${baseId}&environment_name=${env_name}" \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H "Content-Type: application/json" \\
--connect-timeout 60
`
export default function cURLCode(appName: string, env_name: string): string {
return `curl -L '${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api/variants/configs/fetch' \\
-H "Authorization: Bearer YOUR_API_KEY" \\
-H 'Content-Type: application/json' \\
-H 'Accept: application/json' \\
-d '{
"environment_ref": {
"slug": "${env_name}",
"version": null,
"id": null
},
"application_ref": {
"slug": "${appName}",
"version": null,
"id": null
}
}'
`
}
22 changes: 13 additions & 9 deletions agenta-web/src/code_snippets/endpoints/fetch_config/python.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
export default function pythonCode(baseId: string, env_name: string): string {
export default function pythonCode(appName: string, env_name: string): string {
return `
# os.environ["AGENTA_API_KEY"] = "your_api_key" # Only when using cloud
# os.environ["AGENTA_HOST"] = "${process.env.NEXT_PUBLIC_AGENTA_API_URL}"
import os
import agenta as ag
from agenta import Agenta
ag = Agenta()
ag.get_config(base_id="${baseId}",
environment="${env_name}",
cache_timeout=600) # timeout 300 per default
`
os.environ["AGENTA_API_KEY"] = "your_api_key" # Only when using cloud
os.environ["AGENTA_HOST"] = "${process.env.NEXT_PUBLIC_AGENTA_API_URL}"
ag.init()
config = ag.ConfigManager.get_from_registry(
app_slug="${appName}",
environment_slug="${env_name}"
)
print(config)
`
}
64 changes: 29 additions & 35 deletions agenta-web/src/code_snippets/endpoints/fetch_config/typescript.ts
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
import {js as beautify} from "js-beautify"

export default function tsCode(baseId: string, env_name: string): string {
const codeString = `
import axios from 'axios';
export default function tsCode(appName: string, env_name: string): string {
const codeString = `import axios from 'axios';
const getConfig = async (baseId: string, environmentName: string) => {
try {
const baseUrl = '${process.env.NEXT_PUBLIC_AGENTA_API_URL}/api';
const params = {
base_id: baseId,
environment_name: environmentName
};
const getConfig = async (appName: string, environmentSlug: string) => {
const baseUrl = 'https://oss.agenta.ai/api/variants/configs/fetch';
const response = await axios.get(baseUrl + "/configs", {
params: params,
headers: {
'Authorization': "Bearer YOUR_API_KEY",
'Content-Type': 'application/json'
},
timeout: 60000
});
try {
const response = await axios.post(baseUrl, {
environment_ref: {
slug: environmentSlug,
version: null,
id: null,
},
application_ref: {
slug: appName,
version: null,
id: null,
},
}, {
headers: {
'Authorization': "Bearer YOUR_API_KEY",
'Content-Type': 'application/json',
'Accept': 'application/json',
},
});
if (response.status >= 200 && response.status < 300) {
return response.data;
} else if (response.status === 422) {
throw new Error(JSON.stringify(response.data));
}
} catch (error: any) {
if (error.response) {
console.error("API Error: " + error.response.status, error.response.data);
} else if (error.request) {
console.error('API Error: No response received', error.request);
} else {
console.error('Error', error.message);
}
throw error;
}
};
return response.data;
} catch {
throw new Error('Failed to fetch configuration.');
}
};
getConfig('${baseId}', '${env_name}').then(console.log).catch(console.error);
getConfig('demo', 'production').then(console.log).catch(console.error);
`

const formattedCodeString = beautify(codeString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {formatCurrency, formatLatency, formatTokenUsage} from "@/lib/helpers/for
import {getNodeById} from "@/lib/helpers/observability_helpers"
import {Filter, FilterConditions, JSSTheme} from "@/lib/Types"
import {_AgentaRootsResponse} from "@/services/observability/types"
import {SwapOutlined} from "@ant-design/icons"
import {ReloadOutlined, SwapOutlined} from "@ant-design/icons"
import {
Button,
Input,
Expand Down Expand Up @@ -71,6 +71,7 @@ const ObservabilityDashboard = () => {
setSort,
pagination,
setPagination,
fetchTraces,
} = useObservabilityData()
const appId = useAppId()
const router = useRouter()
Expand Down Expand Up @@ -250,6 +251,12 @@ const ObservabilityDashboard = () => {
}
}, [activeTrace, selected])

useEffect(() => {
const interval = setInterval(fetchTraces, 300000)

return () => clearInterval(interval)
}, [])

const selectedItem = useMemo(
() => (traces?.length ? getNodeById(traces, selected) : null),
[selected, traces],
Expand Down Expand Up @@ -480,6 +487,14 @@ const ObservabilityDashboard = () => {

<div className="flex justify-between gap-2 flex-col 2xl:flex-row 2xl:items-center">
<Space>
<Button
icon={<ReloadOutlined />}
onClick={() => {
fetchTraces()
}}
>
Reload
</Button>
<Input.Search
placeholder="Search"
value={searchQuery}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {isDemo} from "@/lib/helpers/utils"
import {dynamicComponent} from "@/lib/helpers/dynamic"
import VariantPopover from "../variants/VariantPopover"
import {getCurrentProject} from "@/contexts/project.context"
import {useAppsData} from "@/contexts/app.context"

const DeploymentHistoryModal: any = dynamicComponent(
"pages/overview/deployments/DeploymentHistoryModal",
Expand Down Expand Up @@ -125,6 +126,7 @@ const DeploymentDrawer = ({
const classes = useStyles()
const router = useRouter()
const appId = router.query.app_id as string
const {currentApp} = useAppsData()
const [selectedLang, setSelectedLang] = useState("python")
const [uri, setURI] = useState<string | null>(null)
const [variant, setVariant] = useState<Variant | null>(null)
Expand Down Expand Up @@ -167,9 +169,9 @@ const DeploymentDrawer = ({
}

const fetchConfigCodeSnippet: Record<string, string> = {
python: fetchConfigpythonCode(variant?.baseId!, selectedEnvironment?.name!),
bash: fetchConfigcURLCode(variant?.baseId!, selectedEnvironment?.name!),
typescript: fetchConfigtsCode(variant?.baseId!, selectedEnvironment?.name!),
python: fetchConfigpythonCode(currentApp?.app_name!, selectedEnvironment?.name!),
bash: fetchConfigcURLCode(currentApp?.app_name!, selectedEnvironment?.name!),
typescript: fetchConfigtsCode(currentApp?.app_name!, selectedEnvironment?.name!),
}

return (
Expand Down
30 changes: 27 additions & 3 deletions docs/docs/reference/api/accept-invitation.api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "Accept an invitation to a workspace."
sidebar_label: "Accept Workspace Invitation"
hide_title: true
hide_table_of_contents: true
api: eJztVsluIzcQ/RWCpwRQ1IoxuXQu8UwMjLPZsJUEgW0Ipe6SxHGL7JBsjzUN/XuqyF4ly1kQ5BQdbIosvlrfo2qZo8usKr0yWqbyPMuw9AK0UPpJeeBt4Y0A8dHYR1dChtN7fa9vQDl06b0W9Hk/n19fPPNFsk7FYgC5+Fo4QqncIjM5puKr2ezFO5e9N228WJlK58JYsQEn8LlUFvMDpDcnkH4zlYDCIuQ7scTC6DXH7zfKEd4atPoU3LyERmmhr6xu8/ru9uqnG3Sl0Y5MYmkwP6hMV5cDxLPZTE6kKdEG08ucqgsBYtEDkEUJFrbo0TqZ3tXS4u8VZytTbyucSJdtcAsyraXflUgYzlul13TRK1/wxpVdC0LfT6QmINqgNBcqJwvFHS3Bb+jwnyD/2qY2xu8yPvLyMAle0Pm3Jt8xdGa0R+15CWVZqCyknXxwPG31IIbScqm8QhciMo+oXwttHgz2FFRjYZYfMPNyMkjzroF56K+FMcP28n5yUJSwEfsdwuAe0r8xRW4r6qJzq6oQ7XCQ27+a6D64fXN2dgz8CxQqj3N1Ya2xfwP1oHw5elAFryjbrTs2KEw2OgW9u1qF+RsXnOem2VEUyRotNbkvOlgLu0FXfjAxQB6WrVu/1sAfqYSwRtmBnTYNxRBzPv2zhnNe0XVjN+h9X95Y3dNpfBvL95Kz1oRF5wgw9pbIvDHM9tI4HwhO1EhlMlQfl9SRpfukYxPtDZm1T4JMYBJFg4Ac2qdWJipL7ZUb70uXJklWmCqfUjm1hymoBEpF9gfKHk7FOzYNTHWYVVb5XcA7v778HnfvSTWpxendw9Dglqcszs3YrGsZ+aNt2SnEeUUlsE2urURs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uqbnGDXPfhjdE97sZPMXxPKesgPNcOCGNuaV4UhgdKZZwPM4T6N5XJcMC5pIlDZJNsW57Ohu2/ScIkwiTOJSJyaB+6SVRbSq8svK9cmiRZaep8ROHUHkagEqgU4feWR7gVbxkquVMdZrVVfh34zq4ufsH1OxrMlOL0djoE3HCVxbrZhW1TRvromFS2A+asphDY1tduxhRRikPE9XvdD4rzR1hVJQ4ava8/kl2YcNNGvvXjDWSE5AHGMYkujkevRuNjjrcCglxoGwuy0FidzQFGV7uh3QaVbqjXuKukR1j92F+wR5zrFeghX1zWgyE8XCw7JjZ9n/+/4194x7cV6vHRJ1UJKsymkOKm7cxbudOZJJNuF3zfnHx8sJ25P+mh7VBqmYJbnhibZg4O/7DlZsPHcb1yn+XKwbzkYbWA0uEzhfDNdTvXvhXH3Linntvb5g9Q1gwMHf4AVrG2l9fc9b1eD3V2FrXh4+XxFbXuZCdsqaIbZ00LeRu1fRd2SU9xsFrZ8ihx1g3f49jpYORfXd5MCDxv335WVIh0auEj7yn6DuaaKhYavx7xGa1j0Muat2EqIyd//gHVAiGb
sidebar_class_name: "post api-method"
info_path: reference/api/agenta-backend
custom_edit_url: null
Expand Down Expand Up @@ -77,12 +77,36 @@ Returns:
<ul>
<ParamsItem
className={"paramsItem"}
param={{"required":true,"schema":{"type":"string","title":"Org Id"},"name":"org_id","in":"path"}}
param={{"name":"org_id","in":"path","required":true,"schema":{"type":"string","title":"Org Id"}}}
>

</ParamsItem><ParamsItem
className={"paramsItem"}
param={{"required":true,"schema":{"type":"string","title":"Workspace Id"},"name":"workspace_id","in":"path"}}
param={{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","title":"Workspace Id"}}}
>

</ParamsItem>
</ul>
</div>
</details><details
style={{"marginBottom":"1rem"}}
className={"openapi-markdown__details"}
data-collapsed={false}
open={true}
>
<summary
style={{}}
>
<h3
className={"openapi-markdown__details-summary-header-params"}
>
Query Parameters
</h3>
</summary><div>
<ul>
<ParamsItem
className={"paramsItem"}
param={{"name":"project_id","in":"query","required":true,"schema":{"type":"string","title":"Project Id"}}}
>

</ParamsItem>
Expand Down
Loading

0 comments on commit 0f0ead7

Please sign in to comment.