Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Agenta-AI/agenta into feat/…
Browse files Browse the repository at this point in the history
…1789-save-variant-postions
  • Loading branch information
ashrafchowdury committed Jul 15, 2024
2 parents 06a1ed2 + 22221c3 commit 4cb45ed
Show file tree
Hide file tree
Showing 132 changed files with 7,775 additions and 3,812 deletions.
10 changes: 10 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@
"bug",
"code"
]
},
{
"login": "jp-agenta",
"name": "jp-agenta",
"avatar_url": "https://avatars.githubusercontent.com/u/174311389?v=4",
"profile": "https://github.com/jp-agenta",
"contributions": [
"code",
"bug"
]
}
],
"contributorsPerLine": 7,
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-frontend-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
NEXT_PUBLIC_OPENAI_API_KEY: ${{ secrets.NEXT_PUBLIC_OPENAI_API_KEY }}
run: |
sudo apt install curl -y
docker-compose -f "docker-compose.test.yml" up -d --build
OPENAI_API_KEY=${{ secrets.NEXT_PUBLIC_OPENAI_API_KEY }} ENVIRONMENT=github docker-compose -f "docker-compose.test.yml" up -d --build
- name: Restart Backend Service To Fetch Template(s)
run: docker container restart agenta-backend-test
Expand Down
70 changes: 42 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
<div align="center" style="margin: 30px">
<a href="https://docs.agenta.ai/self-host/migration/migration-to-postgres">
Important: We are migrating from MongoDB to PostgreSQL in v0.19! Follow this guide to migrate your data.
</a>
</div>
</br>
</br>

<div align="center" style="margin: 30px">
<div>
<a href="https://agentaai.notion.site/Careers-at-agenta-fb8a76d4d9044e27bd3a32678818dbc8/">
<img src="https://github.com/Agenta-AI/agenta/raw/main/.github/images/we-are-hiring.svg" alt="We are hiring! Join our team!" width="350" height="60" alt="We are hiring! Join our team!" width="350" height="60">
</a>
</a>
</div>

<a href="https://agenta.ai/">
<div align="center" >
<picture >
Expand Down Expand Up @@ -42,7 +51,6 @@
</br>
</p>


<p align="center">
<a href="https://join.slack.com/t/agenta-hq/shared_invite/zt-1zsafop5i-Y7~ZySbhRZvKVPV5DO_7IA">
<img src="https://img.shields.io/badge/JOIN US ON SLACK-4A154B?style=for-the-badge&logo=slack&logoColor=white" />
Expand All @@ -55,7 +63,6 @@
</a>
</p>


</br>

<a href="https://cloud.agenta.ai">
Expand All @@ -64,7 +71,6 @@
</picture>
</a>


<br>
<br />
<br />
Expand Down Expand Up @@ -96,54 +102,58 @@

# ⭐️ Why Agenta?

Agenta is an end-to-end LLM developer platform. It provides the tools for **prompt engineering and management**, ⚖️ **evaluation**, **human annotation**, and :rocket: **deployment**. All without imposing any restrictions on your choice of framework, library, or model.
Agenta is an end-to-end LLM developer platform. It provides the tools for **prompt engineering and management**, ⚖️ **evaluation**, **human annotation**, and :rocket: **deployment**. All without imposing any restrictions on your choice of framework, library, or model.

Agenta allows developers and product teams to collaborate in building production-grade LLM-powered applications in less time.
Agenta allows developers and product teams to collaborate in building production-grade LLM-powered applications in less time.

### With Agenta, you can:

