Skip to content

Commit ed1246c

Browse files
authored
Fix dynamic repo on PR comment and new key names (#87)
1 parent f3bf861 commit ed1246c

4 files changed

Lines changed: 15 additions & 21 deletions

File tree

docs/dagger/dagger-hackathon/README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,16 @@ The below steps will take you through making a breaking change to a file in our
126126

127127
- Rename `docs/dagger/dagger-hackathon/.env-example` to `.env`
128128
- Populate the placeholder keys with real values (we will provide for Hackathon day)
129-
- Create environment variables for `GITHUB_TOKEN`, `AZURE_API_KEY`, `AZURE_API_ENDPOINT`
129+
- Create environment variables for `GITHUB_TOKEN` and `AZURE_OPENAI_API_KEY`
130130
A GitHub Token can be created in GitHub under Settings → Developer Settings → Create a classic token
131131
Example:
132132
```bash
133133
export GITHUB_TOKEN="XXX"
134134
```
135135
The Azure OpenAI details can be found below:
136136

137-
```bash
138-
export AZURE_API_KEY="FT0Dd0iIglkzGbizOMUp79k0Frea7neDtVXRhFZ5m39CJJJcdfxFJQQJ99BEACYeBjFXJ3w3AAABACO"
139-
export AZURE_API_ENDPOINT="https://vdfvdf.openai.azure.com/"
140-
```
137+
- Azure OpenAI API Key: FT0Dd0iIglkzGbizOMUp79k0Frea7neDtVXRhFZ5m39CJJJcdfxFJQQJ99BEACYeBjFXJ3w3AAABACO
138+
- Azure OpenAI Endpoint: https://vdfvdf.openai.azure.com/
141139

142140
> **Note:** The full API key will be provided during the hackathon.
143141
@@ -148,8 +146,8 @@ The Azure OpenAI details can be found below:
148146
--github_branch="BRANCH-NAME" \
149147
--github_repo="USERNAME/REPO-NAME" \
150148
--github_token="GITHUB_TOKEN" \
151-
--azure_api_key="AZURE_API_KEY" \
152-
--azure_endpoint="AZURE_API_ENDPOINT" \
149+
--azure_openai_api_key="AZURE_OPENAI_API_KEY" \
150+
--azure_openai_endpoint="ENDPOINT-URL" \
153151
fix-my-tests-agent
154152
```
155153

docs/dagger/dagger-hackathon/dagger-hackathon-pipeline/src/dagger_hackathon/main.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class DaggerHackathon:
3636
github_branch: str
3737
github_repo: str
3838
github_token: dagger.Secret
39-
azure_api_key: dagger.Secret
40-
azure_endpoint: str
41-
azure_model: str = "gpt-4o"
39+
azure_openai_api_key: dagger.Secret # use in azure_xxx in StructureLlmResponse with AzureOpenAI library
40+
azure_openai_endpoint: str
41+
azure_openai_model: str = "gpt-4o"
4242
@function
4343
async def GetPrMetadata(self) -> PrMetadataResult:
4444
"""Get the PR number and commit ID
@@ -129,19 +129,18 @@ async def StructureLlmResponse(
129129
command_to_execute = [
130130
"python", "dagger-hackathon-pipeline/src/dagger_hackathon/structure_llm_response.py",
131131
"--response", response_to_structure,
132-
"--endpoint", self.azure_endpoint,
133-
"--model", self.azure_model
132+
"--endpoint", self.azure_openai_endpoint,
133+
"--model", self.azure_openai_model
134134
]
135135
container = (
136136
dag.container()
137137
.from_("python:3.11")
138138
.with_mounted_directory("/app", self.source)
139139
.with_workdir("/app")
140-
.with_secret_variable("AZURE_OPENAI_API_KEY", self.azure_api_key)
140+
.with_secret_variable("AZURE_OPENAI_API_KEY", self.azure_openai_api_key)
141141
.with_exec(["pip", "install", "--upgrade", "pip"])
142142
.with_exec(["pip", "install", "openai==1.82.0", "pydantic==2.11.5"])
143143
.with_exec(["sh", "-c", "export $(grep -v '^#' .env | xargs)"])
144-
.with_exec(["sh", "-c", "echo $OPENAI_API_KEY"])
145144
.with_exec(command_to_execute)
146145
)
147146

@@ -174,7 +173,7 @@ async def CreatePrSuggestion(
174173
"--method", "POST",
175174
"-H", "Accept: application/vnd.github+json",
176175
"-H", "X-GitHub-Api-Version: 2022-11-28",
177-
f"/repos/codetocloudorg/platform-engineering/pulls/{pr_metadata.pr_number}/comments",
176+
f"/repos/{self.github_repo}/pulls/{pr_metadata.pr_number}/comments",
178177
"-f", f"body=```suggestion\n{proposed_code_changes.change}\n```",
179178
"-f", f"commit_id={pr_metadata.commit_id}",
180179
"-f", f"path={proposed_code_changes.path}",
@@ -244,8 +243,6 @@ async def FixMyTestsAgent(
244243
.with_prompt_file(dag.current_module().source().file("debug_unit_test_prompt.md"))
245244
)
246245

247-
analyzed_results_output = await analyze_results.last_reply()
248-
249246
proposed_code_change = await self.StructureLlmResponse(
250247
await analyze_results.last_reply()
251248
)
@@ -259,4 +256,4 @@ async def FixMyTestsAgent(
259256
pr_metadata=pr_metadata,
260257
pr_suggestions=created_pr_suggestion
261258
))
262-
259+

docs/dagger/dagger-hackathon/dagger-hackathon-pipeline/src/dagger_hackathon/structure_llm_response.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import argparse
22
from pydantic import BaseModel, Field
33
from openai import AzureOpenAI
4-
import os
54

65
class ProposedCodeChangesPydantic(BaseModel):
76
path: str = Field(description="The path to the source file. ie: docs/dagger/dagger-hackathon/src/file.py")
@@ -34,4 +33,4 @@ def main():
3433
print(structured_output)
3534

3635
if __name__ == "__main__":
37-
main()
36+
main()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
def add(a, b):
2-
return a - b*2
2+
return a - b * 10

0 commit comments

Comments
 (0)