File size: 2,536 Bytes
b502835
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
pip install gradio openai

import openai
import gradio as gr

# Set your LLaMA3 API key
openai.api_key = 'your-llama3-api-key'

def ai_developer_agent(prompt, specialization="general"):
    """
    Function to interact with the LLaMA3 API and get a response based on the prompt and specialization.
    
    :param prompt: The input text to the AI agent.
    :param specialization: The area of specialization for the AI agent.
    :return: The response from the AI agent.
    """
    try:
        specialized_prompt = (
            f"You are an AI developer assistant specializing in {specialization}. "
            "Answer the following query or provide the requested code snippet:\n\n{prompt}"
        )
        response = openai.Completion.create(
            engine="text-davinci-003",
            prompt=specialized_prompt,
            max_tokens=300,
            n=1,
            stop=None,
            temperature=0.7
        )
        return response.choices[0].text.strip()
    except Exception as e:
        return str(e)

def determine_specialization(query):
    """
    Function to determine the specialization based on the query content.
    
    :param query: The input query from the user.
    :return: The determined area of specialization.
    """
    if "frontend" in query.lower():
        return "frontend development"
    elif "backend" in query.lower():
        return "backend development"
    elif "debug" in query.lower():
        return "debugging"
    elif "deploy" in query.lower():
        return "deployment"
    else:
        return "general development"

def interact(query):
    specialization = determine_specialization(query)
    response = ai_developer_agent(query, specialization)
    return response

iface = gr.Interface(
    fn=interact,
    inputs="text",
    outputs="text",
    title="AI Developer Agent",
    description="Ask the AI developer assistant anything about frontend, backend, debugging, or deployment."
)

if __name__ == "__main__":
    iface.launch()

python ai_developer_agent.py

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.route('/api', methods=['GET'])
def get_api():
    data = {"message": "Hello, World!"}
    return jsonify(data)

@app.route('/api', methods=['POST'])
def post_api():
    data = request.get_json()
    return jsonify(data), 201

if __name__ == '__main__':
    app.run(debug=True)

import pdb

def add(a, b):
    pdb.set_trace()  # This will pause execution and open the debugger
    return a + b

result = add(3, 5)
print(result)