dnnsdunca commited on
Commit
6838dfd
1 Parent(s): 851227f

Create agent24

Browse files
Files changed (1) hide show
  1. agent24 +34 -0
agent24 ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ import requests
3
+
4
+ app = Flask(__name__)
5
+
6
+ # Hugging Face API URL and token
7
+ HUGGING_FACE_API_URL = 'https://api-inference.huggingface.co/models/dnnsdunca/Llama-3-70B-DDroidlabs'
8
+ API_TOKEN = 'your api key'
9
+
10
+ @app.route('/generate-code', methods=['POST'])
11
+ def generate_code():
12
+ data = request.get_json()
13
+ prompt = data['prompt']
14
+
15
+ headers = {
16
+ 'Authorization': f'Bearer {API_TOKEN}',
17
+ 'Content-Type': 'application/json'
18
+ }
19
+
20
+ payload = {
21
+ 'inputs': prompt,
22
+ }
23
+
24
+ response = requests.post(HUGGING_FACE_API_URL, headers=headers, json=payload)
25
+
26
+ if response.status_code == 200:
27
+ result = response.json()
28
+ code = result[0]['generated_text'].strip()
29
+ return jsonify({'code': code})
30
+ else:
31
+ return jsonify({'error': 'Error generating code'}), 500
32
+
33
+ if __name__ == '__main__':
34
+ app.run(port=8000)