tune-sdk 0.1.0

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.
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # Tune for VSCode
2
+
3
+ [Tune](https://marketplace.visualstudio.com/items?itemName=iovdin.tune) is a handy extension for Visual Studio Code that lets you chat with large language models (LLMs) right in your code editor. Need quick answers, help brainstorming, or running scripts? Tune’s got you covered! You can even use different LLMs and create handy tools in Python, JavaScript, or PHP—all without leaving your editor. Get ready to boost your productivity!
4
+
5
+
6
+ ## 🚀 Features
7
+ ### 💬 .chat file
8
+
9
+ To start chatting create a .chat file. Use `<Shift>+<Enter>` to trigger chat response
10
+
11
+ <img src=https://raw.githubusercontent.com/iovdin/tune/main/gifs/basic.gif width=800 height=450>
12
+
13
+ ### 🔗 Variable expansion
14
+
15
+ You can use `{filename}` to inject filename contents to the chat.
16
+ file can be any text file or image.
17
+
18
+ <img src=https://raw.githubusercontent.com/iovdin/tune/main/gifs/variables.gif width=800 height=450>
19
+
20
+
21
+ ## 🛠️ Setup
22
+
23
+ 1. Install nodejs.
24
+ 2. Set OPENAI_KEY in settings. By default Tune uses gpt4o-mini. But you can change it
25
+
26
+ <img src=https://raw.githubusercontent.com/iovdin/tune/main/gifs/set_openai_key.gif width=800 height=450>
27
+
28
+ ## ⚙️ Support for Multiple LLMs
29
+
30
+ Configure different LLMs by creating a `.config.js` file that defines the HTTP payload.
31
+
32
+ Example: Setting up Claude with [openrouter.ai](https://openrouter.ai)
33
+
34
+ ```javascript
35
+ ({
36
+ url: "https://openrouter.ai/api/v1/chat/completions",
37
+ method: "POST",
38
+ headers: {
39
+ "content-type": "application/json",
40
+ authorization: `Bearer ${OPEN_ROUTER_KEY}`,
41
+ },
42
+ body: JSON.stringify({
43
+ ...payload,
44
+ model: "anthropic/claude-3.5-sonnet"
45
+ })
46
+ })
47
+ ```
48
+
49
+ - Add your `OPEN_ROUTER_KEY` to the `.env` file.
50
+ - Use the config in your `.chat` file:
51
+
52
+ ```chat
53
+ u: {claude}
54
+ What is the meaning of life?
55
+ ```
56
+
57
+ - Naming the config `default.config.js` makes it the default LLM used by Tune.
58
+
59
+ **Note**: Tune supports OpenAI and Ollama for streaming. For Anthropic models, use services like OpenRouter.ai.
60
+
61
+ <img src=https://raw.githubusercontent.com/iovdin/tune/main/gifs/config.gif width=800 height=450>
62
+
63
+ ### 🛠️ Tools
64
+ Tools are functions or scripts that LLMs can call to perform tasks beyond their native capabilities, such as querying a database or calling an external API.
65
+
66
+ Easily create tools using JavaScript, Python, or PHP. Name your tool files as `toolname.tool.mjs/js/cjs/py/php/chat`.
67
+
68
+ Here is a shell tool example as ESM module
69
+
70
+ **`sh.tool.mjs`**.
71
+
72
+ ```javascript
73
+ import { execSync } from 'node:child_process';
74
+
75
+ export default async function sh({ text }) {
76
+ return execSync(text, { encoding: "utf8" });
77
+ }
78
+ ```
79
+
80
+ To use the tool, just expand the file
81
+ ```chat
82
+ u: {sh}
83
+ what is contents fo the current directory?
84
+ tc: sh
85
+ ls -la
86
+ tr: total 944
87
+ -rw-r--r-- 1 iovdin staff 248 3 Oct 22:12 4o.config.js
88
+ -rw-r--r-- 1 iovdin staff 253 17 Sep 16:10 4om.config.js
89
+ -rw-r--r-- 1 iovdin staff 2128 8 Oct 17:18 README.md
90
+ c:
91
+ tc: stands for tool call
92
+ tr: tool result
93
+ ```
94
+
95
+ Here are the shell tool in other languages
96
+
97
+ **`sh.tool.cjs`**
98
+ ```javascript
99
+ const { execSync } = require('child_process');
100
+
101
+ exports.default = async function sh({ text }) {
102
+ return execSync(text, { encoding: "utf8" });
103
+ };
104
+ ```
105
+
106
+ **`sh.tool.py`**
107
+ ```python
108
+ import subprocess
109
+
110
+ def main(params):
111
+ return subprocess.check_output(params['text'], shell=True, text=True)
112
+ ```
113
+
114
+ **`sh.tool.php`**
115
+ ```php
116
+ <?php
117
+ function main($params) {
118
+ return shell_exec($params['text']);
119
+ }
120
+ ?>
121
+ ```
122
+
123
+ <img src=https://raw.githubusercontent.com/iovdin/tune/main/gifs/tool.gif width=800 height=450>
124
+
125
+ It is possible to make tool out of another chat.
126
+ Lets create a tool that gives file a name given text content
127
+
128
+ **`filename.tool.chat`**
129
+ ```chat
130
+ s: You're given text content, please come up with a filename for the content.
131
+ it should use camel case
132
+ u: {text}
133
+ ```
134
+
135
+ How to use it?
136
+ ```chat
137
+ s: {filename}
138
+ tc: filename
139
+ console.log("hello world")
140
+ tr: HelloWorld.js
141
+ ```
142
+
143
+ Checkout more tools at [Tune GitHub](https://github.com/iovdin/tune)
144
+
145
+ ## Help System Prompt
146
+ You can ask for help using
147
+ ```chat
148
+ s: {esc:tune_help}
149
+ u: how to make a tool?
150
+ ```
151
+
152
+ ### 📫 Contact
153
+
154
+ For any inquiries or support, feel free to [open an issue](https://github.com/iovdin/tune/issues) on GitHub. Or drop a message to [Tune Discord Channel](https://discord.com/channels/1293110380813484063/1293110381400559689)
155
+