rogerthat11 commited on
Commit
3d48e06
Β·
1 Parent(s): 36058b9

push full macanism

Browse files
This view is limited to 50 files because it contains too many changes. Β  See raw diff
Files changed (50) hide show
  1. .history/README_20250202035449.md +13 -0
  2. .history/README_20250202065215.md +56 -0
  3. .history/README_20250202065217.md +57 -0
  4. .history/README_20250202065728.md +38 -0
  5. .history/README_20250202071804.md +51 -0
  6. .history/README_20250202072652.md +61 -0
  7. .history/app_20250202070123.py +28 -0
  8. .history/app_20250202071439.py +42 -0
  9. .history/app_20250202072114.py +49 -0
  10. .history/app_20250202072637.py +49 -0
  11. .history/app_20250202072640.py +49 -0
  12. configs/config.yaml β†’ .history/configs/chatbot_config_20250202065636.yaml +0 -0
  13. .history/configs/chatbot_config_20250202071313.yaml +23 -0
  14. .history/configs/chatbot_config_20250202071856.yaml +23 -0
  15. .history/configs/chatbot_config_20250202072554.yaml +24 -0
  16. .history/details_20250202061415.txt +0 -0
  17. .history/details_20250202065715.txt +21 -0
  18. .history/requirements_20250202065234.txt +3 -0
  19. .history/requirements_20250202065734.txt +4 -0
  20. .history/requirements_20250202071821.txt +4 -0
  21. .history/requirements_20250202071824.txt +4 -0
  22. .history/scripts/chatbot_logic_20250202065546.py +0 -0
  23. .history/scripts/chatbot_logic_20250202070001.py +132 -0
  24. .history/scripts/chatbot_logic_20250202071411.py +150 -0
  25. .history/scripts/chatbot_logic_20250202072003.py +209 -0
  26. .history/scripts/chatbot_logic_20250202072623.py +203 -0
  27. .history/scripts/chatbot_logic_20250202072626.py +203 -0
  28. .history/scripts/code_templates/api_template.py_20250202065623.txt +0 -0
  29. .history/scripts/code_templates/api_template.py_20250202070107.txt +60 -0
  30. .history/scripts/code_templates/api_template.py_20250202072103.txt +60 -0
  31. .history/scripts/code_templates/evaluation_template.py_20250202065617.txt +0 -0
  32. .history/scripts/code_templates/evaluation_template.py_20250202070058.txt +67 -0
  33. .history/scripts/code_templates/evaluation_template.py_20250202072054.txt +67 -0
  34. .history/scripts/code_templates/preprocessing_template.py_20250202065605.txt +0 -0
  35. .history/scripts/code_templates/preprocessing_template.py_20250202070023.txt +44 -0
  36. .history/scripts/code_templates/preprocessing_template.py_20250202072023.txt +44 -0
  37. .history/scripts/code_templates/training_template.py_20250202065612.txt +0 -0
  38. .history/scripts/code_templates/training_template.py_20250202070043.txt +58 -0
  39. .history/scripts/code_templates/training_template.py_20250202072034.txt +58 -0
  40. .history/scripts/parse_20250202061443.py +1 -0
  41. .history/scripts/parsing_utils_20250202065553.py +0 -0
  42. .history/scripts/parsing_utils_20250202065942.py +28 -0
  43. .history/scripts/parsing_utils_20250202071904.py +28 -0
  44. .history/scripts/parsing_utils_20250202071913.py +28 -0
  45. .history/scripts/parsing_utils_20250202071948.py +28 -0
  46. README.md +49 -1
  47. app.py +49 -36
  48. configs/chatbot_config.yaml +24 -0
  49. configs/requirments.txt +0 -8
  50. details.txt +21 -0