- [🧪 **Experiment** and **compare** prompts](https://docs.agenta.ai/basic_guides/prompt_engineering) on [any LLM workflow](https://docs.agenta.ai/advanced_guides/custom_applications) (chain-of-prompts, Retrieval Augmented Generation (RAG), LLM agents...)
- ✍️ Collect and [**annotate golden test sets**](https://docs.agenta.ai/basic_guides/test_sets) for evaluation
- 📈 [**Evaluate** your application](https://docs.agenta.ai/basic_guides/automatic_evaluation) with pre-existing or [**custom evaluators**](https://docs.agenta.ai/advanced_guides/using_custom_evaluators)
- [🔍 **Annotate** and **A/B test**](https://docs.agenta.aibasic_guides/human_evaluation) your applications with **human feedback**
- [🤝 **Collaborate with product teams**](https://docs.agenta.ai/basic_guides/team_management) for prompt engineering and evaluation
- [🚀 **Deploy your application**](https://docs.agenta.ai/basic_guides/deployment) in one-click in the UI, through CLI, or through github workflows.
- [🧪 **Experiment** and **compare** prompts](https://docs.agenta.ai/prompt_management/prompt_engineering) on [any LLM workflow](https://docs.agenta.ai/prompt_management/custom_applications) (chain-of-prompts, Retrieval Augmented Generation (RAG), LLM agents...)
- ✍️ Collect and [**annotate golden test sets**](https://docs.agenta.ai/evaluation/test_sets) for evaluation
- 📈 [**Evaluate** your application](https://docs.agenta.ai/evaluation/automatic_evaluation) with pre-existing or [**custom evaluators**](https://docs.agenta.ai/evaluation/custom_evaluator)
- [🔍 **Annotate** and **A/B test**](https://docs.agenta.ai/evaluation/human_evaluation) your applications with **human feedback**
- [🤝 **Collaborate with product teams**](https://docs.agenta.ai/misc/team_management) for prompt engineering and evaluation
- [🚀 **Deploy your application**](https://docs.agenta.ai/prompt_management/deployment) in one-click in the UI, through CLI, or through github workflows.

### Works with any LLM app workflow

Agenta enables prompt engineering and evaluation on any LLM app architecture:

- Chain of prompts
- RAG
- Agents
- ...

It works with any framework such as [Langchain](https://langchain.com), [LlamaIndex](https://www.llamaindex.ai/) and any LLM provider (openAI, Cohere, Mistral).

[Jump here to see how to use your own custom application with agenta](/advanced_guides/custom_applications)
It works with any framework such as [Langchain](https://langchain.com), [LlamaIndex](https://www.llamaindex.ai/) and any LLM provider (openAI, Cohere, Mistral).

# Quick Start

### [Get started for free](https://cloud.agenta.ai?utm_source=github&utm_medium=readme&utm_campaign=github)
### [Explore the Docs](https://docs.agenta.ai)
### [Create your first application in one-minute](https://docs.agenta.ai/quickstart/getting-started-ui)
### [Create an application using Langchain](https://docs.agenta.ai/tutorials/first-app-with-langchain)

### [Explore the Docs](https://docs.agenta.ai/getting_started/introduction)

### [Create your first application in one-minute](https://docs.agenta.ai/getting_started/quick-start)

### [Create an application using Langchain](https://docs.agenta.ai/guides/tutorials/first-app-with-langchain)

### [Self-host agenta](https://docs.agenta.ai/self-host/host-locally)
### [Check the Cookbook](https://docs.agenta.ai/cookbook)

# Features
### [Check the Cookbook](https://docs.agenta.ai/guides/evaluation_from_sdk)

# Features

| Playground | Evaluation |
| ------- | ------- |
| Compare and version prompts for any LLM app, from single prompt to agents. <br/> <video src="https://github.com/Agenta-AI/agenta/assets/4510758/8b736d2b-7c61-414c-b534-d95efc69134c" controls="controls" style="max-width:100%;"> | Define test sets, then evaluate manually or programmatically your different variants.<br/> <video src="https://github.com/Agenta-AI/agenta/assets/4510758/8c6997c6-da87-46ad-a81f-e15e277263d2" controls="controls" style="max-width:100%;">|
| Human annotation | Deployment |
| Use Human annotator to A/B test and score your LLM apps. <br/> <img width="750" alt="Screenshot 2024-01-28 at 12 57 46" src="https://github.com/Agenta-AI/agenta/assets/4510758/bf62a697-bf19-4ba9-850e-742fbfb75424"> | When you are ready, deploy your LLM applications as APIs in one click.<br/>![](https://github.com/Agenta-AI/agenta/blob/main/docs/images/endpoint.gif) |
| Playground | Evaluation |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Compare and version prompts for any LLM app, from single prompt to agents. <br/> <video src="https://github.com/Agenta-AI/agenta/assets/4510758/8b736d2b-7c61-414c-b534-d95efc69134c" controls="controls" style="max-width:100%;"> | Define test sets, then evaluate manually or programmatically your different variants.<br/> <video src="https://github.com/Agenta-AI/agenta/assets/4510758/8c6997c6-da87-46ad-a81f-e15e277263d2" controls="controls" style="max-width:100%;"> |
| Human annotation | Deployment |
| Use Human annotator to A/B test and score your LLM apps. <br/> <img width="750" alt="Screenshot 2024-01-28 at 12 57 46" src="https://github.com/Agenta-AI/agenta/assets/4510758/bf62a697-bf19-4ba9-850e-742fbfb75424"> | When you are ready, deploy your LLM applications as APIs in one click.<br/>![](https://github.com/Agenta-AI/agenta/blob/main/docs/images/endpoint.gif) |

# Enterprise Support

Contact us here for enterprise support and early access to agenta self-managed enterprise with Kubernetes support. <br/><br/>
<a href="https://cal.com/mahmoud-mabrouk-ogzgey/demo"><img src="https://cal.com/book-with-cal-dark.svg" alt="Book us"></a>

# Disabling Anonymized Tracking

By default, Agenta automatically reports anonymized basic usage statistics. This helps us understand how Agenta is used and track its overall usage and growth. This data does not include any sensitive information.

To disable anonymized telemetry, follow these steps:
Expand All @@ -154,6 +164,7 @@ To disable anonymized telemetry, follow these steps:
After making this change, restart Agenta Compose.

# ⭐️ Join Our Team

- [Founding Lead Software Engineer Backend](https://agentaai.notion.site/Founding-Lead-Software-Engineer-Backend-d70bfefed6d543778bc4aa38b543a678)
- [Founding Product Engineer Frontend](https://agentaai.notion.site/Founding-Product-Engineer-Frontend-b6d26a3e9b254be6b6c2bfffbf0b53c5)
- [Founding Product Designer](https://agentaai.notion.site/Founding-Product-Designer-96b1e760ff0241fd96632578d533a778)
Expand All @@ -164,12 +175,14 @@ We warmly welcome contributions to Agenta. Feel free to submit issues, fork the

We are usually hanging in our Slack. Feel free to [join our Slack and ask us anything](https://join.slack.com/t/agenta-hq/shared_invite/zt-1zsafop5i-Y7~ZySbhRZvKVPV5DO_7IA)

Check out our [Contributing Guide](https://docs.agenta.ai/contributing/getting-started) for more information.
Check out our [Contributing Guide](https://docs.agenta.ai/misc/contributing/getting-started) for more information.

## Contributors ✨

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-46-orange.svg?style=flat-square)](#contributors-)

[![All Contributors](https://img.shields.io/badge/all_contributors-47-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 @@ -238,6 +251,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/youcefs21"><img src="https://avatars.githubusercontent.com/u/34604972?v=4?s=100" width="100px;" alt="Youcef Boumar"/><br /><sub><b>Youcef Boumar</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/commits?author=youcefs21" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/LucasTrg"><img src="https://avatars.githubusercontent.com/u/47852577?v=4?s=100" width="100px;" alt="LucasTrg"/><br /><sub><b>LucasTrg</b></sub></a><br /><a href="https://github.com/Agenta-AI/agenta/commits?author=LucasTrg" title="Code">💻</a> <a href="https://github.com/Agenta-AI/agenta/issues?q=author%3ALucasTrg" title="Bug reports">🐛</a></td>
<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>
</tr>
</tbody>
</table>
Expand Down
1 change: 1 addition & 0 deletions agenta-backend/agenta_backend/celery_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
CELERY_ACCEPT_CONTENT = ["json"]
CELERY_RESULT_SERIALIZER = "json"
CELERY_TIMEZONE = "UTC"
CELERY_TASK_TRACK_STARTED = True

CELERY_QUEUES = (
Queue(
Expand Down
6 changes: 4 additions & 2 deletions agenta-backend/agenta_backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
health_router,
)
from agenta_backend.utils.common import isEE, isCloudProd, isCloudDev, isOss, isCloudEE
from agenta_backend.models.db_engine import DBEngine
from agenta_backend.models.db_engine import db_engine
from agenta_backend.open_api import open_api_tags_metadata

if isEE() or isCloudProd():
Expand Down Expand Up @@ -52,9 +52,11 @@ async def lifespan(application: FastAPI, cache=True):
application: FastAPI application.
cache: A boolean value that indicates whether to use the cached data or not.
"""
await DBEngine().init_db()

await db_engine.init_db()
await templates_manager.update_and_sync_templates(cache=cache)
yield
await db_engine.close()


app = FastAPI(lifespan=lifespan, openapi_tags=open_api_tags_metadata)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Migration steps are detailed here:
https://docs.agenta.ai/self-host/migration/migration-to-postgres
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import os
import logging
from asyncio import current_task
from typing import AsyncGenerator
from contextlib import asynccontextmanager

from sqlalchemy.ext.asyncio import (
AsyncSession,
create_async_engine,
async_sessionmaker,
async_scoped_session,
)

from agenta_backend.utils.common import isCloudEE

if isCloudEE():
from agenta_backend.commons.observability.models.db import SpanDB
from agenta_backend.commons.models.db_models import (
APIKeyDB,
WorkspaceDB,
OrganizationDB,
AppDB_ as AppDB,
UserDB_ as UserDB,
ImageDB_ as ImageDB,
TestSetDB_ as TestSetDB,
AppVariantDB_ as AppVariantDB,
EvaluationDB_ as EvaluationDB,
DeploymentDB_ as DeploymentDB,
VariantBaseDB_ as VariantBaseDB,
AppEnvironmentDB_ as AppEnvironmentDB,
AppEnvironmentRevisionDB_ as AppEnvironmentRevisionDB,
EvaluatorConfigDB_ as EvaluatorConfigDB,
HumanEvaluationDB_ as HumanEvaluationDB,
EvaluationScenarioDB_ as EvaluationScenarioDB,
HumanEvaluationScenarioDB_ as HumanEvaluationScenarioDB,
)
else:
from agenta_backend.models.db_models import (
AppDB,
UserDB,
ImageDB,
TestSetDB,
EvaluationDB,
DeploymentDB,
AppVariantDB,
VariantBaseDB,
AppEnvironmentDB,
AppEnvironmentRevisionDB,
EvaluatorConfigDB,
HumanEvaluationDB,
EvaluationScenarioDB,
HumanEvaluationScenarioDB,
)

from agenta_backend.models.db_models import (
TemplateDB,
AppVariantRevisionsDB,
)

models = [
AppDB,
UserDB,
ImageDB,
TestSetDB,
TemplateDB,
AppVariantDB,
DeploymentDB,
EvaluationDB,
VariantBaseDB,
AppEnvironmentDB,
AppEnvironmentRevisionDB,
EvaluatorConfigDB,
HumanEvaluationDB,
EvaluationScenarioDB,
AppVariantRevisionsDB,
HumanEvaluationScenarioDB,
]

if isCloudEE():
models.extend([OrganizationDB, WorkspaceDB, APIKeyDB]) # type: ignore


# Configure and set logging level
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


class DBEngine:
"""
Database engine to initialize SQLAlchemy and return the engine based on mode.
"""

def __init__(self) -> None:
self.mode = os.environ.get("DATABASE_MODE", "v2")
self.db_url = f"{os.environ.get('POSTGRES_URI')}"
self.engine = create_async_engine(url=self.db_url)
self.async_session_maker = async_sessionmaker(
bind=self.engine, class_=AsyncSession, expire_on_commit=False
)
self.async_session = async_scoped_session(
session_factory=self.async_session_maker, scopefunc=current_task
)

async def init_db(self):
"""
Initialize the database based on the mode and create all tables.
"""
async with self.engine.begin() as conn:
# Create tables
for model in models:
await conn.run_sync(model.metadata.create_all)
logger.info(f"Using {self.mode} database...")

@asynccontextmanager
async def get_session(self) -> AsyncGenerator[AsyncSession, None]:
session = self.async_session()
try:
yield session
except Exception as e:
await session.rollback()
raise e
finally:
await session.close()

async def close(self):
"""
Closes and dispose all the connections using the engine.
:raises Exception: if engine is initialized
"""

if self.engine is None:
raise Exception("DBEngine is not initialized")

await self.engine.dispose()

self.engine = None
self.async_session_maker = None
self.async_session = None


db_engine = DBEngine()
Loading

0 comments on commit 4cb45ed

Please sign in to comment.