dnnsdunca commited on
Commit
253524a
·
verified ·
1 Parent(s): 38dfef4

Create src/generate.py

Browse files
Files changed (1) hide show
  1. src/generate.py +40 -0
src/generate.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agent import CodingAgent
2
+ from utils import load_config
3
+
4
+ def main():
5
+ config = load_config('configs/model_config.yaml')
6
+ agent = CodingAgent("./final_model")
7
+
8
+ while True:
9
+ print("\nChoose an action:")
10
+ print("1. Generate code")
11
+ print("2. Answer coding question")
12
+ print("3. Explain code")
13
+ print("4. Suggest improvements")
14
+ print("5. Exit")
15
+
16
+ choice = input("Enter your choice (1-5): ")
17
+
18
+ if choice == '1':
19
+ prompt = input("Enter a prompt for code generation: ")
20
+ code = agent.generate_code(prompt)
21
+ print("\nGenerated Code:\n", code)
22
+ elif choice == '2':
23
+ question = input("Enter your coding question: ")
24
+ answer = agent.answer_coding_question(question)
25
+ print("\nAnswer:\n", answer)
26
+ elif choice == '3':
27
+ code = input("Enter the code to explain: ")
28
+ explanation = agent.explain_code(code)
29
+ print("\nExplanation:\n", explanation)
30
+ elif choice == '4':
31
+ code = input("Enter the code for improvement suggestions: ")
32
+ suggestions = agent.suggest_improvements(code)
33
+ print("\nSuggestions:\n", suggestions)
34
+ elif choice == '5':
35
+ break
36
+ else:
37
+ print("Invalid choice. Please try again.")
38
+
39
+ if __name__ == "__main__":
40
+ main()