Skip to content

Commit

Permalink
First iteration of tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
aarushik93 committed May 2, 2024
1 parent a34ce51 commit 3c3e026
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ PORT=8080

GIT_TOKEN=<your-github-token>

VERBOSE_LOGGING=true
VERBOSE_LOGGING=true
LANGCHAIN_PROJECT="codex-dev"
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=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
7 changes: 4 additions & 3 deletions codex/deploy/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
from codex.develop.compile import create_bundle_code
from codex.deploy.infrastructure import create_cloud_db
from codex.deploy.model import Settings
from langsmith import traceable

logger = logging.getLogger(__name__)


@traceable
async def create_deployment(
ids: Identifiers,
completedApp: CompletedApp,
Expand All @@ -27,7 +28,7 @@ async def create_deployment(
deployment = await create_cloud_deployment(ids, completedApp, spec, settings)
return deployment


@traceable
async def create_local_deployment(
ids: Identifiers, completedApp: CompletedApp, spec: Specification
) -> Deployment:
Expand Down Expand Up @@ -65,7 +66,7 @@ async def create_local_deployment(
raise ValueError(f"Error creating deployment in database: {e}")
return deployment


@traceable
async def create_cloud_deployment(
ids: Identifiers,
completedApp: CompletedApp,
Expand Down
11 changes: 6 additions & 5 deletions codex/develop/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@
from codex.develop.function import construct_function, generate_object_template
from codex.requirements.blocks.ai_page_decompose import PageDecompositionBlock
from codex.requirements.database import get_specification
from langsmith import traceable

RECURSION_DEPTH_LIMIT = int(os.environ.get("RECURSION_DEPTH_LIMIT", 2))

logger = logging.getLogger(__name__)


@traceable
async def process_api_route(
api_route: prisma.models.APIRouteSpec,
ids: Identifiers,
Expand Down Expand Up @@ -128,7 +129,7 @@ async def process_api_route(
compiled_route.id, route_root_func, spec, available_funcs, available_objs
)


@traceable
async def develop_user_interface(ids: Identifiers) -> CompletedApp:
if not ids.user_id or not ids.app_id or not ids.completed_app_id:
raise ValueError("user_id, app_id, and completed_app_id are required")
Expand Down Expand Up @@ -174,7 +175,7 @@ async def develop_user_interface(ids: Identifiers) -> CompletedApp:

return await develop_application(ids, frontend_spec, lang="nicegui")


@traceable
async def develop_application(
ids: Identifiers,
spec: Specification,
Expand Down Expand Up @@ -247,7 +248,7 @@ async def develop_application(

return completed_app


@traceable
async def populate_available_functions_objects(
functions: list[Function],
) -> tuple[dict[str, Function], dict[str, ObjectType]]:
Expand All @@ -270,7 +271,7 @@ async def populate_available_functions_objects(

return generated_func, generated_objs


@traceable
async def develop_route(
ids: Identifiers,
goal_description: str,
Expand Down
6 changes: 4 additions & 2 deletions codex/interview/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
InterviewResponse,
UpdateUnderstanding,
)
from langsmith.wrappers import wrap_openai
from langsmith import traceable

logger = logging.getLogger(__name__)


@traceable
async def start_interview(
ids: Identifiers, app: prisma.models.Application
) -> InterviewResponse:
Expand Down Expand Up @@ -74,7 +76,7 @@ async def start_interview(
phase_completed=ans.phase_completed,
)


@traceable
async def continue_interview(
ids: Identifiers, app: prisma.models.Application, user_message: str
) -> InterviewResponse:
Expand Down
7 changes: 4 additions & 3 deletions codex/requirements/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import codex.requirements.blocks.ai_module_routes
import codex.requirements.model
from codex.api_model import Identifiers
from langsmith import traceable

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -57,7 +58,7 @@ class SpecHolder(pydantic.BaseModel):
modules: list[Module] = []
db_response: codex.requirements.model.DBResponse | None = None


@traceable
async def generate_requirements(ids: Identifiers, app: Application) -> SpecHolder:
"""
Runs the Requirements Agent to generate the system requirements based
Expand Down Expand Up @@ -166,7 +167,7 @@ async def generate_requirements(ids: Identifiers, app: Application) -> SpecHolde
logger.info("Specification Definition Complete, saving to database")
return spec_holder


@traceable
async def denfine_module_routes(
ids: Identifiers,
app: Application,
Expand Down Expand Up @@ -216,7 +217,7 @@ async def denfine_module_routes(

return module


@traceable
async def define_api_spec(
ids: Identifiers,
app: Application,
Expand Down
20 changes: 18 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ google-api-python-client = "^2.126.0"
google-auth-httplib2 = "^0.2.0"
google-auth-oauthlib = "^1.2.0"
nicegui = "^1.4.22"
langsmith = "^0.1.52"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.3"
Expand Down

0 comments on commit 3c3e026

Please sign in to comment.