-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2292 from Agenta-AI/AGE-1332/fix-prompt-fetching-…
…code fix(frontend): prompt fetching code
- Loading branch information
Showing
4 changed files
with
65 additions
and
54 deletions.
There are no files selected for viewing
25 changes: 18 additions & 7 deletions
25
agenta-web/src/code_snippets/endpoints/fetch_config/curl.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
agenta-web/src/code_snippets/endpoints/fetch_config/python.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
64
agenta-web/src/code_snippets/endpoints/fetch_config/typescript.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters