Skip to content

Commit

Permalink
Merge pull request #62 from Significant-Gravitas/ntindle/agpt-400-upd…
Browse files Browse the repository at this point in the history
…ate-post-spec-to-schedule-a-background-task-for

[Needed for Discord bot] Segment Interview and Spec Generation
  • Loading branch information
ntindle authored Mar 1, 2024
2 parents 525ce40 + ef0e2cc commit 10da924
Show file tree
Hide file tree
Showing 27 changed files with 1,302 additions and 301 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

The Codex System is an innovative coding agent designed to streamline the software development process. It consists of four key sub-agents, each specialized in a different aspect of software development. These sub-agents work in harmony to ensure efficient and effective delivery of software applications. This README provides an overview of the Codex System and its components.


## Getting Started

Welcome to the initial setup guide for your project. Follow these easy steps to get everything up and running.
Expand Down Expand Up @@ -167,26 +166,26 @@ sequenceDiagram
User->>API: Modifies App Spec Element
API->>User: Returns a new App Spec ID
end
User->>API: Request App Spec ID is Developed
API->>+Codex: Runs Architect and Develop Flow
Codex->>-User: Returns Developed App ID
User->>API: Requests Deveoped App ID is deployed
Note right of API: When we have added deployment flow
API->>+Codex: Runs Deployment Flow
Codex-->>-User: Returns Deployment details (id, url etc)
User->>API: Requests Code for Developed App ID
Note right of API: During Beta
API->>+Codex: Runs Package flow
Codex-->>-User: Returns Zipfile
```

## Workflow
Expand All @@ -199,7 +198,6 @@ sequenceDiagram

4. **Deployment**: Once the coding is complete, the Deploy sub-agent takes over to package, compile, and deploy the application to the desired environment.


```mermaid
sequenceDiagram
participant User
Expand All @@ -221,14 +219,12 @@ sequenceDiagram
Deploy->>+User: Deploy to Production
```


## Database Schema
## Database Schema

<p align="center">
<img src="docs/mermaid.png" alt="Mermaid Diagram of Schema" style="border-radius: 50px;" width="600">
</p>


The schema revolves around key models:

- CodeGraph: Represents the logic and structure of code as graphs, linked to function definitions and database schemas.
Expand Down Expand Up @@ -333,9 +329,9 @@ erDiagram
}
```

## Useful commands
> docker buildx build --platform linux/amd64 -t gcr.io/agpt-dev/mvp/codegen . --push
## Useful commands

> docker buildx build --platform linux/amd64 -t gcr.io/agpt-dev/mvp/codegen . --push
## Prisma with Python: Quick Setup and Usage Guide

Expand All @@ -344,18 +340,21 @@ Prisma is an open-source database toolkit that simplifies database access and ma
### 1. Setting Up Prisma

#### Prerequisites:

- Node.js installed (for Prisma CLI)
- Python environment setup

#### Steps:

1. **Install Prisma CLI**:

- Use npm to install Prisma globally:
```bash
npm install -g prisma
```

2. **Initialize Prisma in Your Project**:

- Navigate to your Python project directory and initialize Prisma:
```bash
prisma init
Expand Down Expand Up @@ -410,6 +409,7 @@ Prisma is an open-source database toolkit that simplifies database access and ma
### 5. Using Prisma with Python

- Since Prisma Client is native to JavaScript/TypeScript, using it in Python requires a workaround. You can execute Prisma Client through a child process. For example:

```python
import subprocess
import json
Expand All @@ -435,4 +435,4 @@ Prisma is an open-source database toolkit that simplifies database access and ma

### Conclusion