.history/README_20250202035449.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Test
3
+ emoji: πŸ“š
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.41.1
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: STTETTETE
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
.history/README_20250202065215.md ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Test
3
+ emoji: πŸ“š
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.41.1
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: STTETTETE
11
+ ---
12
+ # Custom AI Chatbot for Project Guidance
13
+
14
+ This project provides a template for building a custom AI chatbot that guides users through projects based on predefined roadmaps and rules.
15
+
16
+ ## Getting Started
17
+
18
+ 1. **Clone this repository.**
19
+ 2. **Install dependencies:** `pip install -r requirements.txt`
20
+ 3. **Customize `roadmap.txt` and `rules.txt`:** Define your project's roadmap and rules in YAML format.
21
+ 4. **Run the chatbot:** `python app.py`
22
+ 5. **Access the chatbot:** Open the Gradio link provided in the console.
23
+
24
+ ## Deployment on Hugging Face Spaces
25
+
26
+ 1. **Create a new Space on Hugging Face Spaces.** Choose Gradio or Streamlit as the SDK.
27
+ 2. **Upload all project files** to your Space repository.
28
+ 3. **Hugging Face Spaces will automatically install dependencies from `requirements.txt` and run `app.py` (or your chosen app script).**
29
+
30
+ ## Customization
31
+
32
+ * **Modify `roadmap.txt` and `rules.txt`** to fit your specific project.
33
+ * **Implement actual LLM integration** in `guidance_system.py` and `app.py`.
34
+ * **Develop code generation logic** in `code_generator.py`.
35
+ * **Enhance the user interface** in `app.py`.
36
+ * **Add more sophisticated parsing and guidance logic** as needed.
37
+
38
+ ## File Structure
39
+
40
+ * `/data`: Intended for storing project datasets (e.g., for fine-tuning). Currently a placeholder.
41
+ * `/models`: Intended for storing downloaded or trained models. Currently a placeholder.
42
+ * `/scripts`: Contains Python scripts for core chatbot logic (parsing, guidance, code generation, error handling).
43
+ * `/api`: Intended for API related files if you integrate with external services. Currently a placeholder.
44
+ * `/configs`: Contains configuration files like `config.yaml`.
45
+ * `app.py`: The main application script using Gradio for the user interface.
46
+ * `requirements.txt`: Lists Python dependencies.
47
+ * `roadmap.txt`: Defines the project roadmap in YAML format.
48
+ * `rules.txt`: Defines project rules and best practices in YAML format.
49
+
50
+ ## Example Roadmap and Rules
51
+
52
+ See `roadmap.txt` and `rules.txt` for example content.
53
+
54
+ ## License
55
+
56
+ [Your License] (e.g., MIT License)
.history/README_20250202065217.md ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Test
3
+ emoji: πŸ“š
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.41.1
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: STTETTETE
11
+ ---
12
+
13
+ # Custom AI Chatbot for Project Guidance
14
+
15
+ This project provides a template for building a custom AI chatbot that guides users through projects based on predefined roadmaps and rules.
16
+
17
+ ## Getting Started
18
+
19
+ 1. **Clone this repository.**
20
+ 2. **Install dependencies:** `pip install -r requirements.txt`
21
+ 3. **Customize `roadmap.txt` and `rules.txt`:** Define your project's roadmap and rules in YAML format.
22
+ 4. **Run the chatbot:** `python app.py`
23
+ 5. **Access the chatbot:** Open the Gradio link provided in the console.
24
+
25
+ ## Deployment on Hugging Face Spaces
26
+
27
+ 1. **Create a new Space on Hugging Face Spaces.** Choose Gradio or Streamlit as the SDK.
28
+ 2. **Upload all project files** to your Space repository.
29
+ 3. **Hugging Face Spaces will automatically install dependencies from `requirements.txt` and run `app.py` (or your chosen app script).**
30
+
31
+ ## Customization
32
+
33
+ * **Modify `roadmap.txt` and `rules.txt`** to fit your specific project.
34
+ * **Implement actual LLM integration** in `guidance_system.py` and `app.py`.
35
+ * **Develop code generation logic** in `code_generator.py`.
36
+ * **Enhance the user interface** in `app.py`.
37
+ * **Add more sophisticated parsing and guidance logic** as needed.
38
+
39
+ ## File Structure
40
+
41
+ * `/data`: Intended for storing project datasets (e.g., for fine-tuning). Currently a placeholder.
42
+ * `/models`: Intended for storing downloaded or trained models. Currently a placeholder.
43
+ * `/scripts`: Contains Python scripts for core chatbot logic (parsing, guidance, code generation, error handling).
44
+ * `/api`: Intended for API related files if you integrate with external services. Currently a placeholder.
45
+ * `/configs`: Contains configuration files like `config.yaml`.
46
+ * `app.py`: The main application script using Gradio for the user interface.
47
+ * `requirements.txt`: Lists Python dependencies.
48
+ * `roadmap.txt`: Defines the project roadmap in YAML format.
49
+ * `rules.txt`: Defines project rules and best practices in YAML format.
50
+
51
+ ## Example Roadmap and Rules
52
+
53
+ See `roadmap.txt` and `rules.txt` for example content.
54
+
55
+ ## License
56
+
57
+ [Your License] (e.g., MIT License)
.history/README_20250202065728.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Test
3
+ emoji: πŸ“š
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.41.1
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: STTETTETE
11
+ ---
12
+ # Custom AI Chatbot for Project Guidance
13
+
14
+ This project implements a custom AI chatbot designed to guide users through complex projects based on predefined roadmaps and rules.
15
+
16
+ **Features:**
17
+
18
+ * **Roadmap-based Guidance:** Follows a structured roadmap defined in `roadmap.yaml`.
19
+ * **Rule Enforcement:** Adheres to project rules defined in `rules.yaml`.
20
+ * **Dynamic Response Generation:** Provides context-aware and step-by-step guidance.
21
+ * **Code Snippet Generation:** Generates complete code snippets for project phases.
22
+ * **LLM Selection:** Integrates with Hugging Face Hub for flexible LLM selection.
23
+ * **Deployable on Hugging Face Spaces:** Built using Gradio for easy deployment.
24
+
25
+ **Getting Started:**
26
+
27
+ 1. **Clone this repository.**
28
+ 2. **Install dependencies:** `pip install -r requirements.txt`
29
+ 3. **Customize `roadmap.yaml` and `rules.yaml`** to define your project guidance.
30
+ 4. **Configure `configs/chatbot_config.yaml`** (optional).
31
+ 5. **Run the Gradio app:** `python app.py`
32
+ 6. **Deploy to Hugging Face Spaces** (refer to Hugging Face Spaces documentation).
33
+
34
+ **Further Development:**
35
+
36
+ * [List potential improvements and features here, as discussed earlier]
37
+
38
+ **License:** [Your License]
.history/README_20250202071804.md ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Test
3
+ emoji: πŸ“š
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.41.1
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: STTETTETE
11
+ ---
12
+ # Custom AI Chatbot for Project Guidance
13
+
14
+ This project implements a custom AI chatbot designed to guide users through complex projects based on predefined roadmaps and rules.
15
+
16
+ **Features:**
17
+
18
+ * **Roadmap-based Guidance:** Follows a structured roadmap defined in `roadmap.yaml`.
19
+ * **Rule Enforcement:** Adheres to project rules defined in `rules.yaml`.
20
+ * **Dynamic Response Generation:** Provides context-aware and step-by-step guidance.
21
+ * **Code Snippet Generation:** Generates complete code snippets for project phases using templates.
22
+ * **LLM Selection:** Integrates with Hugging Face Hub for flexible LLM selection (DeepSeek and Gemini models).
23
+ * **Model Switching:** Allows users to switch between available LLMs via the UI.
24
+ * **Basic LLM Responses:** Generates responses using the selected LLM for general queries.
25
+ * **Error Handling:** Includes error handling for model loading and switching, with UI warnings.
26
+ * **Deployable on Hugging Face Spaces:** Built using Gradio for easy deployment.
27
+
28
+ **Getting Started:**
29
+
30
+ 1. **Clone this repository.**
31
+ 2. **Install dependencies:** `pip install -r requirements.txt`
32
+ 3. **Customize `roadmap.yaml` and `rules.yaml`** to define your project guidance.
33
+ 4. **Configure `configs/chatbot_config.yaml`** to set up LLMs and chatbot behavior.
34
+ 5. **Run the Gradio app:** `python app.py`
35
+ 6. **Deploy to Hugging Face Spaces** (refer to Hugging Face Spaces documentation).
36
+
37
+ **Available Models:**
38
+
39
+ * DeepSeek-R1-Distill-Llama-8B
40
+ * Gemini 2.0 Flash (Exp 01-21)
41
+
42
+ **Further Development:**
43
+
44
+ * Enhance LLM response generation for more context-aware and project-specific guidance.
45
+ * Implement more sophisticated state management to track user progress through the roadmap.
46
+ * Improve code generation with more dynamic templates and customization options.
47
+ * Develop a more advanced GUI or web-based interface.
48
+ * Add more LLMs to the selection pool.
49
+ * Implement more robust error handling and logging.
50
+
51
+ **License:** [Your License]
.history/README_20250202072652.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Test
3
+ emoji: πŸ“š
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: streamlit
7
+ sdk_version: 1.41.1
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: STTETTETE
11
+ ---
12
+ # Custom AI Chatbot for Project Guidance
13
+
14
+ This project implements a custom AI chatbot designed to guide users through complex projects based on predefined roadmaps and rules.
15
+
16
+ **Features:**
17
+
18
+ * **Roadmap-based Guidance:** Follows a structured roadmap defined in `roadmap.yaml`.
19
+ * **Rule Enforcement:** Adheres to project rules defined in `rules.yaml`.
20
+ * **Dynamic Response Generation:** Provides context-aware and step-by-step guidance.
21
+ * **Code Snippet Generation:** Generates complete code snippets for project phases using templates.
22
+ * **LLM Selection:** Integrates with Hugging Face Hub for flexible LLM selection (DeepSeek and Gemini models).
23
+ * **Model Switching:** Allows users to switch between available LLMs via the UI.
24
+ * **Basic LLM Responses:** Generates responses using the selected LLM for general queries.
25
+ * **Token Control:** Limits LLM response length using `max_response_tokens` in `configs/chatbot_config.yaml`.
26
+ * **Error Handling:** Includes error handling for model loading and switching, with UI warnings.
27
+ * **Deployable on Hugging Face Spaces:** Built using Gradio for easy deployment.
28
+
29
+ **Important Notes on Safety Settings:**
30
+
31
+ * **Direct Safety Configuration Limited:** For the Hugging Face models used directly via `transformers` (DeepSeek and Gemini Flash), there are **no easily configurable, standardized "safety settings"** like "Harassment: None," "Hate: None," etc., available through the `transformers` library itself.
32
+ * **Model-Dependent Safety:** Safety behavior is primarily determined by how these models were trained and any inherent safety mechanisms built by their creators.
33
+ * **Basic Output Filtering (Possible Extension):** For a very rudimentary level of control, you could implement keyword-based output filtering as a post-processing step, but this is not implemented in this version.
34
+ * **Commercial APIs Offer More Control:** If you need fine-grained safety controls, consider using commercial LLM APIs (like Google AI Gemini API, OpenAI API), which often provide parameters to adjust safety filters in their API requests.
35
+
36
+ **Getting Started:**
37
+
38
+ 1. **Clone this repository.**
39
+ 2. **Install dependencies:** `pip install -r requirements.txt`
40
+ 3. **Customize `roadmap.yaml` and `rules.yaml`** to define your project guidance.
41
+ 4. **Configure `configs/chatbot_config.yaml`** to set up LLMs, token limits, and chatbot behavior.
42
+ 5. **Run the Gradio app:** `python app.py`
43
+ 6. **Deploy to Hugging Face Spaces** (refer to Hugging Face Spaces documentation).
44
+
45
+ **Available Models:**
46
+
47
+ * DeepSeek-R1-Distill-Llama-8B
48
+ * Gemini 2.0 Flash (Exp 01-21)
49
+
50
+ **Further Development:**
51
+
52
+ * Enhance LLM response generation for more context-aware and project-specific guidance.
53
+ * Implement more sophisticated state management to track user progress through the roadmap.
54
+ * Improve code generation with more dynamic templates and customization options.
55
+ * Develop a more advanced GUI or web-based interface.
56
+ * Add more LLMs to the selection pool.
57
+ * Implement more robust error handling and logging.
58
+ * **Explore and potentially integrate keyword-based output filtering for basic safety control.**
59
+ * **Investigate using commercial LLM APIs for more advanced safety settings and control.**
60
+
61
+ **License:** [Your License]
.history/app_20250202070123.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from scripts.chatbot_logic import ProjectGuidanceChatbot
3
+
4
+ # Initialize Chatbot
5
+ chatbot = ProjectGuidanceChatbot(
6
+ roadmap_file="roadmap.yaml",
7
+ rules_file="rules.yaml",
8
+ config_file="configs/chatbot_config.yaml",
9
+ code_templates_dir="scripts/code_templates"
10
+ )
11
+
12
+ def respond(message, chat_history):
13
+ bot_message = chatbot.process_query(message)
14
+ chat_history.append((message, bot_message))
15
+ return "", chat_history
16
+
17
+ with gr.Blocks() as demo:
18
+ chatbot_greeting = chatbot.get_chatbot_greeting()
19
+ gr.Markdown(f"# {chatbot.chatbot_config.get('name', 'Project Guidance Chatbot')}")
20
+ gr.Markdown(chatbot_greeting)
21
+
22
+ chatbot_ui = gr.Chatbot()
23
+ msg = gr.Textbox()
24
+ clear = gr.ClearButton([msg, chatbot_ui])
25
+
26
+ msg.submit(respond, [msg, chatbot_ui], [msg, chatbot_ui])
27
+
28
+ demo.launch()
.history/app_20250202071439.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from scripts.chatbot_logic import ProjectGuidanceChatbot
3
+
4
+ # Initialize Chatbot
5
+ chatbot = ProjectGuidanceChatbot(
6
+ roadmap_file="roadmap.yaml",
7
+ rules_file="rules.yaml",
8
+ config_file="configs/chatbot_config.yaml",
9
+ code_templates_dir="scripts/code_templates"
10
+ )
11
+
12
+ def respond(message, chat_history):
13
+ bot_message = chatbot.process_query(message)
14
+ chat_history.append((message, bot_message))
15
+ return "", chat_history
16
+
17
+ def switch_model(model_key):
18
+ model_switch_message = chatbot.switch_llm_model(model_key)
19
+ greeting_message = chatbot.get_chatbot_greeting()
20
+ return greeting_message # Update greeting to reflect new model
21
+
22
+ with gr.Blocks() as demo:
23
+ chatbot_greeting_md = gr.Markdown(chatbot.get_chatbot_greeting()) # Markdown for greeting - to update dynamically
24
+ gr.Markdown(f"# {chatbot.chatbot_config.get('name', 'Project Guidance Chatbot')}")
25
+
26
+ # Model selection dropdown
27
+ model_choices = [(model['name'], key) for key, model in chatbot.available_models_config.items()] # (Display Name, Key)
28
+ model_dropdown = gr.Dropdown(
29
+ choices=model_choices,
30
+ value=chatbot.active_model_info['name'] if chatbot.active_model_info else None, # Set initial value to current model name
31
+ label="Select LLM Model"
32
+ )
33
+ model_dropdown.change(fn=switch_model, inputs=model_dropdown, outputs=chatbot_greeting_md) # Update greeting on model change
34
+
35
+
36
+ chatbot_ui = gr.Chatbot()
37
+ msg = gr.Textbox()
38
+ clear = gr.ClearButton([msg, chatbot_ui])
39
+
40
+ msg.submit(respond, [msg, chatbot_ui], [msg, chatbot_ui])
41
+
42
+ demo.launch()
.history/app_20250202072114.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from scripts.chatbot_logic import ProjectGuidanceChatbot
3
+
4
+ # Initialize Chatbot
5
+ chatbot = ProjectGuidanceChatbot(
6
+ roadmap_file="roadmap.yaml",
7
+ rules_file="rules.yaml",
8
+ config_file="configs/chatbot_config.yaml",
9
+ code_templates_dir="scripts/code_templates"
10
+ )
11
+
12
+ def respond(message, chat_history):
13
+ bot_message = chatbot.process_query(message)
14
+ chat_history.append((message, bot_message))
15
+ return "", chat_history
16
+
17
+ def switch_model(model_key):
18
+ model_switch_result = chatbot.switch_llm_model(model_key) # Get result message
19
+ greeting_message = chatbot.get_chatbot_greeting()
20
+
21
+ if "Error:" in model_switch_result: # Check if result contains "Error:"
22
+ return gr.Warning(model_switch_result), greeting_message # Display error as Gradio Warning
23
+ else:
24
+ return None, greeting_message # No warning, just update greeting
25
+
26
+ with gr.Blocks() as demo:
27
+ chatbot_greeting_md = gr.Markdown(chatbot.get_chatbot_greeting())
28
+ gr.Markdown(f"# {chatbot.chatbot_config.get('name', 'Project Guidance Chatbot')}")
29
+
30
+ model_choices = [(model['name'], key) for key, model in chatbot.available_models_config.items()]
31
+ model_dropdown = gr.Dropdown(
32
+ choices=model_choices,
33
+ value=chatbot.active_model_info['name'] if chatbot.active_model_info else None,
34
+ label="Select LLM Model"
35
+ )
36
+ model_error_output = gr.Warning(visible=False) # Initially hidden warning component
37
+ model_dropdown.change(
38
+ fn=switch_model,
39
+ inputs=model_dropdown,
40
+ outputs=[model_error_output, chatbot_greeting_md] # Output both warning and greeting
41
+ )
42
+
43
+ chatbot_ui = gr.Chatbot()
44
+ msg = gr.Textbox()
45
+ clear = gr.ClearButton([msg, chatbot_ui])
46
+
47
+ msg.submit(respond, [msg, chatbot_ui], [msg, chatbot_ui])
48
+
49
+ demo.launch()
.history/app_20250202072637.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from scripts.chatbot_logic import ProjectGuidanceChatbot
3
+
4
+ # Initialize Chatbot
5
+ chatbot = ProjectGuidanceChatbot(
6
+ roadmap_file="roadmap.yaml",
7
+ rules_file="rules.yaml",
8
+ config_file="configs/chatbot_config.yaml",
9
+ code_templates_dir="scripts/code_templates"
10
+ )
11
+
12
+ def respond(message, chat_history):
13
+ bot_message = chatbot.process_query(message)
14
+ chat_history.append((message, bot_message))
15
+ return "", chat_history
16
+
17
+ def switch_model(model_key):
18
+ model_switch_result = chatbot.switch_llm_model(model_key) # Get result message
19
+ greeting_message = chatbot.get_chatbot_greeting()
20
+
21
+ if "Error:" in model_switch_result: # Check if result contains "Error:"
22
+ return gr.Warning(model_switch_result), greeting_message # Display error as Gradio Warning
23
+ else:
24
+ return None, greeting_message # No warning, just update greeting
25
+
26
+ with gr.Blocks() as demo:
27
+ chatbot_greeting_md = gr.Markdown(chatbot.get_chatbot_greeting())
28
+ gr.Markdown(f"# {chatbot.chatbot_config.get('name', 'Project Guidance Chatbot')}")
29
+
30
+ model_choices = [(model['name'], key) for key, model in chatbot.available_models_config.items()]
31
+ model_dropdown = gr.Dropdown(
32
+ choices=model_choices,
33
+ value=chatbot.active_model_info['name'] if chatbot.active_model_info else None,
34
+ label="Select LLM Model"
35
+ )
36
+ model_error_output = gr.Warning(visible=False) # Initially hidden warning component
37
+ model_dropdown.change(
38
+ fn=switch_model,
39
+ inputs=model_dropdown,
40
+ outputs=[model_error_output, chatbot_greeting_md] # Output both warning and greeting
41
+ )
42
+
43
+ chatbot_ui = gr.Chatbot()
44
+ msg = gr.Textbox()
45
+ clear = gr.ClearButton([msg, chatbot_ui])
46
+
47
+ msg.submit(respond, [msg, chatbot_ui], [msg, chatbot_ui])
48
+
49
+ demo.launch()
.history/app_20250202072640.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from scripts.chatbot_logic import ProjectGuidanceChatbot
3
+
4
+ # Initialize Chatbot
5
+ chatbot = ProjectGuidanceChatbot(
6
+ roadmap_file="roadmap.yaml",
7
+ rules_file="rules.yaml",
8
+ config_file="configs/chatbot_config.yaml",
9
+ code_templates_dir="scripts/code_templates"
10
+ )
11
+
12
+ def respond(message, chat_history):
13
+ bot_message = chatbot.process_query(message)
14
+ chat_history.append((message, bot_message))
15
+ return "", chat_history
16
+
17
+ def switch_model(model_key):
18
+ model_switch_result = chatbot.switch_llm_model(model_key) # Get result message
19
+ greeting_message = chatbot.get_chatbot_greeting()
20
+
21
+ if "Error:" in model_switch_result: # Check if result contains "Error:"
22
+ return gr.Warning(model_switch_result), greeting_message # Display error as Gradio Warning
23
+ else:
24
+ return None, greeting_message # No warning, just update greeting
25
+
26
+ with gr.Blocks() as demo:
27
+ chatbot_greeting_md = gr.Markdown(chatbot.get_chatbot_greeting())
28
+ gr.Markdown(f"# {chatbot.chatbot_config.get('name', 'Project Guidance Chatbot')}")
29
+
30
+ model_choices = [(model['name'], key) for key, model in chatbot.available_models_config.items()]
31
+ model_dropdown = gr.Dropdown(
32
+ choices=model_choices,
33
+ value=chatbot.active_model_info['name'] if chatbot.active_model_info else None,
34
+ label="Select LLM Model"
35
+ )
36
+ model_error_output = gr.Warning(visible=False) # Initially hidden warning component
37
+ model_dropdown.change(
38
+ fn=switch_model,
39
+ inputs=model_dropdown,
40
+ outputs=[model_error_output, chatbot_greeting_md] # Output both warning and greeting
41
+ )
42
+
43
+ chatbot_ui = gr.Chatbot()
44
+ msg = gr.Textbox()
45
+ clear = gr.ClearButton([msg, chatbot_ui])
46
+
47
+ msg.submit(respond, [msg, chatbot_ui], [msg, chatbot_ui])
48
+
49
+ demo.launch()
configs/config.yaml β†’ .history/configs/chatbot_config_20250202065636.yaml RENAMED
File without changes
.history/configs/chatbot_config_20250202071313.yaml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ chatbot:
2
+ name: "Project Guidance Chatbot"
3
+ description: "Your helpful AI assistant for project completion with LLM selection."
4
+ default_llm_model_id: "deepseek-r1-distill-llama-8b" # Default model ID (using keys from 'available_models')
5
+
6
+ available_models:
7
+ deepseek-r1-distill-llama-8b:
8
+ name: "DeepSeek-R1-Distill-Llama-8B"
9
+ model_id: "DeepSeek-AI/DeepSeek-R1-Distill-Llama-8B"
10
+ gemini-flash-01-21: # Using a shorter key for easier referencing in code
11
+ name: "Gemini 2.0 Flash (Exp 01-21)"
12
+ model_id: "google/gemini-2.0-flash-thinking-exp-01-21"
13
+
14
+ model_selection:
15
+ suggested_models: # (Keep suggested models - might be useful later)
16
+ - "mistralai/Mistral-7B-Instruct-v0.2"
17
+ - "google/flan-t5-xl"
18
+ - "facebook/bart-large"
19
+ criteria_prompt: "Consider these criteria when selecting a model: {rules.model_selection}"
20
+
21
+ response_generation:
22
+ error_message: "Sorry, I encountered an issue. Please check your input and project files."
23
+ default_instruction: "How can I help you with your project?"
.history/configs/chatbot_config_20250202071856.yaml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ chatbot:
2
+ name: "Project Guidance Chatbot"
3
+ description: "Your helpful AI assistant for project completion with LLM selection."
4
+ default_llm_model_id: "deepseek-r1-distill-llama-8b" # Default model ID (using keys from 'available_models')
5
+
6
+ available_models:
7
+ deepseek-r1-distill-llama-8b:
8
+ name: "DeepSeek-R1-Distill-Llama-8B"
9
+ model_id: "DeepSeek-AI/DeepSeek-R1-Distill-Llama-8B"
10
+ gemini-flash-01-21: # Using a shorter key for easier referencing in code
11
+ name: "Gemini 2.0 Flash (Exp 01-21)"
12
+ model_id: "google/gemini-2.0-flash-thinking-exp-01-21"
13
+
14
+ model_selection:
15
+ suggested_models: # (Keep suggested models - might be useful later)
16
+ - "mistralai/Mistral-7B-Instruct-v0.2"
17
+ - "google/flan-t5-xl"
18
+ - "facebook/bart-large"
19
+ criteria_prompt: "Consider these criteria when selecting a model: {rules.model_selection}"
20
+
21
+ response_generation:
22
+ error_message: "Sorry, I encountered an issue. Please check your input and project files."
23
+ default_instruction: "How can I help you with your project?"
.history/configs/chatbot_config_20250202072554.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ chatbot:
2
+ name: "Project Guidance Chatbot"
3
+ description: "Your helpful AI assistant for project completion with LLM selection and token control."
4
+ default_llm_model_id: "deepseek-r1-distill-llama-8b"
5
+ max_response_tokens: 200 # Maximum tokens for LLM generated responses
6
+
7
+ available_models:
8
+ deepseek-r1-distill-llama-8b:
9
+ name: "DeepSeek-R1-Distill-Llama-8B"
10
+ model_id: "DeepSeek-AI/DeepSeek-R1-Distill-Llama-8B"
11
+ gemini-flash-01-21:
12
+ name: "Gemini 2.0 Flash (Exp 01-21)"
13
+ model_id: "google/gemini-2.0-flash-thinking-exp-01-21"
14
+
15
+ model_selection:
16
+ suggested_models:
17
+ - "mistralai/Mistral-7B-Instruct-v0.2"
18
+ - "google/flan-t5-xl"
19
+ - "facebook/bart-large"
20
+ criteria_prompt: "Consider these criteria when selecting a model: {rules.model_selection}"
21
+
22
+ response_generation:
23
+ error_message: "Sorry, I encountered an issue. Please check your input and project files."
24
+ default_instruction: "How can I help you with your project?"
.history/details_20250202061415.txt ADDED
File without changes
.history/details_20250202065715.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ custom-llm-project/
2
+ β”œβ”€β”€ data/
3
+ β”‚ └── # (Optional: Datasets or example data - currently empty)
4
+ β”œβ”€β”€ models/
5
+ β”‚ └── # (Optional: Could store cached models or local models in future)
6
+ β”œβ”€β”€ scripts/
7
+ β”‚ β”œβ”€β”€ chatbot_logic.py # Core chatbot logic (parsing, response generation, code gen)
8
+ β”‚ β”œβ”€β”€ parsing_utils.py # Utility functions for parsing roadmap and rules
9
+ β”‚ └── code_templates/ # Directory for code templates
10
+ β”‚ β”œβ”€β”€ preprocessing_template.py.txt
11
+ β”‚ β”œβ”€β”€ training_template.py.txt
12
+ β”‚ β”œβ”€β”€ evaluation_template.py.txt
13
+ β”‚ └── api_template.py.txt
14
+ β”œβ”€β”€ configs/
15
+ β”‚ └── chatbot_config.yaml # Configuration for chatbot behavior, LLM selection, etc.
16
+ β”œβ”€β”€ api/ # (Placeholder for future API integration - currently empty)
17
+ β”œβ”€β”€ roadmap.yaml # Project roadmap (YAML format)
18
+ β”œβ”€β”€ rules.yaml # Project rules (YAML format)
19
+ β”œβ”€β”€ requirements.txt # Python dependencies
20
+ β”œβ”€β”€ app.py # Gradio application script (main entry point for HF Spaces)
21
+ └── README.md # Project README file (documentation)
.history/requirements_20250202065234.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # requirements.txt
2
+ gradio
3
+ PyYAML
.history/requirements_20250202065734.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ PyYAML
3
+ transformers # For interacting with Hugging Face models (if needed directly)
4
+ # Add other dependencies as needed, e.g., for specific LLMs or utilities
.history/requirements_20250202071821.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ PyYAML
3
+ transformers # For interacting with Hugging Face models (if needed directly)
4
+ torch
.history/requirements_20250202071824.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio
2
+ PyYAML
3
+ transformers # For interacting with Hugging Face models (if needed directly)
4
+ torch
.history/scripts/chatbot_logic_20250202065546.py ADDED
File without changes
.history/scripts/chatbot_logic_20250202070001.py ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from scripts.parsing_utils import load_yaml_file, get_roadmap_phases, get_project_rules
2
+ import os
3
+
4
+ class ProjectGuidanceChatbot:
5
+ def __init__(self, roadmap_file, rules_file, config_file, code_templates_dir):
6
+ self.roadmap_file = roadmap_file
7
+ self.rules_file = rules_file
8
+ self.config_file = config_file
9
+ self.code_templates_dir = code_templates_dir
10
+
11
+ self.roadmap_data = load_yaml_file(self.roadmap_file)
12
+ self.rules_data = load_yaml_file(self.rules_file)
13
+ self.config_data = load_yaml_file(self.config_file)
14
+
15
+ self.phases = get_roadmap_phases(self.roadmap_data)
16
+ self.rules = get_project_rules(self.rules_data)
17
+ self.chatbot_config = self.config_data.get('chatbot', {}) if self.config_data else {}
18
+ self.model_config = self.config_data.get('model_selection', {}) if self.config_data else {}
19
+ self.response_config = self.config_data.get('response_generation', {}) if self.config_data else {}
20
+
21
+
22
+ self.current_phase = None # Track current phase (can be improved with state management)
23
+
24
+ def get_chatbot_greeting(self):
25
+ return f"Hello! I am the {self.chatbot_config.get('name', 'Project Guidance Chatbot')}. {self.chatbot_config.get('description', 'How can I help you with your project?')}"
26
+
27
+ def process_query(self, user_query):
28
+ if not self.phases:
29
+ return "Error: Roadmap data not loaded correctly."
30
+ if not self.rules:
31
+ return "Error: Rules data not loaded correctly."
32
+
33
+ query_lower = user_query.lower()
34
+
35
+ if "roadmap" in query_lower:
36
+ return self.get_roadmap_summary()
37
+ if "rules" in query_lower:
38
+ return self.get_rules_summary()
39
+
40
+ if self.current_phase:
41
+ current_phase_data = self.phases.get(self.current_phase)
42
+ if current_phase_data:
43
+ phase_response = self.get_phase_guidance(current_phase_data, user_query)
44
+ if phase_response:
45
+ return phase_response
46
+
47
+ # Basic phase detection based on keywords (improve with more sophisticated NLP)
48
+ for phase_key, phase_data in self.phases.items():
49
+ if phase_data['name'].lower() in query_lower:
50
+ self.current_phase = phase_key # Set current phase if detected
51
+ return self.get_phase_introduction(phase_data)
52
+
53
+ return self.response_config.get('default_instruction', "I can guide you through project phases. Ask me about a specific phase or project aspect.")
54
+
55
+ def get_roadmap_summary(self):
56
+ summary = "Project Roadmap:\n"
57
+ for phase_key, phase_data in self.phases.items():
58
+ summary += f"- **Phase: {phase_data['name']}**\n"
59
+ summary += f" Description: {phase_data['description']}\n"
60
+ summary += f" Milestones: {', '.join(phase_data['milestones'])}\n"
61
+ return summary
62
+
63
+ def get_rules_summary(self):
64
+ summary = "Project Rules:\n"
65
+ for rule_category, rules_list in self.rules.items():
66
+ summary += f"**{rule_category.capitalize()} Rules:**\n"
67
+ for rule_key, rule_text in rules_list.items():
68
+ summary += f"- {rule_text}\n"
69
+ return summary
70
+
71
+ def get_phase_introduction(self, phase_data):
72
+ return f"Okay, let's focus on **Phase: {phase_data['name']}**. \nDescription: {phase_data['description']}. \nKey milestones are: {', '.join(phase_data['milestones'])}. \nWhat would you like to know or do in this phase?"
73
+
74
+ def get_phase_guidance(self, phase_data, user_query):
75
+ query_lower = user_query.lower()
76
+
77
+ if "milestones" in query_lower:
78
+ return "The milestones for this phase are: " + ", ".join(phase_data['milestones'])
79
+ if "actions" in query_lower or "how to" in query_lower:
80
+ if 'actions' in phase_data:
81
+ return "Recommended actions for this phase: " + ", ".join(phase_data['actions'])
82
+ else:
83
+ return "No specific actions are listed for this phase in the roadmap."
84
+ if "code" in query_lower or "script" in query_lower:
85
+ if 'code_generation_hint' in phase_data:
86
+ template_filename_prefix = phase_data['name'].lower().replace(" ", "_")
87
+ template_filepath = os.path.join(self.code_templates_dir, f"{template_filename_prefix}_template.py.txt") # Example template file naming convention
88
+ if os.path.exists(template_filepath):
89
+ code_snippet = self.generate_code_snippet(template_filepath, phase_data) # Pass phase data for potential customization
90
+ return "Here's a starting code snippet for this phase:\n\n```python\n" + code_snippet + "\n```\n\nRemember to adapt it to your specific needs."
91
+ else:
92
+ return f"A code template for this phase ({phase_data['name']}) is not yet available. However, the hint is: {phase_data['code_generation_hint']}"
93
+ else:
94
+ return "No code generation hint is available for this phase."
95
+
96
+ # General guidance based on phase description (can be enhanced with LLM)
97
+ return f"For phase '{phase_data['name']}', remember the description: {phase_data['description']}. Consider the milestones and actions. What specific aspect are you interested in?"
98
+
99
+
100
+ def generate_code_snippet(self, template_filepath, phase_data):
101
+ """Generates code snippet from a template file. (Simple template filling example)"""
102
+ try:
103
+ with open(template_filepath, 'r') as f:
104
+ template_content = f.read()
105
+
106
+ # Simple placeholder replacement - enhance with more sophisticated templating
107
+ code_snippet = template_content.replace("{{phase_name}}", phase_data['name'])
108
+ # Add more dynamic replacements based on phase_data or other context if needed
109
+
110
+ return code_snippet
111
+ except FileNotFoundError:
112
+ return f"Error: Code template file not found at {template_filepath}"
113
+ except Exception as e:
114
+ return f"Error generating code snippet: {e}"
115
+
116
+
117
+ # Example usage (for testing - remove or adjust for app.py)
118
+ if __name__ == '__main__':
119
+ chatbot = ProjectGuidanceChatbot(
120
+ roadmap_file="roadmap.yaml",
121
+ rules_file="rules.yaml",
122
+ config_file="configs/chatbot_config.yaml",
123
+ code_templates_dir="scripts/code_templates"
124
+ )
125
+ print(chatbot.get_chatbot_greeting())
126
+
127
+ while True:
128
+ user_input = input("You: ")
129
+ if user_input.lower() == "exit":
130
+ break
131
+ response = chatbot.process_query(user_input)
132
+ print("Chatbot:", response)
.history/scripts/chatbot_logic_20250202071411.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from scripts.parsing_utils import load_yaml_file, get_roadmap_phases, get_project_rules
2
+ import os
3
+ # Placeholder import for LLM interaction - replace with actual LLM library when integrating
4
+ # from transformers import AutoModelForCausalLM, AutoTokenizer
5
+
6
+ class ProjectGuidanceChatbot:
7
+ def __init__(self, roadmap_file, rules_file, config_file, code_templates_dir):
8
+ self.roadmap_file = roadmap_file
9
+ self.rules_file = rules_file
10
+ self.config_file = config_file
11
+ self.code_templates_dir = code_templates_dir
12
+
13
+ self.roadmap_data = load_yaml_file(self.roadmap_file)
14
+ self.rules_data = load_yaml_file(self.rules_file)
15
+ self.config_data = load_yaml_file(self.config_file)
16
+
17
+ self.phases = get_roadmap_phases(self.roadmap_data)
18
+ self.rules = get_project_rules(self.rules_data)
19
+ self.chatbot_config = self.config_data.get('chatbot', {}) if self.config_data else {}
20
+ self.model_config = self.config_data.get('model_selection', {}) if self.config_data else {}
21
+ self.response_config = self.config_data.get('response_generation', {}) if self.config_data else {}
22
+ self.available_models_config = self.config_data.get('available_models', {}) if self.config_data else {}
23
+
24
+ self.current_phase = None
25
+ self.active_model_key = self.chatbot_config.get('default_llm_model_id') # Get default model key
26
+ self.active_model_info = self.available_models_config.get(self.active_model_key) # Get model info from config
27
+
28
+ # Placeholder for actual model and tokenizer - replace with LLM loading logic
29
+ self.llm_model = None # Placeholder for loaded model
30
+ self.llm_tokenizer = None # Placeholder for tokenizer
31
+ self.load_llm_model(self.active_model_info) # Load initial model
32
+
33
+
34
+ def load_llm_model(self, model_info):
35
+ """Loads the LLM model and tokenizer based on model_info (placeholder)."""
36
+ if not model_info:
37
+ print("Error: Model information not provided.")
38
+ self.llm_model = None
39
+ self.llm_tokenizer = None
40
+ return
41
+
42
+ model_id = model_info.get('model_id')
43
+ model_name = model_info.get('name')
44
+ if not model_id:
45
+ print(f"Error: 'model_id' not found for model: {model_name}")
46
+ self.llm_model = None
47
+ self.llm_tokenizer = None
48
+ return
49
+
50
+ print(f"Loading model: {model_name} ({model_id})... (Placeholder - replace with actual LLM loading)")
51
+ # --- Placeholder for actual LLM loading using transformers (example) ---
52
+ # try:
53
+ # self.llm_tokenizer = AutoTokenizer.from_pretrained(model_id)
54
+ # self.llm_model = AutoModelForCausalLM.from_pretrained(model_id) # Or appropriate model class
55
+ # print(f"Model {model_name} loaded successfully.")
56
+ # except Exception as e:
57
+ # print(f"Error loading model {model_name} ({model_id}): {e}")
58
+ # self.llm_model = None
59
+ # self.llm_tokenizer = None
60
+ # --- End Placeholder ---
61
+ self.active_model_info = model_info # Update active model info
62
+
63
+ def switch_llm_model(self, model_key):
64
+ """Switches the active LLM model based on the provided model key."""
65
+ if model_key in self.available_models_config:
66
+ model_info = self.available_models_config[model_key]
67
+ print(f"Switching LLM model to: {model_info.get('name')}")
68
+ self.load_llm_model(model_info) # Load the new model
69
+ self.active_model_key = model_key # Update active model key
70
+ return f"Switched to model: {model_info.get('name')}"
71
+ else:
72
+ return f"Error: Model key '{model_key}' not found in available models."
73
+
74
+
75
+ def get_chatbot_greeting(self):
76
+ current_model_name = self.active_model_info.get('name', 'Unknown Model') if self.active_model_info else 'Unknown Model'
77
+ return f"Hello! I am the {self.chatbot_config.get('name', 'Project Guidance Chatbot')}. Currently using **{current_model_name}**. {self.chatbot_config.get('description', 'How can I help you with your project?')}"
78
+
79
+ def process_query(self, user_query):
80
+ # ... (rest of the process_query function remains largely the same for roadmap/rules logic) ...
81
+
82
+ if "roadmap" in query_lower:
83
+ return self.get_roadmap_summary()
84
+ if "rules" in query_lower:
85
+ return self.get_rules_summary()
86
+ if "switch model to" in query_lower: # Example command for switching model via text input
87
+ parts = user_query.lower().split("switch model to")
88
+ if len(parts) > 1:
89
+ model_name_or_key = parts[1].strip()
90
+ for key, model_data in self.available_models_config.items():
91
+ if model_data['name'].lower() == model_name_or_key.lower() or key.lower() == model_name_or_key.lower():
92
+ switch_result = self.switch_llm_model(key) # Switch by key
93
+ return switch_result + "\n" + self.get_chatbot_greeting() # Re-greet with new model info
94
+ return f"Model '{model_name_or_key}' not found in available models."
95
+
96
+
97
+ if self.current_phase:
98
+ current_phase_data = self.phases.get(self.current_phase)
99
+ if current_phase_data:
100
+ phase_response = self.get_phase_guidance(current_phase_data, user_query)
101
+ if phase_response:
102
+ return phase_response
103
+
104
+ # Basic phase detection based on keywords
105
+ for phase_key, phase_data in self.phases.items():
106
+ if phase_data['name'].lower() in query_lower:
107
+ self.current_phase = phase_key
108
+ return self.get_phase_introduction(phase_data)
109
+
110
+ # --- Placeholder for LLM-based response generation ---
111
+ # If no specific roadmap/rule logic applies, you could use the LLM here
112
+ # llm_response = self.generate_llm_response(user_query) # Function to interact with LLM
113
+ # if llm_response:
114
+ # return llm_response
115
+
116
+ return self.response_config.get('default_instruction', "I can guide you through project phases. Ask me about a specific phase or project aspect.")
117
+
118
+ # --- Placeholder for LLM response generation function ---
119
+ # def generate_llm_response(self, user_query):
120
+ # """Generates a response using the currently active LLM (placeholder)."""
121
+ # if not self.llm_model or not self.llm_tokenizer:
122
+ # return "LLM model not loaded."
123
+ # try:
124
+ # inputs = self.llm_tokenizer(user_query, return_tensors="pt") # Tokenize
125
+ # outputs = self.llm_model.generate(**inputs) # Generate response
126
+ # response = self.llm_tokenizer.decode(outputs[0], skip_special_tokens=True) # Decode
127
+ # return response
128
+ # except Exception as e:
129
+ # return f"Error generating LLM response: {e}"
130
+
131
+
132
+ # ... (rest of the chatbot logic functions like get_roadmap_summary, get_rules_summary, get_phase_guidance, generate_code_snippet remain largely the same) ...
133
+
134
+
135
+ # Example usage (for testing - remove or adjust for app.py)
136
+ if __name__ == '__main__':
137
+ chatbot = ProjectGuidanceChatbot(
138
+ roadmap_file="roadmap.yaml",
139
+ rules_file="rules.yaml",
140
+ config_file="configs/chatbot_config.yaml",
141
+ code_templates_dir="scripts/code_templates"
142
+ )
143
+ print(chatbot.get_chatbot_greeting())
144
+
145
+ while True:
146
+ user_input = input("You: ")
147
+ if user_input.lower() == "exit":
148
+ break
149
+ response = chatbot.process_query(user_input)
150
+ print("Chatbot:", response)
.history/scripts/chatbot_logic_20250202072003.py ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from scripts.parsing_utils import load_yaml_file, get_roadmap_phases, get_project_rules
2
+ import os
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer # Import necessary classes
4
+
5
+ class ProjectGuidanceChatbot:
6
+ def __init__(self, roadmap_file, rules_file, config_file, code_templates_dir):
7
+ self.roadmap_file = roadmap_file
8
+ self.rules_file = rules_file
9
+ self.config_file = config_file
10
+ self.code_templates_dir = code_templates_dir
11
+
12
+ self.roadmap_data = load_yaml_file(self.roadmap_file)
13
+ self.rules_data = load_yaml_file(self.rules_file)
14
+ self.config_data = load_yaml_file(self.config_file)
15
+
16
+ self.phases = get_roadmap_phases(self.roadmap_data)
17
+ self.rules = get_project_rules(self.rules_data)
18
+ self.chatbot_config = self.config_data.get('chatbot', {}) if self.config_data else {}
19
+ self.model_config = self.config_data.get('model_selection', {}) if self.config_data else {}
20
+ self.response_config = self.config_data.get('response_generation', {}) if self.config_data else {}
21
+ self.available_models_config = self.config_data.get('available_models', {}) if self.config_data else {}
22
+
23
+ self.current_phase = None
24
+ self.active_model_key = self.chatbot_config.get('default_llm_model_id') # Get default model key
25
+ self.active_model_info = self.available_models_config.get(self.active_model_key) # Get model info from config
26
+
27
+ # Placeholder for actual model and tokenizer - replace with LLM loading logic
28
+ self.llm_model = None # Placeholder for loaded model
29
+ self.llm_tokenizer = None # Placeholder for tokenizer
30
+ self.load_llm_model(self.active_model_info) # Load initial model
31
+
32
+
33
+ def load_llm_model(self, model_info):
34
+ """Loads the LLM model and tokenizer based on model_info."""
35
+ if not model_info:
36
+ print("Error: Model information not provided.")
37
+ self.llm_model = None
38
+ self.llm_tokenizer = None
39
+ return
40
+
41
+ model_id = model_info.get('model_id')
42
+ model_name = model_info.get('name')
43
+ if not model_id:
44
+ print(f"Error: 'model_id' not found for model: {model_name}")
45
+ self.llm_model = None
46
+ self.llm_tokenizer = None
47
+ return
48
+
49
+ print(f"Loading model: {model_name} ({model_id})...")
50
+ try:
51
+ self.llm_tokenizer = AutoTokenizer.from_pretrained(model_id)
52
+ self.llm_model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto") # device_map="auto" for GPU/CPU handling
53
+ print(f"Model {model_name} loaded successfully.")
54
+ except Exception as e:
55
+ print(f"Error loading model {model_name} ({model_id}): {e}")
56
+ self.llm_model = None
57
+ self.llm_tokenizer = None
58
+ self.active_model_info = model_info
59
+
60
+ def switch_llm_model(self, model_key):
61
+ """Switches the active LLM model based on the provided model key."""
62
+ if model_key in self.available_models_config:
63
+ model_info = self.available_models_config[model_key]
64
+ print(f"Switching LLM model to: {model_info.get('name')}")
65
+ self.load_llm_model(model_info) # Load the new model
66
+ self.active_model_key = model_key # Update active model key
67
+ return f"Switched to model: {model_info.get('name')}"
68
+ else:
69
+ return f"Error: Model key '{model_key}' not found in available models."
70
+
71
+
72
+ def get_chatbot_greeting(self):
73
+ current_model_name = self.active_model_info.get('name', 'Unknown Model') if self.active_model_info else 'Unknown Model'
74
+ return f"Hello! I am the {self.chatbot_config.get('name', 'Project Guidance Chatbot')}. Currently using **{current_model_name}**. {self.chatbot_config.get('description', 'How can I help you with your project?')}"
75
+
76
+ def generate_llm_response(self, user_query):
77
+ """Generates a response using the currently active LLM."""
78
+ if not self.llm_model or not self.llm_tokenizer:
79
+ return "LLM model not loaded. Please select a model."
80
+ try:
81
+ inputs = self.llm_tokenizer(user_query, return_tensors="pt").to(self.llm_model.device) # Tokenize and move to model's device
82
+ outputs = self.llm_model.generate(**inputs, max_length=200, num_beams=5, no_repeat_ngram_size=2, early_stopping=True) # Example generation parameters
83
+ response = self.llm_tokenizer.decode(outputs[0], skip_special_tokens=True) # Decode
84
+ return response
85
+ except Exception as e:
86
+ print(f"Error generating LLM response: {e}")
87
+ return f"Error generating response from LLM: {e}"
88
+
89
+ def process_query(self, user_query):
90
+ if not self.phases:
91
+ return "Error: Roadmap data not loaded correctly."
92
+ if not self.rules:
93
+ return "Error: Rules data not loaded correctly."
94
+
95
+ query_lower = user_query.lower()
96
+
97
+ if "roadmap" in query_lower:
98
+ return self.get_roadmap_summary()
99
+ if "rules" in query_lower:
100
+ return self.get_rules_summary()
101
+ if "switch model to" in query_lower: # Example command for switching model via text input
102
+ parts = user_query.lower().split("switch model to")
103
+ if len(parts) > 1:
104
+ model_name_or_key = parts[1].strip()
105
+ for key, model_data in self.available_models_config.items():
106
+ if model_data['name'].lower() == model_name_or_key.lower() or key.lower() == model_name_or_key.lower():
107
+ switch_result = self.switch_llm_model(key) # Switch by key
108
+ return switch_result + "\n" + self.get_chatbot_greeting() # Re-greet with new model info
109
+ return f"Model '{model_name_or_key}' not found in available models."
110
+
111
+
112
+ if self.current_phase:
113
+ current_phase_data = self.phases.get(self.current_phase)
114
+ if current_phase_data:
115
+ phase_response = self.get_phase_guidance(current_phase_data, user_query)
116
+ if phase_response:
117
+ return phase_response
118
+
119
+ # Basic phase detection based on keywords
120
+ for phase_key, phase_data in self.phases.items():
121
+ if phase_data['name'].lower() in query_lower:
122
+ self.current_phase = phase_key
123
+ return self.get_phase_introduction(phase_data)
124
+
125
+ # --- After roadmap/rules logic, try LLM response if no specific guidance found ---
126
+ llm_response = self.generate_llm_response(user_query)
127
+ if llm_response:
128
+ return llm_response
129
+
130
+ return self.response_config.get('default_instruction', "I can guide you through project phases. Ask me about a specific phase or project aspect.")
131
+
132
+ def get_roadmap_summary(self):
133
+ summary = "Project Roadmap:\n"
134
+ for phase_key, phase_data in self.phases.items():
135
+ summary += f"- **Phase: {phase_data['name']}**\n"
136
+ summary += f" Description: {phase_data['description']}\n"
137
+ summary += f" Milestones: {', '.join(phase_data['milestones'])}\n"
138
+ return summary
139
+
140
+ def get_rules_summary(self):
141
+ summary = "Project Rules:\n"
142
+ for rule_category, rules_list in self.rules.items():
143
+ summary += f"**{rule_category.capitalize()} Rules:**\n"
144
+ for rule_key, rule_text in rules_list.items():
145
+ summary += f"- {rule_text}\n"
146
+ return summary
147
+
148
+ def get_phase_introduction(self, phase_data):
149
+ return f"Okay, let's focus on **Phase: {phase_data['name']}**. \nDescription: {phase_data['description']}. \nKey milestones are: {', '.join(phase_data['milestones'])}. \nWhat would you like to know or do in this phase?"
150
+
151
+ def get_phase_guidance(self, phase_data, user_query):
152
+ query_lower = user_query.lower()
153
+
154
+ if "milestones" in query_lower:
155
+ return "The milestones for this phase are: " + ", ".join(phase_data['milestones'])
156
+ if "actions" in query_lower or "how to" in query_lower:
157
+ if 'actions' in phase_data:
158
+ return "Recommended actions for this phase: " + ", ".join(phase_data['actions'])
159
+ else:
160
+ return "No specific actions are listed for this phase in the roadmap."
161
+ if "code" in query_lower or "script" in query_lower:
162
+ if 'code_generation_hint' in phase_data:
163
+ template_filename_prefix = phase_data['name'].lower().replace(" ", "_")
164
+ template_filepath = os.path.join(self.code_templates_dir, f"{template_filename_prefix}_template.py.txt") # Example template file naming convention
165
+ if os.path.exists(template_filepath):
166
+ code_snippet = self.generate_code_snippet(template_filepath, phase_data) # Pass phase data for potential customization
167
+ return "Here's a starting code snippet for this phase:\n\n```python\n" + code_snippet + "\n```\n\nRemember to adapt it to your specific needs."
168
+ else:
169
+ return f"A code template for this phase ({phase_data['name']}) is not yet available. However, the hint is: {phase_data['code_generation_hint']}"
170
+ else:
171
+ return "No code generation hint is available for this phase."
172
+
173
+ # General guidance based on phase description (can be enhanced with LLM)
174
+ return f"For phase '{phase_data['name']}', remember the description: {phase_data['description']}. Consider the milestones and actions. What specific aspect are you interested in?"
175
+
176
+
177
+ def generate_code_snippet(self, template_filepath, phase_data):
178
+ """Generates code snippet from a template file. (Simple template filling example)"""
179
+ try:
180
+ with open(template_filepath, 'r') as f:
181
+ template_content = f.read()
182
+
183
+ # Simple placeholder replacement - enhance with more sophisticated templating
184
+ code_snippet = template_content.replace("{{phase_name}}", phase_data['name'])
185
+ # Add more dynamic replacements based on phase_data or other context if needed
186
+
187
+ return code_snippet
188
+ except FileNotFoundError:
189
+ return f"Error: Code template file not found at {template_filepath}"
190
+ except Exception as e:
191
+ return f"Error generating code snippet: {e}"
192
+
193
+
194
+ # Example usage (for testing - remove or adjust for app.py)
195
+ if __name__ == '__main__':
196
+ chatbot = ProjectGuidanceChatbot(
197
+ roadmap_file="roadmap.yaml",
198
+ rules_file="rules.yaml",
199
+ config_file="configs/chatbot_config.yaml",
200
+ code_templates_dir="scripts/code_templates"
201
+ )
202
+ print(chatbot.get_chatbot_greeting())
203
+
204
+ while True:
205
+ user_input = input("You: ")
206
+ if user_input.lower() == "exit":
207
+ break
208
+ response = chatbot.process_query(user_input)
209
+ print("Chatbot:", response)
.history/scripts/chatbot_logic_20250202072623.py ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from scripts.parsing_utils import load_yaml_file, get_roadmap_phases, get_project_rules
2
+ import os
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer # Import necessary classes
4
+
5
+ class ProjectGuidanceChatbot:
6
+ def __init__(self, roadmap_file, rules_file, config_file, code_templates_dir):
7
+ self.roadmap_file = roadmap_file
8
+ self.rules_file = rules_file
9
+ self.config_file = config_file
10
+ self.code_templates_dir = code_templates_dir
11
+
12
+ self.roadmap_data = load_yaml_file(self.roadmap_file)
13
+ self.rules_data = load_yaml_file(self.rules_file)
14
+ self.config_data = load_yaml_file(self.config_file)
15
+
16
+ self.phases = get_roadmap_phases(self.roadmap_data)
17
+ self.rules = get_project_rules(self.rules_data)
18
+ self.chatbot_config = self.config_data.get('chatbot', {}) if self.config_data else {}
19
+ self.model_config = self.config_data.get('model_selection', {}) if self.config_data else {}
20
+ self.response_config = self.config_data.get('response_generation', {}) if self.config_data else {}
21
+ self.available_models_config = self.config_data.get('available_models', {}) if self.config_data else {}
22
+
23
+ self.current_phase = None
24
+ self.active_model_key = self.chatbot_config.get('default_llm_model_id') # Get default model key
25
+ self.active_model_info = self.available_models_config.get(self.active_model_key) # Get model info from config
26
+ self.max_response_tokens = self.chatbot_config.get('max_response_tokens', 200) # Get max tokens from config
27
+
28
+ self.llm_model = None
29
+ self.llm_tokenizer = None
30
+ self.load_llm_model(self.active_model_info)
31
+
32
+
33
+ def load_llm_model(self, model_info):
34
+ """Loads the LLM model and tokenizer based on model_info."""
35
+ if not model_info:
36
+ print("Error: Model information not provided.")
37
+ self.llm_model = None
38
+ self.llm_tokenizer = None
39
+ return
40
+
41
+ model_id = model_info.get('model_id')
42
+ model_name = model_info.get('name')
43
+ if not model_id:
44
+ print(f"Error: 'model_id' not found for model: {model_name}")
45
+ self.llm_model = None
46
+ self.llm_tokenizer = None
47
+ return
48
+
49
+ print(f"Loading model: {model_name} ({model_id})...")
50
+ try:
51
+ self.llm_tokenizer = AutoTokenizer.from_pretrained(model_id)
52
+ self.llm_model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto") # device_map="auto" for GPU/CPU handling
53
+ print(f"Model {model_name} loaded successfully.")
54
+ except Exception as e:
55
+ print(f"Error loading model {model_name} ({model_id}): {e}")
56
+ self.llm_model = None
57
+ self.llm_tokenizer = None
58
+ self.active_model_info = model_info
59
+
60
+ def switch_llm_model(self, model_key):
61
+ """Switches the active LLM model based on the provided model key."""
62
+ if model_key in self.available_models_config:
63
+ model_info = self.available_models_config[model_key]
64
+ print(f"Switching LLM model to: {model_info.get('name')}")
65
+ self.load_llm_model(model_info)
66
+ self.active_model_key = model_key
67
+ return f"Switched to model: {model_info.get('name')}"
68
+ else:
69
+ return f"Error: Model key '{model_key}' not found in available models."
70
+
71
+
72
+ def get_chatbot_greeting(self):
73
+ current_model_name = self.active_model_info.get('name', 'Unknown Model') if self.active_model_info else 'Unknown Model'
74
+ return f"Hello! I am the {self.chatbot_config.get('name', 'Project Guidance Chatbot')}. Currently using **{current_model_name}**. Max response tokens: {self.max_response_tokens}. {self.chatbot_config.get('description', 'How can I help you with your project?')}"
75
+
76
+ def generate_llm_response(self, user_query):
77
+ """Generates a response using the currently active LLM."""
78
+ if not self.llm_model or not self.llm_tokenizer:
79
+ return "LLM model not loaded. Please select a model."
80
+ try:
81
+ inputs = self.llm_tokenizer(user_query, return_tensors="pt").to(self.llm_model.device)
82
+ outputs = self.llm_model.generate(**inputs, max_length=self.max_response_tokens, num_beams=5, no_repeat_ngram_size=2, early_stopping=True) # Use max_response_tokens
83
+ response = self.llm_tokenizer.decode(outputs[0], skip_special_tokens=True)
84
+ return response
85
+ except Exception as e:
86
+ print(f"Error generating LLM response: {e}")
87
+ return f"Error generating response from LLM: {e}"
88
+
89
+ def process_query(self, user_query):
90
+ if not self.phases:
91
+ return "Error: Roadmap data not loaded correctly."
92
+ if not self.rules:
93
+ return "Error: Rules data not loaded correctly."
94
+
95
+ query_lower = user_query.lower()
96
+
97
+ if "roadmap" in query_lower:
98
+ return self.get_roadmap_summary()
99
+ if "rules" in query_lower:
100
+ return self.get_rules_summary()
101
+ if "switch model to" in query_lower:
102
+ parts = user_query.lower().split("switch model to")
103
+ if len(parts) > 1:
104
+ model_name_or_key = parts[1].strip()
105
+ for key, model_data in self.available_models_config.items():
106
+ if model_data['name'].lower() == model_name_or_key.lower() or key.lower() == model_name_or_key.lower():
107
+ switch_result = self.switch_llm_model(key)
108
+ return switch_result + "\n" + self.get_chatbot_greeting()
109
+ return f"Model '{model_name_or_key}' not found in available models."
110
+
111
+
112
+ if self.current_phase:
113
+ current_phase_data = self.phases.get(self.current_phase)
114
+ if current_phase_data:
115
+ phase_response = self.get_phase_guidance(current_phase_data, user_query)
116
+ if phase_response:
117
+ return phase_response
118
+
119
+ for phase_key, phase_data in self.phases.items():
120
+ if phase_data['name'].lower() in query_lower:
121
+ self.current_phase = phase_key
122
+ return self.get_phase_introduction(phase_data)
123
+
124
+ llm_response = self.generate_llm_response(user_query)
125
+ if llm_response:
126
+ return llm_response
127
+
128
+ return self.response_config.get('default_instruction', "I can guide you through project phases. Ask me about a specific phase or project aspect.")
129
+
130
+ def get_roadmap_summary(self):
131
+ summary = "Project Roadmap:\n"
132
+ for phase_key, phase_data in self.phases.items():
133
+ summary += f"- **Phase: {phase_data['name']}**\n"
134
+ summary += f" Description: {phase_data['description']}\n"
135
+ summary += f" Milestones: {', '.join(phase_data['milestones'])}\n"
136
+ return summary
137
+
138
+ def get_rules_summary(self):
139
+ summary = "Project Rules:\n"
140
+ for rule_category, rules_list in self.rules.items():
141
+ summary += f"**{rule_category.capitalize()} Rules:**\n"
142
+ for rule_key, rule_text in rules_list.items():
143
+ summary += f"- {rule_text}\n"
144
+ return summary
145
+
146
+ def get_phase_introduction(self, phase_data):
147
+ return f"Okay, let's focus on **Phase: {phase_data['name']}**. \nDescription: {phase_data['description']}. \nKey milestones are: {', '.join(phase_data['milestones'])}. \nWhat would you like to know or do in this phase?"
148
+
149
+ def get_phase_guidance(self, phase_data, user_query):
150
+ query_lower = user_query.lower()
151
+
152
+ if "milestones" in query_lower:
153
+ return "The milestones for this phase are: " + ", ".join(phase_data['milestones'])
154
+ if "actions" in query_lower or "how to" in query_lower:
155
+ if 'actions' in phase_data:
156
+ return "Recommended actions for this phase: " + ", ".join(phase_data['actions'])
157
+ else:
158
+ return "No specific actions are listed for this phase in the roadmap."
159
+ if "code" in query_lower or "script" in query_lower:
160
+ if 'code_generation_hint' in phase_data:
161
+ template_filename_prefix = phase_data['name'].lower().replace(" ", "_")
162
+ template_filepath = os.path.join(self.code_templates_dir, f"{template_filename_prefix}_template.py.txt")
163
+ if os.path.exists(template_filepath):
164
+ code_snippet = self.generate_code_snippet(template_filepath, phase_data)
165
+ return "Here's a starting code snippet for this phase:\n\n```python\n" + code_snippet + "\n```\n\nRemember to adapt it to your specific needs."
166
+ else:
167
+ return f"A code template for this phase ({phase_data['name']}) is not yet available. However, the hint is: {phase_data['code_generation_hint']}"
168
+ else:
169
+ return "No code generation hint is available for this phase."
170
+
171
+ return f"For phase '{phase_data['name']}', remember the description: {phase_data['description']}. Consider the milestones and actions. What specific aspect are you interested in?"
172
+
173
+
174
+ def generate_code_snippet(self, template_filepath, phase_data):
175
+ """Generates code snippet from a template file. (Simple template filling example)"""
176
+ try:
177
+ with open(template_filepath, 'r') as f:
178
+ template_content = f.read()
179
+
180
+ code_snippet = template_content.replace("{{phase_name}}", phase_data['name'])
181
+ return code_snippet
182
+ except FileNotFoundError:
183
+ return f"Error: Code template file not found at {template_filepath}"
184
+ except Exception as e:
185
+ return f"Error generating code snippet: {e}"
186
+
187
+
188
+ # Example usage (for testing - remove or adjust for app.py)
189
+ if __name__ == '__main__':
190
+ chatbot = ProjectGuidanceChatbot(
191
+ roadmap_file="roadmap.yaml",
192
+ rules_file="rules.yaml",
193
+ config_file="configs/chatbot_config.yaml",
194
+ code_templates_dir="scripts/code_templates"
195
+ )
196
+ print(chatbot.get_chatbot_greeting())
197
+
198
+ while True:
199
+ user_input = input("You: ")
200
+ if user_input.lower() == "exit":
201
+ break
202
+ response = chatbot.process_query(user_input)
203
+ print("Chatbot:", response)
.history/scripts/chatbot_logic_20250202072626.py ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from scripts.parsing_utils import load_yaml_file, get_roadmap_phases, get_project_rules
2
+ import os
3
+ from transformers import AutoModelForCausalLM, AutoTokenizer # Import necessary classes
4
+
5
+ class ProjectGuidanceChatbot:
6
+ def __init__(self, roadmap_file, rules_file, config_file, code_templates_dir):
7
+ self.roadmap_file = roadmap_file
8
+ self.rules_file = rules_file
9
+ self.config_file = config_file
10
+ self.code_templates_dir = code_templates_dir
11
+
12
+ self.roadmap_data = load_yaml_file(self.roadmap_file)
13
+ self.rules_data = load_yaml_file(self.rules_file)
14
+ self.config_data = load_yaml_file(self.config_file)
15
+
16
+ self.phases = get_roadmap_phases(self.roadmap_data)
17
+ self.rules = get_project_rules(self.rules_data)
18
+ self.chatbot_config = self.config_data.get('chatbot', {}) if self.config_data else {}
19
+ self.model_config = self.config_data.get('model_selection', {}) if self.config_data else {}
20
+ self.response_config = self.config_data.get('response_generation', {}) if self.config_data else {}
21
+ self.available_models_config = self.config_data.get('available_models', {}) if self.config_data else {}
22
+
23
+ self.current_phase = None
24
+ self.active_model_key = self.chatbot_config.get('default_llm_model_id') # Get default model key
25
+ self.active_model_info = self.available_models_config.get(self.active_model_key) # Get model info from config
26
+ self.max_response_tokens = self.chatbot_config.get('max_response_tokens', 200) # Get max tokens from config
27
+
28
+ self.llm_model = None
29
+ self.llm_tokenizer = None
30
+ self.load_llm_model(self.active_model_info)
31
+
32
+
33
+ def load_llm_model(self, model_info):
34
+ """Loads the LLM model and tokenizer based on model_info."""
35
+ if not model_info:
36
+ print("Error: Model information not provided.")
37
+ self.llm_model = None
38
+ self.llm_tokenizer = None
39
+ return
40
+
41
+ model_id = model_info.get('model_id')
42
+ model_name = model_info.get('name')
43
+ if not model_id:
44
+ print(f"Error: 'model_id' not found for model: {model_name}")
45
+ self.llm_model = None
46
+ self.llm_tokenizer = None
47
+ return
48
+
49
+ print(f"Loading model: {model_name} ({model_id})...")
50
+ try:
51
+ self.llm_tokenizer = AutoTokenizer.from_pretrained(model_id)
52
+ self.llm_model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto") # device_map="auto" for GPU/CPU handling
53
+ print(f"Model {model_name} loaded successfully.")
54
+ except Exception as e:
55
+ print(f"Error loading model {model_name} ({model_id}): {e}")
56
+ self.llm_model = None
57
+ self.llm_tokenizer = None
58
+ self.active_model_info = model_info
59
+
60
+ def switch_llm_model(self, model_key):
61
+ """Switches the active LLM model based on the provided model key."""
62
+ if model_key in self.available_models_config:
63
+ model_info = self.available_models_config[model_key]
64
+ print(f"Switching LLM model to: {model_info.get('name')}")
65
+ self.load_llm_model(model_info)
66
+ self.active_model_key = model_key
67
+ return f"Switched to model: {model_info.get('name')}"
68
+ else:
69
+ return f"Error: Model key '{model_key}' not found in available models."
70
+
71
+
72
+ def get_chatbot_greeting(self):
73
+ current_model_name = self.active_model_info.get('name', 'Unknown Model') if self.active_model_info else 'Unknown Model'
74
+ return f"Hello! I am the {self.chatbot_config.get('name', 'Project Guidance Chatbot')}. Currently using **{current_model_name}**. Max response tokens: {self.max_response_tokens}. {self.chatbot_config.get('description', 'How can I help you with your project?')}"
75
+
76
+ def generate_llm_response(self, user_query):
77
+ """Generates a response using the currently active LLM."""
78
+ if not self.llm_model or not self.llm_tokenizer:
79
+ return "LLM model not loaded. Please select a model."
80
+ try:
81
+ inputs = self.llm_tokenizer(user_query, return_tensors="pt").to(self.llm_model.device)
82
+ outputs = self.llm_model.generate(**inputs, max_length=self.max_response_tokens, num_beams=5, no_repeat_ngram_size=2, early_stopping=True) # Use max_response_tokens
83
+ response = self.llm_tokenizer.decode(outputs[0], skip_special_tokens=True)
84
+ return response
85
+ except Exception as e:
86
+ print(f"Error generating LLM response: {e}")
87
+ return f"Error generating response from LLM: {e}"
88
+
89
+ def process_query(self, user_query):
90
+ if not self.phases:
91
+ return "Error: Roadmap data not loaded correctly."
92
+ if not self.rules:
93
+ return "Error: Rules data not loaded correctly."
94
+
95
+ query_lower = user_query.lower()
96
+
97
+ if "roadmap" in query_lower:
98
+ return self.get_roadmap_summary()
99
+ if "rules" in query_lower:
100
+ return self.get_rules_summary()
101
+ if "switch model to" in query_lower:
102
+ parts = user_query.lower().split("switch model to")
103
+ if len(parts) > 1:
104
+ model_name_or_key = parts[1].strip()
105
+ for key, model_data in self.available_models_config.items():
106
+ if model_data['name'].lower() == model_name_or_key.lower() or key.lower() == model_name_or_key.lower():
107
+ switch_result = self.switch_llm_model(key)
108
+ return switch_result + "\n" + self.get_chatbot_greeting()
109
+ return f"Model '{model_name_or_key}' not found in available models."
110
+
111
+
112
+ if self.current_phase:
113
+ current_phase_data = self.phases.get(self.current_phase)
114
+ if current_phase_data:
115
+ phase_response = self.get_phase_guidance(current_phase_data, user_query)
116
+ if phase_response:
117
+ return phase_response
118
+
119
+ for phase_key, phase_data in self.phases.items():
120
+ if phase_data['name'].lower() in query_lower:
121
+ self.current_phase = phase_key
122
+ return self.get_phase_introduction(phase_data)
123
+
124
+ llm_response = self.generate_llm_response(user_query)
125
+ if llm_response:
126
+ return llm_response
127
+
128
+ return self.response_config.get('default_instruction', "I can guide you through project phases. Ask me about a specific phase or project aspect.")
129
+
130
+ def get_roadmap_summary(self):
131
+ summary = "Project Roadmap:\n"
132
+ for phase_key, phase_data in self.phases.items():
133
+ summary += f"- **Phase: {phase_data['name']}**\n"
134
+ summary += f" Description: {phase_data['description']}\n"
135
+ summary += f" Milestones: {', '.join(phase_data['milestones'])}\n"
136
+ return summary
137
+
138
+ def get_rules_summary(self):
139
+ summary = "Project Rules:\n"
140
+ for rule_category, rules_list in self.rules.items():
141
+ summary += f"**{rule_category.capitalize()} Rules:**\n"
142
+ for rule_key, rule_text in rules_list.items():
143
+ summary += f"- {rule_text}\n"
144
+ return summary
145
+
146
+ def get_phase_introduction(self, phase_data):
147
+ return f"Okay, let's focus on **Phase: {phase_data['name']}**. \nDescription: {phase_data['description']}. \nKey milestones are: {', '.join(phase_data['milestones'])}. \nWhat would you like to know or do in this phase?"
148
+
149
+ def get_phase_guidance(self, phase_data, user_query):
150
+ query_lower = user_query.lower()
151
+
152
+ if "milestones" in query_lower:
153
+ return "The milestones for this phase are: " + ", ".join(phase_data['milestones'])
154
+ if "actions" in query_lower or "how to" in query_lower:
155
+ if 'actions' in phase_data:
156
+ return "Recommended actions for this phase: " + ", ".join(phase_data['actions'])
157
+ else:
158
+ return "No specific actions are listed for this phase in the roadmap."
159
+ if "code" in query_lower or "script" in query_lower:
160
+ if 'code_generation_hint' in phase_data:
161
+ template_filename_prefix = phase_data['name'].lower().replace(" ", "_")
162
+ template_filepath = os.path.join(self.code_templates_dir, f"{template_filename_prefix}_template.py.txt")
163
+ if os.path.exists(template_filepath):
164
+ code_snippet = self.generate_code_snippet(template_filepath, phase_data)
165
+ return "Here's a starting code snippet for this phase:\n\n```python\n" + code_snippet + "\n```\n\nRemember to adapt it to your specific needs."
166
+ else:
167
+ return f"A code template for this phase ({phase_data['name']}) is not yet available. However, the hint is: {phase_data['code_generation_hint']}"
168
+ else:
169
+ return "No code generation hint is available for this phase."
170
+
171
+ return f"For phase '{phase_data['name']}', remember the description: {phase_data['description']}. Consider the milestones and actions. What specific aspect are you interested in?"
172
+
173
+
174
+ def generate_code_snippet(self, template_filepath, phase_data):
175
+ """Generates code snippet from a template file. (Simple template filling example)"""
176
+ try:
177
+ with open(template_filepath, 'r') as f:
178
+ template_content = f.read()
179
+
180
+ code_snippet = template_content.replace("{{phase_name}}", phase_data['name'])
181
+ return code_snippet
182
+ except FileNotFoundError:
183
+ return f"Error: Code template file not found at {template_filepath}"
184
+ except Exception as e:
185
+ return f"Error generating code snippet: {e}"
186
+
187
+
188
+ # Example usage (for testing - remove or adjust for app.py)
189
+ if __name__ == '__main__':
190
+ chatbot = ProjectGuidanceChatbot(
191
+ roadmap_file="roadmap.yaml",
192
+ rules_file="rules.yaml",
193
+ config_file="configs/chatbot_config.yaml",
194
+ code_templates_dir="scripts/code_templates"
195
+ )
196
+ print(chatbot.get_chatbot_greeting())
197
+
198
+ while True:
199
+ user_input = input("You: ")
200
+ if user_input.lower() == "exit":
201
+ break
202
+ response = chatbot.process_query(user_input)
203
+ print("Chatbot:", response)
.history/scripts/code_templates/api_template.py_20250202065623.txt ADDED
File without changes
.history/scripts/code_templates/api_template.py_20250202070107.txt ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for API integration script for {{phase_name}} (using Flask example)
2
+
3
+ from flask import Flask, request, jsonify
4
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
5
+ import torch # Example PyTorch
6
+
7
+ app = Flask(__name__)
8
+
9
+ # --- Model and Tokenizer Loading ---
10
+ model_name = "models/fine_tuned_model" # Replace with your actual model path
11
+ tokenizer_name = "bert-base-uncased" # Replace with the tokenizer used for training, likely the base model tokenizer
12
+ try:
13
+ tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
14
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
15
+ print("Model and tokenizer loaded successfully.")
16
+ model.eval() # Set model to evaluation mode
17
+ except Exception as e:
18
+ print(f"Error loading model or tokenizer: {e}")
19
+ tokenizer = None
20
+ model = None
21
+
22
+
23
+ @app.route('/predict', methods=['POST'])
24
+ def predict():
25
+ if not tokenizer or not model:
26
+ return jsonify({"error": "Model or tokenizer not loaded."}), 500
27
+
28
+ try:
29
+ data = request.get_json()
30
+ text = data.get('text')
31
+
32
+ if not text:
33
+ return jsonify({"error": "No text input provided."}), 400
34
+
35
+ inputs = tokenizer(text, padding=True, truncation=True, return_tensors="pt") # Tokenize input text
36
+
37
+ with torch.no_grad(): # Inference mode
38
+ outputs = model(**inputs)
39
+ logits = outputs.logits
40
+ predicted_class_id = torch.argmax(logits, dim=-1).item() # Get predicted class
41
+
42
+ # --- Map class ID to label (if applicable) ---
43
+ # Example for binary classification (class 0 and 1)
44
+ labels = ["Negative", "Positive"] # Replace with your actual labels
45
+ predicted_label = labels[predicted_class_id] if predicted_class_id < len(labels) else f"Class {predicted_class_id}"
46
+
47
+
48
+ return jsonify({"prediction": predicted_label, "class_id": predicted_class_id})
49
+
50
+ except Exception as e:
51
+ print(f"Prediction error: {e}")
52
+ return jsonify({"error": "Error during prediction."}), 500
53
+
54
+ @app.route('/', methods=['GET'])
55
+ def health_check():
56
+ return jsonify({"status": "API is healthy"}), 200
57
+
58
+
59
+ if __name__ == '__main__':
60
+ app.run(debug=False, host='0.0.0.0', port=5000) # Run Flask app
.history/scripts/code_templates/api_template.py_20250202072103.txt ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for API integration script for {{phase_name}} (using Flask example)
2
+
3
+ from flask import Flask, request, jsonify
4
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
5
+ import torch # Example PyTorch
6
+
7
+ app = Flask(__name__)
8
+
9
+ # --- Model and Tokenizer Loading ---
10
+ model_name = "models/fine_tuned_model" # Replace with your actual model path
11
+ tokenizer_name = "bert-base-uncased" # Replace with the tokenizer used for training, likely the base model tokenizer
12
+ try:
13
+ tokenizer = AutoTokenizer.from_pretrained(tokenizer_name)
14
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
15
+ print("Model and tokenizer loaded successfully.")
16
+ model.eval() # Set model to evaluation mode
17
+ except Exception as e:
18
+ print(f"Error loading model or tokenizer: {e}")
19
+ tokenizer = None
20
+ model = None
21
+
22
+
23
+ @app.route('/predict', methods=['POST'])
24
+ def predict():
25
+ if not tokenizer or not model:
26
+ return jsonify({"error": "Model or tokenizer not loaded."}), 500
27
+
28
+ try:
29
+ data = request.get_json()
30
+ text = data.get('text')
31
+
32
+ if not text:
33
+ return jsonify({"error": "No text input provided."}), 400
34
+
35
+ inputs = tokenizer(text, padding=True, truncation=True, return_tensors="pt") # Tokenize input text
36
+
37
+ with torch.no_grad(): # Inference mode
38
+ outputs = model(**inputs)
39
+ logits = outputs.logits
40
+ predicted_class_id = torch.argmax(logits, dim=-1).item() # Get predicted class
41
+
42
+ # --- Map class ID to label (if applicable) ---
43
+ # Example for binary classification (class 0 and 1)
44
+ labels = ["Negative", "Positive"] # Replace with your actual labels
45
+ predicted_label = labels[predicted_class_id] if predicted_class_id < len(labels) else f"Class {predicted_class_id}"
46
+
47
+
48
+ return jsonify({"prediction": predicted_label, "class_id": predicted_class_id})
49
+
50
+ except Exception as e:
51
+ print(f"Prediction error: {e}")
52
+ return jsonify({"error": "Error during prediction."}), 500
53
+
54
+ @app.route('/', methods=['GET'])
55
+ def health_check():
56
+ return jsonify({"status": "API is healthy"}), 200
57
+
58
+
59
+ if __name__ == '__main__':
60
+ app.run(debug=False, host='0.0.0.0', port=5000) # Run Flask app
.history/scripts/code_templates/evaluation_template.py_20250202065617.txt ADDED
File without changes
.history/scripts/code_templates/evaluation_template.py_20250202070058.txt ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for model evaluation script for {{phase_name}}
2
+
3
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
4
+ from datasets import load_dataset # Example datasets library
5
+ from sklearn.metrics import accuracy_score, classification_report # Example metrics
6
+ import torch # Example PyTorch
7
+ # Add other necessary imports
8
+
9
+ def evaluate_model(model_path, dataset_path, model_name="bert-base-uncased"):
10
+ """
11
+ Evaluates a trained model on a dataset.
12
+ """
13
+ try:
14
+ # Load dataset for evaluation (replace with your actual dataset loading)
15
+ dataset = load_dataset('csv', data_files=dataset_path) # Example: CSV dataset loading, replace with your dataset format
16
+
17
+ print("Evaluation dataset loaded. Loading model and tokenizer...")
18
+
19
+ tokenizer = AutoTokenizer.from_pretrained(model_name) # Use base model tokenizer (or fine-tuned tokenizer if saved separately)
20
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
21
+
22
+ def tokenize_function(examples):
23
+ return tokenizer(examples["text_column"], padding="max_length", truncation=True) # Example: tokenize 'text_column'
24
+
25
+ tokenized_datasets = dataset.map(tokenize_function, batched=True)
26
+
27
+ def compute_metrics(eval_pred):
28
+ predictions, labels = eval_pred
29
+ predictions = predictions.argmax(axis=-1)
30
+ accuracy = accuracy_score(labels, predictions)
31
+ report = classification_report(labels, predictions, output_dict=True) # Detailed report
32
+ return {"accuracy": accuracy, "classification_report": report}
33
+
34
+ training_args = TrainingArguments(
35
+ output_dir="./evaluation_results",
36
+ per_device_eval_batch_size=64,
37
+ logging_dir='./eval_logs',
38
+ )
39
+
40
+ trainer = Trainer(
41
+ model=model,
42
+ args=training_args,
43
+ eval_dataset=tokenized_datasets["validation"], # Assuming 'validation' split exists
44
+ compute_metrics=compute_metrics,
45
+ tokenizer=tokenizer
46
+ )
47
+
48
+ evaluation_results = trainer.evaluate()
49
+
50
+ print("Model evaluation completed.")
51
+ print("Evaluation Results:")
52
+ print(f"Accuracy: {evaluation_results['eval_accuracy']}")
53
+ print("Classification Report:\n", evaluation_results['eval_classification_report'])
54
+
55
+
56
+ except FileNotFoundError:
57
+ print(f"Error: Dataset file or model files not found.")
58
+ except Exception as e:
59
+ print(f"Error during model evaluation: {e}")
60
+
61
+
62
+ if __name__ == "__main__":
63
+ model_filepath = "models/fine_tuned_model" # Replace with your model path
64
+ evaluation_data_filepath = "data/evaluation_dataset.csv" # Replace with your evaluation data path
65
+ base_model_name = "bert-base-uncased" # Replace with your base model name
66
+
67
+ evaluate_model(model_filepath, evaluation_data_filepath, model_name=base_model_name)
.history/scripts/code_templates/evaluation_template.py_20250202072054.txt ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for model evaluation script for {{phase_name}}
2
+
3
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer
4
+ from datasets import load_dataset # Example datasets library
5
+ from sklearn.metrics import accuracy_score, classification_report # Example metrics
6
+ import torch # Example PyTorch
7
+ # Add other necessary imports
8
+
9
+ def evaluate_model(model_path, dataset_path, model_name="bert-base-uncased"):
10
+ """
11
+ Evaluates a trained model on a dataset.
12
+ """
13
+ try:
14
+ # Load dataset for evaluation (replace with your actual dataset loading)
15
+ dataset = load_dataset('csv', data_files=dataset_path) # Example: CSV dataset loading, replace with your dataset format
16
+
17
+ print("Evaluation dataset loaded. Loading model and tokenizer...")
18
+
19
+ tokenizer = AutoTokenizer.from_pretrained(model_name) # Use base model tokenizer (or fine-tuned tokenizer if saved separately)
20
+ model = AutoModelForSequenceClassification.from_pretrained(model_path)
21
+
22
+ def tokenize_function(examples):
23
+ return tokenizer(examples["text_column"], padding="max_length", truncation=True) # Example: tokenize 'text_column'
24
+
25
+ tokenized_datasets = dataset.map(tokenize_function, batched=True)
26
+
27
+ def compute_metrics(eval_pred):
28
+ predictions, labels = eval_pred
29
+ predictions = predictions.argmax(axis=-1)
30
+ accuracy = accuracy_score(labels, predictions)
31
+ report = classification_report(labels, predictions, output_dict=True) # Detailed report
32
+ return {"accuracy": accuracy, "classification_report": report}
33
+
34
+ training_args = TrainingArguments(
35
+ output_dir="./evaluation_results",
36
+ per_device_eval_batch_size=64,
37
+ logging_dir='./eval_logs',
38
+ )
39
+
40
+ trainer = Trainer(
41
+ model=model,
42
+ args=training_args,
43
+ eval_dataset=tokenized_datasets["validation"], # Assuming 'validation' split exists
44
+ compute_metrics=compute_metrics,
45
+ tokenizer=tokenizer
46
+ )
47
+
48
+ evaluation_results = trainer.evaluate()
49
+
50
+ print("Model evaluation completed.")
51
+ print("Evaluation Results:")
52
+ print(f"Accuracy: {evaluation_results['eval_accuracy']}")
53
+ print("Classification Report:\n", evaluation_results['eval_classification_report'])
54
+
55
+
56
+ except FileNotFoundError:
57
+ print(f"Error: Dataset file or model files not found.")
58
+ except Exception as e:
59
+ print(f"Error during model evaluation: {e}")
60
+
61
+
62
+ if __name__ == "__main__":
63
+ model_filepath = "models/fine_tuned_model" # Replace with your model path
64
+ evaluation_data_filepath = "data/evaluation_dataset.csv" # Replace with your evaluation data path
65
+ base_model_name = "bert-base-uncased" # Replace with your base model name
66
+
67
+ evaluate_model(model_filepath, evaluation_data_filepath, model_name=base_model_name)
.history/scripts/code_templates/preprocessing_template.py_20250202065605.txt ADDED
File without changes
.history/scripts/code_templates/preprocessing_template.py_20250202070023.txt ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for data preprocessing script for {{phase_name}}
2
+
3
+ import pandas as pd
4
+ # Add other necessary imports
5
+
6
+ def preprocess_data(raw_data_path, processed_data_path):
7
+ """
8
+ Reads raw data, preprocesses it, and saves the processed data.
9
+ """
10
+ try:
11
+ # Load raw data (replace with your actual data loading)
12
+ data = pd.read_csv(raw_data_path) # Example: CSV loading
13
+
14
+ print("Data loaded successfully. Starting preprocessing...")
15
+
16
+ # --- Data Preprocessing Steps ---
17
+ # Example steps (customize based on your data and project)
18
+
19
+ # 1. Handle missing values
20
+ data = data.fillna(0) # Example: fill NaN with 0
21
+
22
+ # 2. Feature engineering (example: create a new feature)
23
+ data['feature_length'] = data['text_column'].str.len() # Example: length of text column
24
+
25
+ # 3. Text cleaning (if applicable - example: lowercasing)
26
+ if 'text_column' in data.columns:
27
+ data['text_column'] = data['text_column'].str.lower()
28
+
29
+ # --- End of Preprocessing Steps ---
30
+
31
+ # Save processed data
32
+ data.to_csv(processed_data_path, index=False)
33
+ print(f"Processed data saved to {processed_data_path}")
34
+
35
+ except FileNotFoundError:
36
+ print(f"Error: Raw data file not found at {raw_data_path}")
37
+ except Exception as e:
38
+ print(f"Error during data preprocessing: {e}")
39
+
40
+ if __name__ == "__main__":
41
+ raw_data_filepath = "data/raw_dataset.csv" # Replace with your raw data path
42
+ processed_data_filepath = "data/processed_dataset.csv" # Replace with your desired output path
43
+
44
+ preprocess_data(raw_data_filepath, processed_data_filepath)
.history/scripts/code_templates/preprocessing_template.py_20250202072023.txt ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for data preprocessing script for {{phase_name}}
2
+
3
+ import pandas as pd
4
+ # Add other necessary imports
5
+
6
+ def preprocess_data(raw_data_path, processed_data_path):
7
+ """
8
+ Reads raw data, preprocesses it, and saves the processed data.
9
+ """
10
+ try:
11
+ # Load raw data (replace with your actual data loading)
12
+ data = pd.read_csv(raw_data_path) # Example: CSV loading
13
+
14
+ print("Data loaded successfully. Starting preprocessing...")
15
+
16
+ # --- Data Preprocessing Steps ---
17
+ # Example steps (customize based on your data and project)
18
+
19
+ # 1. Handle missing values
20
+ data = data.fillna(0) # Example: fill NaN with 0
21
+
22
+ # 2. Feature engineering (example: create a new feature)
23
+ data['feature_length'] = data['text_column'].str.len() # Example: length of text column
24
+
25
+ # 3. Text cleaning (if applicable - example: lowercasing)
26
+ if 'text_column' in data.columns:
27
+ data['text_column'] = data['text_column'].str.lower()
28
+
29
+ # --- End of Preprocessing Steps ---
30
+
31
+ # Save processed data
32
+ data.to_csv(processed_data_path, index=False)
33
+ print(f"Processed data saved to {processed_data_path}")
34
+
35
+ except FileNotFoundError:
36
+ print(f"Error: Raw data file not found at {raw_data_path}")
37
+ except Exception as e:
38
+ print(f"Error during data preprocessing: {e}")
39
+
40
+ if __name__ == "__main__":
41
+ raw_data_filepath = "data/raw_dataset.csv" # Replace with your raw data path
42
+ processed_data_filepath = "data/processed_dataset.csv" # Replace with your desired output path
43
+
44
+ preprocess_data(raw_data_filepath, processed_data_filepath)
.history/scripts/code_templates/training_template.py_20250202065612.txt ADDED
File without changes
.history/scripts/code_templates/training_template.py_20250202070043.txt ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for model training script for {{phase_name}}
2
+
3
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, TrainingArguments, Trainer
4
+ from datasets import load_dataset # Example - datasets library
5
+ import torch # Example - PyTorch
6
+ # Add other necessary imports
7
+
8
+ def train_model(processed_dataset_path, model_name="bert-base-uncased", output_dir="./model_output"):
9
+ """
10
+ Trains a model on the processed dataset.
11
+ """
12
+ try:
13
+ # Load processed dataset (replace with your actual dataset loading)
14
+ dataset = load_dataset('csv', data_files=processed_dataset_path) # Example: CSV dataset loading, replace with your dataset format
15
+
16
+ print("Dataset loaded. Preparing model and training...")
17
+
18
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
19
+ model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2) # Example: binary classification
20
+
21
+ def tokenize_function(examples):
22
+ return tokenizer(examples["text_column"], padding="max_length", truncation=True) # Example: tokenize 'text_column'
23
+
24
+ tokenized_datasets = dataset.map(tokenize_function, batched=True)
25
+
26
+ training_args = TrainingArguments(
27
+ output_dir=output_dir,
28
+ num_train_epochs=3, # Example epochs
29
+ per_device_train_batch_size=16, # Example batch size
30
+ per_device_eval_batch_size=64, # Example batch size
31
+ warmup_steps=500, # Example warmup steps
32
+ weight_decay=0.01, # Example weight decay
33
+ logging_dir='./logs', # Directory for logs
34
+ logging_steps=10,
35
+ )
36
+
37
+ trainer = Trainer(
38
+ model=model,
39
+ args=training_args,
40
+ train_dataset=tokenized_datasets["train"], # Assuming 'train' split exists
41
+ eval_dataset=tokenized_datasets["validation"], # Assuming 'validation' split exists - optional
42
+ tokenizer=tokenizer,
43
+ )
44
+
45
+ trainer.train()
46
+
47
+ print(f"Model training completed. Model saved to {output_dir}")
48
+
49
+ except Exception as e:
50
+ print(f"Error during model training: {e}")
51
+
52
+
53
+ if __name__ == "__main__":
54
+ processed_data_filepath = "data/processed_dataset.csv" # Replace with your processed data path
55
+ model_output_directory = "models/fine_tuned_model" # Replace with your desired output directory
56
+ base_model_name = "bert-base-uncased" # Replace with your base model name
57
+
58
+ train_model(processed_data_filepath, model_name=base_model_name, output_dir=model_output_directory)
.history/scripts/code_templates/training_template.py_20250202072034.txt ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Template for model training script for {{phase_name}}
2
+
3
+ from transformers import AutoModelForSequenceClassification, AutoTokenizer, TrainingArguments, Trainer
4
+ from datasets import load_dataset # Example - datasets library
5
+ import torch # Example - PyTorch
6
+ # Add other necessary imports
7
+
8
+ def train_model(processed_dataset_path, model_name="bert-base-uncased", output_dir="./model_output"):
9
+ """
10
+ Trains a model on the processed dataset.
11
+ """
12
+ try:
13
+ # Load processed dataset (replace with your actual dataset loading)
14
+ dataset = load_dataset('csv', data_files=processed_dataset_path) # Example: CSV dataset loading, replace with your dataset format
15
+
16
+ print("Dataset loaded. Preparing model and training...")
17
+
18
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
19
+ model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2) # Example: binary classification
20
+
21
+ def tokenize_function(examples):
22
+ return tokenizer(examples["text_column"], padding="max_length", truncation=True) # Example: tokenize 'text_column'
23
+
24
+ tokenized_datasets = dataset.map(tokenize_function, batched=True)
25
+
26
+ training_args = TrainingArguments(
27
+ output_dir=output_dir,
28
+ num_train_epochs=3, # Example epochs
29
+ per_device_train_batch_size=16, # Example batch size
30
+ per_device_eval_batch_size=64, # Example batch size
31
+ warmup_steps=500, # Example warmup steps
32
+ weight_decay=0.01, # Example weight decay
33
+ logging_dir='./logs', # Directory for logs
34
+ logging_steps=10,
35
+ )
36
+
37
+ trainer = Trainer(
38
+ model=model,
39
+ args=training_args,
40
+ train_dataset=tokenized_datasets["train"], # Assuming 'train' split exists
41
+ eval_dataset=tokenized_datasets["validation"], # Assuming 'validation' split exists - optional
42
+ tokenizer=tokenizer,
43
+ )
44
+
45
+ trainer.train()
46
+
47
+ print(f"Model training completed. Model saved to {output_dir}")
48
+
49
+ except Exception as e:
50
+ print(f"Error during model training: {e}")
51
+
52
+
53
+ if __name__ == "__main__":
54
+ processed_data_filepath = "data/processed_dataset.csv" # Replace with your processed data path
55
+ model_output_directory = "models/fine_tuned_model" # Replace with your desired output directory
56
+ base_model_name = "bert-base-uncased" # Replace with your base model name
57
+
58
+ train_model(processed_data_filepath, model_name=base_model_name, output_dir=model_output_directory)
.history/scripts/parse_20250202061443.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # File reading and parsing functions for roadmap.txt and rules.txt
.history/scripts/parsing_utils_20250202065553.py ADDED
File without changes
.history/scripts/parsing_utils_20250202065942.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ def load_yaml_file(filepath):
4
+ """Loads and parses a YAML file."""
5
+ try:
6
+ with open(filepath, 'r') as f:
7
+ data = yaml.safe_load(f)
8
+ return data
9
+ except FileNotFoundError:
10
+ print(f"Error: File not found at {filepath}")
11
+ return None
12
+ except yaml.YAMLError as e:
13
+ print(f"Error parsing YAML file {filepath}: {e}")
14
+ return None
15
+
16
+ def get_roadmap_phases(roadmap_data):
17
+ """Extracts phases from roadmap data."""
18
+ if roadmap_data and 'roadmap' in roadmap_data:
19
+ return roadmap_data['roadmap']
20
+ return None
21
+
22
+ def get_project_rules(rules_data):
23
+ """Extracts project rules data."""
24
+ if rules_data and 'project_rules' in rules_data:
25
+ return rules_data['project_rules']
26
+ return None
27
+
28
+ # You can add more parsing utility functions as needed
.history/scripts/parsing_utils_20250202071904.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ def load_yaml_file(filepath):
4
+ """Loads and parses a YAML file."""
5
+ try:
6
+ with open(filepath, 'r') as f:
7
+ data = yaml.safe_load(f)
8
+ return data
9
+ except FileNotFoundError:
10
+ print(f"Error: File not found at {filepath}")
11
+ return None
12
+ except yaml.YAMLError as e:
13
+ print(f"Error parsing YAML file {filepath}: {e}")
14
+ return None
15
+
16
+ def get_roadmap_phases(roadmap_data):
17
+ """Extracts phases from roadmap data."""
18
+ if roadmap_data and 'roadmap' in roadmap_data:
19
+ return roadmap_data['roadmap']
20
+ return None
21
+
22
+ def get_project_rules(rules_data):
23
+ """Extracts project rules data."""
24
+ if rules_data and 'project_rules' in rules_data:
25
+ return rules_data['project_rules']
26
+ return None
27
+
28
+ # You can add more parsing utility functions as needed
.history/scripts/parsing_utils_20250202071913.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ def load_yaml_file(filepath):
4
+ """Loads and parses a YAML file."""
5
+ try:
6
+ with open(filepath, 'r') as f:
7
+ data = yaml.safe_load(f)
8
+ return data
9
+ except FileNotFoundError:
10
+ print(f"Error: File not found at {filepath}")
11
+ return None
12
+ except yaml.YAMLError as e:
13
+ print(f"Error parsing YAML file {filepath}: {e}")
14
+ return None
15
+
16
+ def get_roadmap_phases(roadmap_data):
17
+ """Extracts phases from roadmap data."""
18
+ if roadmap_data and 'roadmap' in roadmap_data:
19
+ return roadmap_data['roadmap']
20
+ return None
21
+
22
+ def get_project_rules(rules_data):
23
+ """Extracts project rules data."""
24
+ if rules_data and 'project_rules' in rules_data:
25
+ return rules_data['project_rules']
26
+ return None
27
+
28
+ # You can add more parsing utility functions as needed
.history/scripts/parsing_utils_20250202071948.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import yaml
2
+
3
+ def load_yaml_file(filepath):
4
+ """Loads and parses a YAML file."""
5
+ try:
6
+ with open(filepath, 'r') as f:
7
+ data = yaml.safe_load(f)
8
+ return data
9
+ except FileNotFoundError:
10
+ print(f"Error: File not found at {filepath}")
11
+ return None
12
+ except yaml.YAMLError as e:
13
+ print(f"Error parsing YAML file {filepath}: {e}")
14
+ return None
15
+
16
+ def get_roadmap_phases(roadmap_data):
17
+ """Extracts phases from roadmap data."""
18
+ if roadmap_data and 'roadmap' in roadmap_data:
19
+ return roadmap_data['roadmap']
20
+ return None
21
+
22
+ def get_project_rules(rules_data):
23
+ """Extracts project rules data."""
24
+ if rules_data and 'project_rules' in rules_data:
25
+ return rules_data['project_rules']
26
+ return None
27
+
28
+ # You can add more parsing utility functions as needed
README.md CHANGED
@@ -9,5 +9,53 @@ app_file: app.py
9
  pinned: false
