janito 0.11.0__py3-none-any.whl → 0.12.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- janito/__init__.py +1 -1
- janito/__main__.py +6 -204
- janito/callbacks.py +34 -132
- janito/cli/__init__.py +6 -0
- janito/cli/agent.py +287 -0
- janito/cli/app.py +86 -0
- janito/cli/commands.py +329 -0
- janito/cli/output.py +29 -0
- janito/cli/utils.py +22 -0
- janito/config.py +338 -121
- janito/data/instructions_template.txt +27 -0
- janito/token_report.py +154 -145
- janito/tools/__init__.py +38 -21
- janito/tools/bash/bash.py +82 -0
- janito/tools/bash/unix_persistent_bash.py +182 -0
- janito/tools/bash/win_persistent_bash.py +306 -0
- janito/tools/decorators.py +2 -13
- janito/tools/delete_file.py +27 -9
- janito/tools/fetch_webpage/__init__.py +34 -0
- janito/tools/fetch_webpage/chunking.py +76 -0
- janito/tools/fetch_webpage/core.py +155 -0
- janito/tools/fetch_webpage/extractors.py +276 -0
- janito/tools/fetch_webpage/news.py +137 -0
- janito/tools/fetch_webpage/utils.py +108 -0
- janito/tools/find_files.py +106 -44
- janito/tools/move_file.py +72 -0
- janito/tools/prompt_user.py +37 -6
- janito/tools/replace_file.py +31 -4
- janito/tools/rich_console.py +139 -0
- janito/tools/search_text.py +33 -21
- janito/tools/str_replace_editor/editor.py +7 -4
- janito/tools/str_replace_editor/handlers/__init__.py +16 -0
- janito/tools/str_replace_editor/handlers/create.py +60 -0
- janito/tools/str_replace_editor/handlers/insert.py +100 -0
- janito/tools/str_replace_editor/handlers/str_replace.py +92 -0
- janito/tools/str_replace_editor/handlers/undo.py +64 -0
- janito/tools/str_replace_editor/handlers/view.py +153 -0
- janito/tools/str_replace_editor/utils.py +0 -1
- janito/tools/usage_tracker.py +136 -0
- janito-0.12.0.dist-info/METADATA +203 -0
- janito-0.12.0.dist-info/RECORD +47 -0
- janito/chat_history.py +0 -117
- janito/data/instructions.txt +0 -4
- janito/tools/bash.py +0 -22
- janito/tools/str_replace_editor/handlers.py +0 -335
- janito-0.11.0.dist-info/METADATA +0 -86
- janito-0.11.0.dist-info/RECORD +0 -26
- {janito-0.11.0.dist-info → janito-0.12.0.dist-info}/WHEEL +0 -0
- {janito-0.11.0.dist-info → janito-0.12.0.dist-info}/entry_points.txt +0 -0
- {janito-0.11.0.dist-info → janito-0.12.0.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,203 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: janito
|
3
|
+
Version: 0.12.0
|
4
|
+
Summary: Janito CLI tool
|
5
|
+
Project-URL: Homepage, https://github.com/joaompinto/janito
|
6
|
+
Author-email: João Pinto <lamego.pinto@gmail.com>
|
7
|
+
License-File: LICENSE
|
8
|
+
Requires-Python: >=3.8
|
9
|
+
Requires-Dist: anthropic>=0.5.0
|
10
|
+
Requires-Dist: beautifulsoup4>=4.13.0
|
11
|
+
Requires-Dist: claudine>=0.1.0
|
12
|
+
Requires-Dist: jinja2>=3.0.0
|
13
|
+
Requires-Dist: lxml-html-clean>=0.4.1
|
14
|
+
Requires-Dist: newspaper3k>=0.2.8
|
15
|
+
Requires-Dist: requests>=2.32.0
|
16
|
+
Requires-Dist: rich>=13.0.0
|
17
|
+
Requires-Dist: trafilatura>=1.6.0
|
18
|
+
Requires-Dist: typer>=0.9.0
|
19
|
+
Description-Content-Type: text/markdown
|
20
|
+
|
21
|
+
# 🤖 Janito
|
22
|
+
|
23
|
+
Janito is a powerful AI-assisted command-line interface (CLI) tool built with Python, leveraging Anthropic's Claude for intelligent code and file management.
|
24
|
+
|
25
|
+
[](https://github.com/joaompinto/janito)
|
26
|
+
|
27
|
+
## ✨ Features
|
28
|
+
|
29
|
+
- 🧠 Intelligent AI assistant powered by Claude
|
30
|
+
- 📁 File management capabilities with real-time output
|
31
|
+
- 🔍 Smart code search and editing
|
32
|
+
- 💻 Interactive terminal interface with rich formatting
|
33
|
+
- 📊 Detailed token usage tracking and cost reporting with cache savings analysis
|
34
|
+
- 🛑 Token and tool usage reporting even when interrupted with Ctrl+C
|
35
|
+
- 🌐 Web page fetching with content extraction capabilities
|
36
|
+
- 🔄 Parameter profiles for optimizing Claude's behavior for different tasks
|
37
|
+
- 📋 Line delta tracking to monitor net changes in files
|
38
|
+
|
39
|
+
## 🛠️ System Requirements
|
40
|
+
|
41
|
+
- **Python 3.8+** - Janito requires Python 3.8 or higher
|
42
|
+
- **Operating Systems**:
|
43
|
+
- Linux/macOS: Native support
|
44
|
+
- Windows: Requires Git Bash for proper operation of CLI tools
|
45
|
+
- **Anthropic API Key** - Required for Claude AI integration
|
46
|
+
|
47
|
+
## 🛠️ Installation
|
48
|
+
|
49
|
+
```bash
|
50
|
+
# Install directly from PyPI
|
51
|
+
pip install janito
|
52
|
+
```
|
53
|
+
|
54
|
+
### Setting up your API Key
|
55
|
+
|
56
|
+
Janito requires an Anthropic API key to function. You can:
|
57
|
+
1. Set the API key: `janito --set-api-key your_api_key`
|
58
|
+
|
59
|
+
For development or installation from source, please see [README_DEV.md](README_DEV.md).
|
60
|
+
|
61
|
+
## 🚀 Usage Tutorial
|
62
|
+
|
63
|
+
After installation, you can start using Janito right away. Let's walk through a simple tutorial:
|
64
|
+
|
65
|
+
### Getting Started
|
66
|
+
|
67
|
+
First, let's check that everything is working:
|
68
|
+
|
69
|
+
```bash
|
70
|
+
# Get help and see available commands
|
71
|
+
janito --help
|
72
|
+
```
|
73
|
+
|
74
|
+
### Tutorial: Creating a Simple Project
|
75
|
+
|
76
|
+
Let's create a simple HTML project with Janito's help:
|
77
|
+
|
78
|
+
After installing Janito, using your prefered editor and/or terminal, go to a new empty folder.
|
79
|
+
|
80
|
+
Use the janito command to create a new project.
|
81
|
+
|
82
|
+
```bash
|
83
|
+
# Step 1: Create a new project structure
|
84
|
+
janito "Create a simple HTML page with a calculator and 3 columns with text for the 3 main activities of the Kazakh culture"
|
85
|
+
```
|
86
|
+
Browse the resulting html page.
|
87
|
+
|
88
|
+
### Tutorial: Adding Features
|
89
|
+
|
90
|
+
Now, let's enhance our example
|
91
|
+
|
92
|
+
```bash
|
93
|
+
# Step 2: Add multiplication and division features
|
94
|
+
janito "Add some svg icons and remove the calculator"
|
95
|
+
|
96
|
+
```
|
97
|
+
|
98
|
+
Refresh the page
|
99
|
+
|
100
|
+
### Exploring More Features
|
101
|
+
|
102
|
+
Janito offers many more capabilities:
|
103
|
+
|
104
|
+
```bash
|
105
|
+
# Show detailed token usage and cost information
|
106
|
+
janito --show-tokens "Explain what is in the project"
|
107
|
+
|
108
|
+
# Use a specific parameter profile for creative tasks
|
109
|
+
janito --profile creative "Write a fun description for our project"
|
110
|
+
|
111
|
+
# Continue previous conversation
|
112
|
+
janito --continue "Plese add one more line"
|
113
|
+
|
114
|
+
# Show current configuration and available profiles
|
115
|
+
janito --show-config
|
116
|
+
|
117
|
+
# You can press Ctrl+C at any time to interrupt a query
|
118
|
+
# Janito will still display token and tool usage information
|
119
|
+
```
|
120
|
+
|
121
|
+
## 🔧 Available Tools
|
122
|
+
|
123
|
+
Janito comes with several built-in tools:
|
124
|
+
- 📄 `str_replace_editor` - View, create, and edit files
|
125
|
+
- 🔎 `find_files` - Find files matching patterns
|
126
|
+
- 🗑️ `delete_file` - Delete files
|
127
|
+
- 🔍 `search_text` - Search for text patterns in files
|
128
|
+
- 🌐 `fetch_webpage` - Fetch and extract content from web pages
|
129
|
+
- 📋 `move_file` - Move files from one location to another
|
130
|
+
- 💻 `bash` - Execute bash commands with real-time output display
|
131
|
+
|
132
|
+
## 📊 Usage Tracking
|
133
|
+
|
134
|
+
Janito includes a comprehensive token usage tracking system that helps you monitor API costs:
|
135
|
+
|
136
|
+
- **Basic tracking**: By default, Janito displays a summary of token usage and cost after each query
|
137
|
+
- **Detailed reporting**: Use the `--show-tokens` or `-t` flag to see detailed breakdowns including:
|
138
|
+
- Input and output token counts
|
139
|
+
- Per-tool token usage statistics
|
140
|
+
- Precise cost calculations
|
141
|
+
- Cache performance metrics with savings analysis
|
142
|
+
- Line delta tracking for file modifications
|
143
|
+
|
144
|
+
```bash
|
145
|
+
# Show detailed token usage and cost information
|
146
|
+
janito --show-tokens "Write a Python function to sort a list"
|
147
|
+
|
148
|
+
# Basic usage (shows simplified token usage summary)
|
149
|
+
janito "Explain Docker containers"
|
150
|
+
```
|
151
|
+
|
152
|
+
The usage tracker automatically calculates cache savings, showing you how much you're saving by reusing previous responses.
|
153
|
+
|
154
|
+
## 📋 Parameter Profiles
|
155
|
+
|
156
|
+
Janito offers predefined parameter profiles to optimize Claude's behavior for different tasks:
|
157
|
+
|
158
|
+
- **precise**: Factual answers, documentation, structured data (temperature: 0.2)
|
159
|
+
- **balanced**: Professional writing, summarization, everyday tasks (temperature: 0.5)
|
160
|
+
- **conversational**: Natural dialogue, educational content (temperature: 0.7)
|
161
|
+
- **creative**: Storytelling, brainstorming, marketing copy (temperature: 0.9)
|
162
|
+
- **technical**: Code generation, debugging, technical problem-solving (temperature: 0.3)
|
163
|
+
|
164
|
+
```bash
|
165
|
+
# Use a specific profile
|
166
|
+
janito --profile creative "Write a poem about coding"
|
167
|
+
|
168
|
+
# View available profiles
|
169
|
+
janito --show-config
|
170
|
+
```
|
171
|
+
|
172
|
+
## ⚙️ Dependencies
|
173
|
+
|
174
|
+
Janito automatically installs the following dependencies:
|
175
|
+
- typer (>=0.9.0) - For CLI interface
|
176
|
+
- rich (>=13.0.0) - For rich text formatting
|
177
|
+
- claudine - For Claude AI integration
|
178
|
+
- Additional packages for file handling and web content extraction
|
179
|
+
|
180
|
+
## 🔑 API Key Configuration
|
181
|
+
|
182
|
+
You can configure your Anthropic API key in several ways:
|
183
|
+
|
184
|
+
```bash
|
185
|
+
# Option 1: Set as environment variable
|
186
|
+
export ANTHROPIC_API_KEY=your_api_key
|
187
|
+
|
188
|
+
# Option 2: Configure globally within Janito
|
189
|
+
janito --set-api-key your_api_key
|
190
|
+
|
191
|
+
# Option 3: Let Janito prompt you on first use
|
192
|
+
janito "Hello, I'm new to Janito!"
|
193
|
+
```
|
194
|
+
|
195
|
+
Your API key is securely stored and used for all future sessions.
|
196
|
+
|
197
|
+
## 💻 Development
|
198
|
+
|
199
|
+
For development instructions, please refer to [README_DEV.md](README_DEV.md).
|
200
|
+
|
201
|
+
## 📜 License
|
202
|
+
|
203
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
janito/__init__.py,sha256=UhMcaPInS2sBvYxOLldeLu7sKy-ZZxndtrf6NPqQBgI,53
|
2
|
+
janito/__main__.py,sha256=Oy-Nc1tZkpyvTKuq1R8oHSuJTkvptN6H93kIHBu7DKY,107
|
3
|
+
janito/callbacks.py,sha256=E1FPXYHZUgiEGMabYuf999PSf_Su4ByHOWlc1-hMqWE,915
|
4
|
+
janito/config.py,sha256=haIErp8tVL6e_5h4fsgLqFib2aCAZZ3sIXa8wStn_yo,12424
|
5
|
+
janito/test_file.py,sha256=c6GWGdTYG3z-Y5XBao9Tmhmq3G-v0L37OfwLgBo8zIU,126
|
6
|
+
janito/token_report.py,sha256=Mks7o2yTxPChgQyBJNoQ5eMmrhSgEM4LKCKi2tHJbVo,9580
|
7
|
+
janito/cli/__init__.py,sha256=dVi9l3E86YyukjxQ-XSUnMZkghnNasXex-X5XAOBiwk,85
|
8
|
+
janito/cli/agent.py,sha256=AYJhSqPbz1Ywz_RBzHxfXIK6x-aZrqA8-C2QzmxZ3J8,10533
|
9
|
+
janito/cli/app.py,sha256=RghsHSmvnECGWzoAeQOJdxHTZM_Xcw6Y4jgbJ5I6-5M,4131
|
10
|
+
janito/cli/commands.py,sha256=c1EHJ_VZR_3aA3zRvCLaBn9yfdj5emQpTI0Z_bXcIyc,12664
|
11
|
+
janito/cli/output.py,sha256=mo3hUokhrD4SWexUjCbLGGQeCDUf0369DA_i9BW7HjU,933
|
12
|
+
janito/cli/utils.py,sha256=gO4NtCNwtEzYDsQesrFlqB5FtYuw87yGwo4iG3nINgw,661
|
13
|
+
janito/data/instructions_template.txt,sha256=oXmjVEajwLuTjcyXyD123CGSjNG1QLbfzbw9iEq-w5w,1411
|
14
|
+
janito/tools/__init__.py,sha256=hio75FRkxLSQB13We-SCCM7Qa9lMqWCfWhEonHlTr8M,1405
|
15
|
+
janito/tools/decorators.py,sha256=Tp48n5y4LKsjyV3HeOA9wk2dV413RrEG-23kRyQVlKs,2522
|
16
|
+
janito/tools/delete_file.py,sha256=UrZ5q59SIxWfuJcqgol6yPBqL-RhO9lFCF4MqAc6o00,2252
|
17
|
+
janito/tools/find_files.py,sha256=c_N9ETcRPprQeuZYanwFnl-9E05ZqUYhNVoCRS5uqQg,8300
|
18
|
+
janito/tools/move_file.py,sha256=FCs1ghalfHlXmcbAA_IlLcUll9hTOU1MMFGrTWopXvM,2741
|
19
|
+
janito/tools/prompt_user.py,sha256=OnTiWVBCbL_2MYu7oThlKr8X_pnYdG-dzxXSOgJF41c,1942
|
20
|
+
janito/tools/replace_file.py,sha256=i4GoLtS14eKSU5lYI18mJ96S0_ekeHMwlQfazg-fxrM,2296
|
21
|
+
janito/tools/rich_console.py,sha256=VyLStA7fCgMGp9KZ0TYHAC3FOOAWKKHx1XTWWWF2ISI,4560
|
22
|
+
janito/tools/search_text.py,sha256=hZLgKlF_cC5JRQ2XsussndSZMmptwr8d0tTKCyCXFwg,9755
|
23
|
+
janito/tools/usage_tracker.py,sha256=IE7GVBDYsX2EDLjsVaVqTeAnT2SAYfcOJvBaH__wHdU,4613
|
24
|
+
janito/tools/bash/bash.py,sha256=gOYhp2CexuEjSSpHGhVQLr-Ooc67Etl7Br1TbRtY6vc,3577
|
25
|
+
janito/tools/bash/unix_persistent_bash.py,sha256=tFFhbG9rk1KcONmG0j6SZHrqYxCXELhzobRSTEHPFm0,6868
|
26
|
+
janito/tools/bash/win_persistent_bash.py,sha256=mMgAdRi7jlznq7ssNmgiSMEqzEI-rIV0kgYpndcum6U,12758
|
27
|
+
janito/tools/fetch_webpage/__init__.py,sha256=0RG0ev-yrfo8gPzt-36WMpVdY2qtMhk2Z-mVpq-7m1o,1076
|
28
|
+
janito/tools/fetch_webpage/chunking.py,sha256=mMtrZeirZ_GnKOOzeG8BijLVpSUI0-TA5Ioqi2HKb1A,2971
|
29
|
+
janito/tools/fetch_webpage/core.py,sha256=3XDvYnC_UbQUNumwWw32hfJhjJUEaPzzoF2yhxhwxos,7764
|
30
|
+
janito/tools/fetch_webpage/extractors.py,sha256=-jrLDRWfWyF2SNOATdRWrqETqnnDLbe2JUWtuyHKFOU,12043
|
31
|
+
janito/tools/fetch_webpage/news.py,sha256=Hp0uNTnRzTa-4hyegQbHSmLeSbkiSpx4cP2oP_hKLEQ,5378
|
32
|
+
janito/tools/fetch_webpage/utils.py,sha256=mkfwefD7U9HOktIwo1eP63v7dpVY-q06COUjaqnTT5M,3412
|
33
|
+
janito/tools/str_replace_editor/__init__.py,sha256=kYmscmQgft3Jzt3oCNz7k2FiRbJvku6OFDDC3Q_zoAA,144
|
34
|
+
janito/tools/str_replace_editor/editor.py,sha256=BckYfiMRUYDfDrbu871qMt2AfZexth_02QhwYYOd53g,2489
|
35
|
+
janito/tools/str_replace_editor/utils.py,sha256=akiPqCHjky_RwL9OitHJJ7uQ-3fNaA8wt_K_YO1EP6I,954
|
36
|
+
janito/tools/str_replace_editor/handlers/__init__.py,sha256=RP6JCeDRIL4R-lTpGowIoOAi64gg6VxZvJGp8Q2UOVU,373
|
37
|
+
janito/tools/str_replace_editor/handlers/create.py,sha256=s8RQE04kDAL7OLZA8WxJkDqTmJlGmCNiit4tIHnmNMo,2470
|
38
|
+
janito/tools/str_replace_editor/handlers/insert.py,sha256=eKHodm2ozKUlRMxWMLAsu9ca6unUo1jfXWwHSld-pSU,4061
|
39
|
+
janito/tools/str_replace_editor/handlers/str_replace.py,sha256=quHQ1vOqvXCPaC14W5iub01kKB4XNMqwh1odnXnhhxY,4459
|
40
|
+
janito/tools/str_replace_editor/handlers/undo.py,sha256=3OIdAWkpXC2iDe94_sfx_WxEFh3a1cRzoP0NtPXq1Ks,2491
|
41
|
+
janito/tools/str_replace_editor/handlers/view.py,sha256=ZWcx7r5VwxWG3ImQxK2lzONL9xlqctM-hy2kMF-huT0,6616
|
42
|
+
janito/data/instructions_template.txt,sha256=oXmjVEajwLuTjcyXyD123CGSjNG1QLbfzbw9iEq-w5w,1411
|
43
|
+
janito-0.12.0.dist-info/METADATA,sha256=oR3nvTukvj3uPVcZ2LbAA4lx46W08elLhWphDWXpAAs,6458
|
44
|
+
janito-0.12.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
45
|
+
janito-0.12.0.dist-info/entry_points.txt,sha256=JMbF_1jg-xQddidpAYkzjOKdw70fy_ymJfcmerY2wIY,47
|
46
|
+
janito-0.12.0.dist-info/licenses/LICENSE,sha256=6-H8LXExbBIAuT4cyiE-Qy8Bad1K4pagQRVTWr6wkhk,1096
|
47
|
+
janito-0.12.0.dist-info/RECORD,,
|
janito/chat_history.py
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Chat history module for Janito.
|
3
|
-
Handles storing and loading chat history.
|
4
|
-
"""
|
5
|
-
import os
|
6
|
-
import json
|
7
|
-
import datetime
|
8
|
-
from pathlib import Path
|
9
|
-
from typing import List, Dict, Any, Optional
|
10
|
-
from janito.config import get_config
|
11
|
-
|
12
|
-
def ensure_chat_history_dir() -> Path:
|
13
|
-
"""
|
14
|
-
Ensure the chat history directory exists.
|
15
|
-
|
16
|
-
Returns:
|
17
|
-
Path: Path to the chat history directory
|
18
|
-
"""
|
19
|
-
workspace_dir = get_config().workspace_dir
|
20
|
-
chat_history_dir = Path(workspace_dir) / ".janito" / "chat_history"
|
21
|
-
chat_history_dir.mkdir(parents=True, exist_ok=True)
|
22
|
-
return chat_history_dir
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def store_conversation(query: str, response: str, agent=None) -> None:
|
27
|
-
"""
|
28
|
-
Store a conversation in the chat history.
|
29
|
-
|
30
|
-
Args:
|
31
|
-
query: The user's query
|
32
|
-
response: The agent's response
|
33
|
-
agent: Optional agent instance for using get_messages method
|
34
|
-
"""
|
35
|
-
chat_history_dir = ensure_chat_history_dir()
|
36
|
-
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
|
37
|
-
filename = f"{timestamp}.json"
|
38
|
-
|
39
|
-
# Create the conversation data
|
40
|
-
conversation = {
|
41
|
-
"timestamp": timestamp,
|
42
|
-
"query": query,
|
43
|
-
"response": response
|
44
|
-
}
|
45
|
-
|
46
|
-
# Write to file
|
47
|
-
with open(chat_history_dir / filename, "w", encoding="utf-8") as f:
|
48
|
-
json.dump(conversation, f, ensure_ascii=False, indent=2)
|
49
|
-
|
50
|
-
def load_recent_conversations(count: int = 5) -> List[Dict[str, str]]:
|
51
|
-
"""
|
52
|
-
Load the most recent conversations from the chat history.
|
53
|
-
|
54
|
-
Args:
|
55
|
-
count: Number of conversations to load
|
56
|
-
|
57
|
-
Returns:
|
58
|
-
List[Dict[str, str]]: List of conversations
|
59
|
-
"""
|
60
|
-
chat_history_dir = ensure_chat_history_dir()
|
61
|
-
|
62
|
-
# Get all JSON files in the chat history directory
|
63
|
-
history_files = list(chat_history_dir.glob("*.json"))
|
64
|
-
|
65
|
-
# Sort by filename (which includes timestamp)
|
66
|
-
history_files.sort(reverse=True)
|
67
|
-
|
68
|
-
# Load the most recent conversations
|
69
|
-
conversations = []
|
70
|
-
for file_path in history_files[:count]:
|
71
|
-
try:
|
72
|
-
with open(file_path, "r", encoding="utf-8") as f:
|
73
|
-
conversation = json.load(f)
|
74
|
-
conversations.append(conversation)
|
75
|
-
except Exception as e:
|
76
|
-
print(f"Error loading chat history file {file_path}: {e}")
|
77
|
-
|
78
|
-
return conversations
|
79
|
-
|
80
|
-
def format_conversation_for_context(conversation: Dict[str, str]) -> str:
|
81
|
-
"""
|
82
|
-
Format a conversation for inclusion in the context.
|
83
|
-
|
84
|
-
Args:
|
85
|
-
conversation: The conversation to format
|
86
|
-
|
87
|
-
Returns:
|
88
|
-
str: The formatted conversation
|
89
|
-
"""
|
90
|
-
timestamp = conversation.get("timestamp", "Unknown time")
|
91
|
-
query = conversation.get("query", "")
|
92
|
-
response = conversation.get("response", "")
|
93
|
-
|
94
|
-
formatted_time = datetime.datetime.strptime(timestamp, "%Y%m%d_%H%M%S").strftime("%Y-%m-%d %H:%M:%S")
|
95
|
-
|
96
|
-
return f"--- Conversation from {formatted_time} ---\nUser: {query}\n\nAssistant: {response}\n\n"
|
97
|
-
|
98
|
-
def get_chat_history_context(count: int = 5) -> str:
|
99
|
-
"""
|
100
|
-
Get the chat history formatted for inclusion in the agent's context.
|
101
|
-
|
102
|
-
Args:
|
103
|
-
count: Number of conversations to include
|
104
|
-
|
105
|
-
Returns:
|
106
|
-
str: The formatted chat history
|
107
|
-
"""
|
108
|
-
conversations = load_recent_conversations(count)
|
109
|
-
|
110
|
-
if not conversations:
|
111
|
-
return ""
|
112
|
-
|
113
|
-
context = "# Previous conversations:\n\n"
|
114
|
-
for conversation in conversations:
|
115
|
-
context += format_conversation_for_context(conversation)
|
116
|
-
|
117
|
-
return context
|
janito/data/instructions.txt
DELETED
janito/tools/bash.py
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
from typing import Tuple
|
3
|
-
|
4
|
-
|
5
|
-
def bash_tool(command: str, restart: Optional[bool] = False) -> Tuple[str, bool]:
|
6
|
-
"""
|
7
|
-
A simple bash tool implementation that just prints the command and restart flag.
|
8
|
-
|
9
|
-
Args:
|
10
|
-
command: The bash command to execute
|
11
|
-
restart: Whether to restart the process
|
12
|
-
|
13
|
-
Returns:
|
14
|
-
A tuple containing (output message, is_error flag)
|
15
|
-
"""
|
16
|
-
# In a real implementation, this would execute the command
|
17
|
-
# Here we just print what would be executed
|
18
|
-
output = f"Would execute bash command: '{command}'\n"
|
19
|
-
output += f"Restart flag is set to: {restart}"
|
20
|
-
|
21
|
-
# Return the output with is_error=False
|
22
|
-
return output, False
|