Skip to content

Commit

Permalink
Bug fixing frontend (#287)
Browse files Browse the repository at this point in the history
* fixing bugs in the frontend

* linting
  • Loading branch information
aarushik93 authored Jun 11, 2024
1 parent f0f9307 commit 95c5b67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
1 change: 1 addition & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
***Note: This frontend is a minimal frontend app to make local development easier. Do not use in production***
5 changes: 3 additions & 2 deletions frontend/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,14 @@ async def handle_interview(codex_client, interview_response, user_message):
future_time = datetime.now(timezone.utc) + timedelta(minutes=15)
future_timestamp = int(future_time.timestamp())
st.session_state.messages.append(
f"Okay starting developing app... Expected completion time: {future_timestamp}"
f"{interview_response.say_to_user}. Expected completion time: {future_timestamp}"
)
st.session_state.progress = 2
elif interview_response.phase == "FEATURES":
st.session_state.messages.append(interview_response.say_to_user)
interview_response = await codex_client.interview_next("")
st.session_state.interview_response = interview_response
interview_response = await codex_client.interview_next("")
st.session_state.messages.append(interview_response.say_to_user)
except Exception as e:
logger.error(f"Failed to handle interview: {e}")
st.error(f"Failed to handle interview: {e}")
Expand Down
35 changes: 22 additions & 13 deletions frontend/codex_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
SpecificationResponse,
DeliverableResponse,
DeploymentResponse,
UserResponse,
)

logger = logging.getLogger(__name__)

# Hardcoded user data
HARDCODED_USER_ID = "7b3a9e01-4ede-4a56-919b-d7063ba3c6e3"
HARDCODED_CODEX_ID = "7b3a9e01-4ede-4a56-919b-d7063ba3c6e3"
HARDCODED_DISCORD_ID = "hardcoded_discord_id"
CLOUD_SERVICES_ID = "7b3a9e01-4ede-4a56-919b-d7063ba3c6e3"
DISCORD_ID = "6984891672811274234"


class CodexClient:
Expand All @@ -35,8 +34,9 @@ def __init__(
auth_key (str, optional): the authorization key for the codex service. Defaults to None.
"""
# Set the base url for codex
self.user = None
if not base_url:
self.base_url = "https://codegen-xca4qjgx4a-uc.a.run.app/api/v1"
self.base_url = "http://localhost:8080/api/v1"
else:
self.base_url = base_url

Expand Down Expand Up @@ -70,14 +70,23 @@ async def init(
cloud_services_user_id (str): the id of the user in the cloud services
codex_user_id (str): the id of the user in the codex service
"""
# Using hardcoded values
self.codex_user_id = HARDCODED_CODEX_ID
self.user_id = HARDCODED_USER_ID
self.user = {
"id": HARDCODED_USER_ID,
"codexId": HARDCODED_CODEX_ID,
"discordId": HARDCODED_DISCORD_ID,
}
async with aiohttp.ClientSession() as session:
async with session.post(
"http://localhost:8080/api/v1/user",
params={
"cloud_services_id": CLOUD_SERVICES_ID,
"discord_id": DISCORD_ID,
},
headers={"accept": "application/json"},
) as response:
if response.status == 200:
data = await response.json()
user_response = UserResponse(**data)
self.user = user_response
self.codex_user_id = self.user.id
else:
# Handle error case
raise Exception(f"Failed to fetch/create user: {response.status}")

if app_id:
self.app_id = app_id
Expand Down

0 comments on commit 95c5b67

Please sign in to comment.