-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
51 deletions.
There are no files selected for viewing
12 changes: 7 additions & 5 deletions
12
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,6 +1,8 @@ | ||
export default function cURLCode(uri: string, config_url: string, params: string): string { | ||
return `curl -X POST ${uri} \ | ||
-H "Content-Type: application/json" \ | ||
-d '${params}' | ||
` | ||
export default function cURLCode(baseId: string, env_name: string): string { | ||
return ` | ||
curl -X GET "https://cloud.agenta.ai/api/configs?base_id=${baseId}&environment_name=${env_name}" \ | ||
-H "Authorization: Bearer YOUR_API_KEY" \ | ||
-H "Content-Type: application/json" \ | ||
--connect-timeout 60 | ||
` | ||
} |
25 changes: 7 additions & 18 deletions
25
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,21 +1,10 @@ | ||
export default function pythonCode(uri: string, config_url: string, params: string): string { | ||
export default function pythonCode(baseId: string, env_name: string): string { | ||
return ` | ||
import requests | ||
import json | ||
# os.environ["AGENTA_API_KEY"] = "your_api_key" # Only when using cloud | ||
# os.environ["HOST"] = "https://cloud.agenta.ai" | ||
url = "${uri}" | ||
config_url = "${config_url}" | ||
config_response = requests.get(config_url) | ||
config_data = config_response.json() | ||
params = ${params} | ||
params.update(config_data) | ||
response = requests.post(url, json=params) | ||
data = response.json() | ||
print(json.dumps(data, indent=4)) | ||
` | ||
from agenta import Agenta | ||
ag = Agenta() | ||
ag.get_config(base_id="${baseId}", environment="${env_name}", cache_timeout=600) # timeout 300 per default | ||
` | ||
} |
49 changes: 37 additions & 12 deletions
49
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