10
  short_description: STTETTETE
11
  ---
 
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  pinned: false
10
  short_description: STTETTETE
11
  ---
12
+ # Custom AI Chatbot for Project Guidance
13
 
14
+ This project implements a custom AI chatbot designed to guide users through complex projects based on predefined roadmaps and rules.
15
+
16
+ **Features:**
17
+
18
+ * **Roadmap-based Guidance:** Follows a structured roadmap defined in `roadmap.yaml`.
19
+ * **Rule Enforcement:** Adheres to project rules defined in `rules.yaml`.
20
+ * **Dynamic Response Generation:** Provides context-aware and step-by-step guidance.
21
+ * **Code Snippet Generation:** Generates complete code snippets for project phases using templates.
22
+ * **LLM Selection:** Integrates with Hugging Face Hub for flexible LLM selection (DeepSeek and Gemini models).
23
+ * **Model Switching:** Allows users to switch between available LLMs via the UI.
24
+ * **Basic LLM Responses:** Generates responses using the selected LLM for general queries.
25
+ * **Token Control:** Limits LLM response length using `max_response_tokens` in `configs/chatbot_config.yaml`.
26
+ * **Error Handling:** Includes error handling for model loading and switching, with UI warnings.
27
+ * **Deployable on Hugging Face Spaces:** Built using Gradio for easy deployment.
28
+
29
+ **Important Notes on Safety Settings:**
30
+
31
+ * **Direct Safety Configuration Limited:** For the Hugging Face models used directly via `transformers` (DeepSeek and Gemini Flash), there are **no easily configurable, standardized "safety settings"** like "Harassment: None," "Hate: None," etc., available through the `transformers` library itself.
32
+ * **Model-Dependent Safety:** Safety behavior is primarily determined by how these models were trained and any inherent safety mechanisms built by their creators.
33
+ * **Basic Output Filtering (Possible Extension):** For a very rudimentary level of control, you could implement keyword-based output filtering as a post-processing step, but this is not implemented in this version.
34
+ * **Commercial APIs Offer More Control:** If you need fine-grained safety controls, consider using commercial LLM APIs (like Google AI Gemini API, OpenAI API), which often provide parameters to adjust safety filters in their API requests.
35
+
36
+ **Getting Started:**
37
+
38
+ 1. **Clone this repository.**
39
+ 2. **Install dependencies:** `pip install -r requirements.txt`
40
+ 3. **Customize `roadmap.yaml` and `rules.yaml`** to define your project guidance.
41
+ 4. **Configure `configs/chatbot_config.yaml`** to set up LLMs, token limits, and chatbot behavior.
42
+ 5. **Run the Gradio app:** `python app.py`
43
+ 6. **Deploy to Hugging Face Spaces** (refer to Hugging Face Spaces documentation).
44
+
45
+ **Available Models:**
46
+
47
+ * DeepSeek-R1-Distill-Llama-8B
48
+ * Gemini 2.0 Flash (Exp 01-21)
49
+
50
+ **Further Development:**
51
+
52
+ * Enhance LLM response generation for more context-aware and project-specific guidance.
53
+ * Implement more sophisticated state management to track user progress through the roadmap.
54
+ * Improve code generation with more dynamic templates and customization options.
55
+ * Develop a more advanced GUI or web-based interface.
56
+ * Add more LLMs to the selection pool.
57
+ * Implement more robust error handling and logging.
58
+ * **Explore and potentially integrate keyword-based output filtering for basic safety control.**
59
+ * **Investigate using commercial LLM APIs for more advanced safety settings and control.**
60
+
61
+ **License:** [Your License]
app.py CHANGED
@@ -1,36 +1,49 @@
1
- # /app.py
2
-
3
- from fastapi import FastAPI, HTTPException
4
- from transformers import AutoModelForCausalLM, AutoTokenizer
5
- from pydantic import BaseModel
6
- import os
7
- import logging
8
-
9
- # Setup logging
10
- logging.basicConfig(level=logging.INFO)
11
-
12
- # FastAPI instance
13
- app = FastAPI()
14
-
15
- # Load the model and tokenizer
16
- MODEL_NAME = 'deepseek-ai/DeepSeek-R1-Distill-Qwen-7B'
17
- tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
18
- model = AutoModelForCausalLM.from_pretrained(MODEL_NAME)
19
-
20
- class UserInput(BaseModel):
21
- input_text: str
22
-
23
- @app.post("/predict")
24
- def predict(input: UserInput):
25
- try:
26
- inputs = tokenizer(input.input_text, return_tensors="pt")
27
- outputs = model.generate(inputs["input_ids"], max_length=100)
28
- response = tokenizer.decode(outputs[0], skip_special_tokens=True)
29
- return {"response": response}
30
- except Exception as e:
31
- logging.error(f"Error during prediction: {e}")
32
- raise HTTPException(status_code=500, detail="Error generating response")
33
-
34
- @app.get("/")
35
- def read_root():
36
- return {"message": "Welcome to the Custom AI Chatbot"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from scripts.chatbot_logic import ProjectGuidanceChatbot
3
+
4
+ # Initialize Chatbot
5
+ chatbot = ProjectGuidanceChatbot(
6
+ roadmap_file="roadmap.yaml",
7
+ rules_file="rules.yaml",
8
+ config_file="configs/chatbot_config.yaml",
9
+ code_templates_dir="scripts/code_templates"
10
+ )
11
+
12
+ def respond(message, chat_history):
13
+ bot_message = chatbot.process_query(message)
14
+ chat_history.append((message, bot_message))
15
+ return "", chat_history
16
+
17
+ def switch_model(model_key):
18
+ model_switch_result = chatbot.switch_llm_model(model_key) # Get result message
19
+ greeting_message = chatbot.get_chatbot_greeting()
20
+
21
+ if "Error:" in model_switch_result: # Check if result contains "Error:"
22
+ return gr.Warning(model_switch_result), greeting_message # Display error as Gradio Warning
23
+ else:
24
+ return None, greeting_message # No warning, just update greeting
25
+
26
+ with gr.Blocks() as demo:
27
+ chatbot_greeting_md = gr.Markdown(chatbot.get_chatbot_greeting())
28
+ gr.Markdown(f"# {chatbot.chatbot_config.get('name', 'Project Guidance Chatbot')}")
29
+
30
+ model_choices = [(model['name'], key) for key, model in chatbot.available_models_config.items()]
31
+ model_dropdown = gr.Dropdown(
32
+ choices=model_choices,
33
+ value=chatbot.active_model_info['name'] if chatbot.active_model_info else None,
34
+ label="Select LLM Model"
35
+ )
36
+ model_error_output = gr.Warning(visible=False) # Initially hidden warning component
37
+ model_dropdown.change(
38
+ fn=switch_model,
39
+ inputs=model_dropdown,
40
+ outputs=[model_error_output, chatbot_greeting_md] # Output both warning and greeting
41
+ )
42
+
43
+ chatbot_ui = gr.Chatbot()
44
+ msg = gr.Textbox()
45
+ clear = gr.ClearButton([msg, chatbot_ui])
46
+
47
+ msg.submit(respond, [msg, chatbot_ui], [msg, chatbot_ui])
48
+
49
+ demo.launch()
configs/chatbot_config.yaml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ chatbot:
2
+ name: "Project Guidance Chatbot"
3
+ description: "Your helpful AI assistant for project completion with LLM selection and token control."
4
+ default_llm_model_id: "deepseek-r1-distill-llama-8b"
5
+ max_response_tokens: 200 # Maximum tokens for LLM generated responses
6
+
7
+ available_models:
8
+ deepseek-r1-distill-llama-8b:
9
+ name: "DeepSeek-R1-Distill-Llama-8B"
10
+ model_id: "DeepSeek-AI/DeepSeek-R1-Distill-Llama-8B"
11
+ gemini-flash-01-21:
12
+ name: "Gemini 2.0 Flash (Exp 01-21)"
13
+ model_id: "google/gemini-2.0-flash-thinking-exp-01-21"
14
+
15
+ model_selection:
16
+ suggested_models:
17
+ - "mistralai/Mistral-7B-Instruct-v0.2"
18
+ - "google/flan-t5-xl"
19
+ - "facebook/bart-large"
20
+ criteria_prompt: "Consider these criteria when selecting a model: {rules.model_selection}"
21
+
22
+ response_generation:
23
+ error_message: "Sorry, I encountered an issue. Please check your input and project files."
24
+ default_instruction: "How can I help you with your project?"
configs/requirments.txt DELETED
@@ -1,8 +0,0 @@
1
- # /configs/requirements.txt
2
-
3
- fastapi
4
- uvicorn
5
- transformers
6
- torch
7
- datasets
8
- pydantic
 
 
 
 
 
 
 
 
 
details.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ custom-llm-project/
2
+ β”œβ”€β”€ data/
3
+ β”‚ └── # (Optional: Datasets or example data - currently empty)
4
+ β”œβ”€β”€ models/
5
+ β”‚ └── # (Optional: Could store cached models or local models in future)
6
+ β”œβ”€β”€ scripts/
7
+ β”‚ β”œβ”€β”€ chatbot_logic.py # Core chatbot logic (parsing, response generation, code gen)
8
+ β”‚ β”œβ”€β”€ parsing_utils.py # Utility functions for parsing roadmap and rules
9
+ β”‚ └── code_templates/ # Directory for code templates
10
+ β”‚ β”œβ”€β”€ preprocessing_template.py.txt
11
+ β”‚ β”œβ”€β”€ training_template.py.txt
12
+ β”‚ β”œβ”€β”€ evaluation_template.py.txt
13
+ β”‚ └── api_template.py.txt
14
+ β”œβ”€β”€ configs/
15
+ β”‚ └── chatbot_config.yaml # Configuration for chatbot behavior, LLM selection, etc.
16
+ β”œβ”€β”€ api/ # (Placeholder for future API integration - currently empty)
17
+ β”œβ”€β”€ roadmap.yaml # Project roadmap (YAML format)
18
+ β”œβ”€β”€ rules.yaml # Project rules (YAML format)
19
+ β”œβ”€β”€ requirements.txt # Python dependencies
20
+ β”œβ”€β”€ app.py # Gradio application script (main entry point for HF Spaces)
21
+ └── README.md # Project README file (documentation)