This cheat sheet covers the basics of setting up Prisma in a Python project and performing essential database operations. Remember that using Prisma with Python is less straightforward than with JavaScript/TypeScript, and it may require additional setup and handling. For more detailed information, refer to the [Prisma Documentation](https://www.prisma.io/docs/).
This cheat sheet covers the basics of setting up Prisma in a Python project and performing essential database operations. Remember that using Prisma with Python is less straightforward than with JavaScript/TypeScript, and it may require additional setup and handling. For more detailed information, refer to the [Prisma Documentation](https://www.prisma.io/docs/).
26 changes: 25 additions & 1 deletion codex/api_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
from typing import List, Optional

from prisma.enums import Role
from prisma.models import Specification
from prisma.models import Question, Specification
from pydantic import BaseModel, Field

from codex.interview.model import InterviewMessage, InterviewMessageWithResponse

logger = logging.getLogger(__name__)


class Identifiers(BaseModel):
user_id: str
cloud_services_id: str
app_id: str
interview_id: str | None = None
spec_id: str | None = None
completed_app_id: str | None = None
deployment_id: str | None = None
Expand Down Expand Up @@ -80,6 +84,7 @@ class ApplicationResponse(BaseModel):
updatedAt: datetime
name: str
userid: str
cloud_services_id: str


class ApplicationsListResponse(BaseModel):
Expand Down Expand Up @@ -124,6 +129,25 @@ class APIRouteSpecModel(BaseModel):
responseObject: Optional[ResponseObjectModel] = None


class InterviewCreate(BaseModel):
name: str
task: str


class InterviewResponse(BaseModel):
id: str = Field(..., description="The unique identifier of the interview")
finished: bool = Field(bool, description="Whether the interview is finished")
uses: List[Question] = Field(
..., description="The list of messages in the interview"
)


class InterviewNextCreate(BaseModel):
uses: List[InterviewMessageWithResponse] = Field(
..., description="The list of messages in the interview"
)


class SpecificationCreate(BaseModel):
description: str

Expand Down
2 changes: 2 additions & 0 deletions codex/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from codex.api import core_routes
from codex.deploy.routes import deployment_router
from codex.develop.routes import delivery_router
from codex.interview.routes import interview_router
from codex.requirements.routes import spec_router

logger = logging.getLogger(__name__)
Expand All @@ -23,6 +24,7 @@


app.include_router(core_routes, prefix="/api/v1")
app.include_router(interview_router, prefix="/api/v1")
app.include_router(spec_router, prefix="/api/v1")
app.include_router(delivery_router, prefix="/api/v1")
app.include_router(deployment_router, prefix="/api/v1")
Expand Down
12 changes: 10 additions & 2 deletions codex/common/ai_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import os
import pathlib
from typing import Any
from typing import Any, Callable, Optional, Type

from jinja2 import Environment, FileSystemLoader
from openai import AsyncOpenAI
Expand All @@ -11,7 +11,7 @@
from prisma.enums import DevelopmentPhase
from prisma.fields import Json
from prisma.models import LLMCallAttempt, LLMCallTemplate
from pydantic import BaseModel
from pydantic import BaseModel, ConfigDict

from codex.api_model import Identifiers
from codex.common.ai_model import OpenAIChatClient
Expand Down Expand Up @@ -393,3 +393,11 @@ async def list_items(self, query_params: dict):
query_params (dict): _description_
"""
raise NotImplementedError("List Items Method not implemented")


class Tool(BaseModel):
model_config = ConfigDict(arbitrary_types_allowed=True)
name: str
description: str
func: Optional[Callable[..., str]] = None
block: Type[AIBlock]
31 changes: 29 additions & 2 deletions codex/common/test_const.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

user_id_1 = "123e4567-e89b-12d3-a456-426614174000"
user_id_2 = "456e7890-f12b-23d4-b567-537625285000"
user_id_3 = "789a1234-c56d-67e8-c901-637636396000"

discord_id_1 = "698489167281127474"
discord_id_2 = "1188760123011776594"
discord_id_3 = "1113853244066779156"

cloud_services_id_1 = "9c7c6f29-c15e-40c9-afb3-c2c94f621a5c"
cloud_services_id_2 = "78f3b489-e99e-4e50-a3aa-e78f8ad9b5b2"
cloud_services_id_3 = "44286240-d819-4c57-beef-0bc815ca1934"

app_id_1 = "789e0123-g34c-45d6-e789-012345678900"
app_id_2 = "901f2345-h56i-67j8-k901-l23456789000"
Expand All @@ -17,6 +26,24 @@
app_id_12 = "901p2345-r67s-78t9-u012-v34567890100"
app_id_13 = "012q3456-s78t-89u0-v123-w45678901200"

interview_id_1 = "d5cf71f4-068c-44aa-97c1-db864526d0cf"
interview_id_2 = "24fefb91-5eae-472e-ab15-0c1ad158bea3"
interview_id_3 = "51de45a0-d00d-40c6-9494-fc0941288a55"
interview_id_4 = "571c30fc-5b22-4da5-8558-9b98e6da4dd2"
interview_id_5 = "6aecf5eb-ea4c-4ba7-96d7-8847a41af480"
interview_id_6 = "d1f0fba7-15e9-41a3-83e2-093d1f64138a"
interview_id_7 = "e5c3386d-814c-4108-b09c-10e807238c8a"
interview_id_8 = "11d9607e-3638-48c5-baac-6f0f9d96fb42"
interview_id_9 = "2b5ccea7-347b-4940-bfe6-ae999fe874fc"
interview_id_10 = "400a8c69-f448-4481-a996-134abb9fa1c0"
interview_id_11 = "a0248eaf-3cac-4c9a-8757-fdda9e840a7c"
interview_id_12 = "daf074f4-eac9-40c6-a6dd-f928aa6717ab"
interview_id_13 = "b2ca05ca-3a41-4a89-9afd-7bd48eb170bd"


identifier_1 = Identifiers(user_id=user_id_1, app_id=app_id_1)
identifier_2 = Identifiers(user_id=user_id_2, app_id=app_id_2)
identifier_1 = Identifiers(
user_id=user_id_1, app_id=app_id_1, cloud_services_id=cloud_services_id_1
)
identifier_2 = Identifiers(
user_id=user_id_2, app_id=app_id_2, cloud_services_id=cloud_services_id_2
)
Loading

0 comments on commit 10da924

Please sign in to comment.