Canstralian commited on
Commit
0f7a93c
·
verified ·
1 Parent(s): 2938f1d

Create codepal_api.py

Browse files
Files changed (1) hide show
  1. codepal_api.py +30 -0
codepal_api.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+ # Replace with your CodePal API Key
4
+ API_KEY = "YOUR_API_KEY"
5
+
6
+ # Define the request URL
7
+ url = "https://api.codepal.ai/v1/cicd-pipeline-writer/query"
8
+
9
+ # Define the request body (the description of the pipeline you want to generate)
10
+ data = {
11
+ "prompt": "Builds a Docker image and deploys it to a Kubernetes cluster using GitHub Actions.",
12
+ "pipeline_name": "github-actions"
13
+ }
14
+
15
+ # Set up the headers for authentication
16
+ headers = {
17
+ "Authorization": f"Bearer {API_KEY}"
18
+ }
19
+
20
+ # Send the POST request to CodePal
21
+ response = requests.post(url, headers=headers, data=data)
22
+
23
+ # Handle the response
24
+ if response.status_code == 201:
25
+ pipeline = response.json()
26
+ print("Pipeline Generated Successfully:")
27
+ print(pipeline["result"]) # This will print the generated pipeline code
28
+ else:
29
+ print(f"Error: {response.status_code}")
30
+ print(response.text)