Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into v1/observability-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
mmabrouk committed Apr 14, 2024
2 parents 210d8c3 + 4dc9c00 commit 56b24a0
Show file tree
Hide file tree
Showing 52 changed files with 697 additions and 207 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,15 @@
"contributions": [
"code"
]
},
{
"login": "eltociear",
"name": "Ikko Eltociear Ashimine",
"avatar_url": "https://avatars.githubusercontent.com/u/22633385?v=4",
"profile": "https://speakerdeck.com/eltociear",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bump-versions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Bump versions
name: "🆙 Bump versions"

on:
workflow_dispatch:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/publish-prerelease-to-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Publish a PRE-RELEASE PyPI

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to publish'
required: true
default: 'main'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.9

- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
- name: Check for agenta version changes
id: version_check
run: |
cd ${{ github.workspace }}/agenta-cli
# Verify that the pyproject.toml file exists
if [ ! -f pyproject.toml ]; then
echo "pyproject.toml file not found. Exiting..."
exit 1
fi
previous_version=$(git describe --abbrev=0 --tags)
current_version=$(poetry version --no-interaction | awk '{print $2}')
if [ "$previous_version" == "$current_version" ]; then
echo "No version change detected. Skipping package publication."
exit 78
fi
if [[ "$current_version" != *a* ]] && [[ "$current_version" != *b* ]]; then
echo "Current version is not an alpha or beta release. Skipping package publication."
exit 78
fi
echo "::set-output name=version_bumped::true"
continue-on-error: true

- name: Build and publish agenta to PyPI
if: steps.version_check.outputs.version_bumped == 'true'
run: |
# Navigate to the cli directory
cd ${{ github.workspace }}
# Build and publish agenta-cli
cd agenta-cli
poetry build
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
continue-on-error: true
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Check out our [Contributing Guide](https://docs.agenta.ai/contributing/getting-s
## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-41-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-42-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 @@ -221,6 +221,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center" valign="top" width="14.28%"><a href="https://github.com/romainrbr"><img src="https://avatars.githubusercontent.com/u/10381609?v=4?s=100" width="100px;" alt="Romain Brucker"/><br /><sub><b>Romain Brucker</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/commits?author=romainrbr" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="http://heonheo.com"><img src="https://avatars.githubusercontent.com/u/76820291?v=4?s=100" width="100px;" alt="Heon Heo"/><br /><sub><b>Heon Heo</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/commits?author=HeonHeo23" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Drewski2222"><img src="https://avatars.githubusercontent.com/u/39228951?v=4?s=100" width="100px;" alt="Drew Reisner"/><br /><sub><b>Drew Reisner</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/commits?author=Drewski2222" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://speakerdeck.com/eltociear"><img src="https://avatars.githubusercontent.com/u/22633385?v=4?s=100" width="100px;" alt="Ikko Eltociear Ashimine"/><br /><sub><b>Ikko Eltociear Ashimine</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/commits?author=eltociear" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
Expand Down
4 changes: 0 additions & 4 deletions agenta-backend/agenta_backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
os.environ["REGISTRY"] = toml_config["registry"]
os.environ["DATABASE_URL"] = toml_config["database_url"]
os.environ["DOCKER_HUB_URL"] = toml_config["docker_hub_url"]
os.environ["DOCKER_HUB_REPO_OWNER"] = toml_config["docker_hub_repo_owner"]
os.environ["DOCKER_HUB_REPO_NAME"] = toml_config["docker_hub_repo_name"]
os.environ["DATABASE_MODE"] = os.environ.get("DATABASE_MODE", "v2")


Expand All @@ -22,8 +20,6 @@ class Settings(BaseSettings):
registry: str
database_url: str
docker_hub_url: str
docker_hub_repo_owner: str
docker_hub_repo_name: str


settings = Settings()
4 changes: 1 addition & 3 deletions agenta-backend/agenta_backend/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
docker_registry_url="registry:5001"
registry="agentaai"
database_url="sqlite:////db/deploy.db"
docker_hub_url="https://hub.docker.com/v2/repositories/{}/{}"
docker_hub_repo_owner="agentaai"
docker_hub_repo_name="templates_v2"
docker_hub_url="https://hub.docker.com/v2/repositories"
2 changes: 2 additions & 0 deletions agenta-backend/agenta_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"http://0.0.0.0:3001",
]


celery_app = Celery("agenta_app")
celery_app.config_from_object(celery_config)

Expand All @@ -64,6 +65,7 @@ async def lifespan(application: FastAPI, cache=True):
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_origin_regex="https://.*\.vercel\.app",
allow_credentials=True,
allow_methods=["*"],
allow_headers=allow_headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"prompt_template": {
"label": "Prompt Template",
"type": "text",
"default": "We have an LLM App that we want to evaluate its outputs. Based on the prompt and the parameters provided below evaluate the output based on the evaluation strategy below: Evaluation strategy: 0 to 10 0 is very bad and 10 is very good. Prompt: {llm_app_prompt_template} Inputs: country: {country} Correct Answer:{correct_answer} Evaluate this: {variant_output} Answer ONLY with one of the given grading or evaluation options.",
"default": "We have an LLM App that we want to evaluate its outputs. Based on the prompt and the parameters provided below evaluate the output based on the evaluation strategy below:\nEvaluation strategy: 0 to 10 0 is very bad and 10 is very good.\nPrompt: {llm_app_prompt_template}\nInputs: country: {country}\nCorrect Answer:{correct_answer}\nEvaluate this: {variant_output}\n\nAnswer ONLY with one of the given grading or evaluation options.",
"description": "Template for AI critique prompts",
"required": True,
}
Expand Down Expand Up @@ -253,7 +253,7 @@

def get_all_evaluators():
"""
Returns a list of evaluators.
Returns a list of evaluators
Returns:
List[dict]: A list of evaluator dictionaries.
Expand Down
24 changes: 16 additions & 8 deletions agenta-backend/agenta_backend/routers/app_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,16 +565,24 @@ async def create_app_and_variant_from_template(
else "Step 7: Starting variant and injecting environment variables"
)
if isCloudEE():
if not os.environ["OPENAI_API_KEY"]:
supported_llm_prodviders_keys = [
"OPENAI_API_KEY",
"MISTRAL_API_KEY",
"COHERE_API_KEY",
]
missing_keys = [
key for key in supported_llm_prodviders_keys if not os.environ.get(key)
]
if missing_keys:
missing_keys_str = ", ".join(missing_keys)
raise Exception(
"Unable to start app container. Please file an issue by clicking on the button below.",
f"Unable to start app container. The following environment variables are missing: {missing_keys_str}. Please file an issue by clicking on the button below."
)
envvars = {
**(payload.env_vars or {}),
"OPENAI_API_KEY": os.environ[
"OPENAI_API_KEY"
], # order is important here
}

envvars = {**(payload.env_vars or {})}
for key in supported_llm_prodviders_keys:
if os.environ.get(key):
envvars[key] = os.environ[key]
else:
envvars = {} if payload.env_vars is None else payload.env_vars
await app_manager.start_variant(app_variant_db, envvars)
Expand Down
17 changes: 5 additions & 12 deletions agenta-backend/agenta_backend/services/templates_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from agenta_backend.services import container_manager

templates_base_url = os.getenv("TEMPLATES_BASE_URL")
agenta_template_repo = os.getenv("AGENTA_TEMPLATE_REPO")

from typing import Union

Expand Down Expand Up @@ -61,13 +62,9 @@ async def update_and_sync_templates(cache: bool = True) -> None:
)
print(f"Template {template_id} added to the database.")

# Get docker hub config
repo_owner = settings.docker_hub_repo_owner
repo_name = settings.docker_hub_repo_name

# Pull image from DockerHub
image_res = await container_manager.pull_docker_image(
repo_name=f"{repo_owner}/{repo_name}", tag=temp["name"]
repo_name=f"{agenta_template_repo}", tag=temp["name"]
)
print(f"Template Image {image_res[0]['id']} pulled from DockerHub.")

Expand All @@ -91,8 +88,7 @@ async def retrieve_templates_from_dockerhub_cached(cache: bool) -> List[dict]:
# If not cached, fetch data from Docker Hub and cache it in Redis
response = await retrieve_templates_from_dockerhub(
settings.docker_hub_url,
settings.docker_hub_repo_owner,
settings.docker_hub_repo_name,
agenta_template_repo,
)
response_data = response["results"]

Expand Down Expand Up @@ -131,7 +127,7 @@ async def retrieve_templates_info_from_s3(

@backoff.on_exception(backoff.expo, (ConnectError, CancelledError), max_tries=5)
async def retrieve_templates_from_dockerhub(
url: str, repo_owner: str, repo_name: str
url: str, repo_name: str
) -> Union[List[dict], dict]:
"""
Business logic to retrieve templates from DockerHub.
Expand All @@ -140,17 +136,14 @@ async def retrieve_templates_from_dockerhub(
url (str): The URL endpoint for retrieving templates. Should contain placeholders `{}`
for the `repo_owner` and `repo_name` values to be inserted. For example:
`https://hub.docker.com/v2/repositories/{}/{}/tags`.
repo_owner (str): The owner or organization of the repository from which templates are to be retrieved.
repo_name (str): The name of the repository where the templates are located.
Returns:
tuple: A tuple containing two values.
"""

async with httpx.AsyncClient() as client:
response = await client.get(
f"{url.format(repo_owner, repo_name)}/tags", timeout=10
)
response = await client.get(f"{url}/{repo_name}/tags", timeout=10)
if response.status_code == 200:
response_data = response.json()
return response_data
Expand Down
Loading

0 comments on commit 56b24a0

Please sign in to comment.