MisterFixx zrewidował ten Gist . Przejdź do rewizji
2 files changed, 149 insertions
fixgpt.log(stworzono plik)
@@ -0,0 +1,83 @@ | |||
1 | + | 2025-05-05T12:59:43: DiscordAPIError[50035]: Invalid Form Body | |
2 | + | 2025-05-05T12:59:43: content[BASE_TYPE_MAX_LENGTH]: Must be 2000 or fewer in length. | |
3 | + | 2025-05-05T12:59:43: at handleErrors (/home/fix/fixgpt/node_modules/@discordjs/rest/dist/index.js:748:13) | |
4 | + | 2025-05-05T12:59:43: at process.processTicksAndRejections (node:internal/process/task_queues:95:5) | |
5 | + | 2025-05-05T12:59:43: at async SequentialHandler.runRequest (/home/fix/fixgpt/node_modules/@discordjs/rest/dist/index.js:1149:23) | |
6 | + | 2025-05-05T12:59:43: at async SequentialHandler.queueRequest (/home/fix/fixgpt/node_modules/@discordjs/rest/dist/index.js:980:14) | |
7 | + | 2025-05-05T12:59:43: at async _REST.request (/home/fix/fixgpt/node_modules/@discordjs/rest/dist/index.js:1293:22) | |
8 | + | 2025-05-05T12:59:43: at async InteractionWebhook.editMessage (/home/fix/fixgpt/node_modules/discord.js/src/structures/Webhook.js:351:15) | |
9 | + | 2025-05-05T12:59:43: at async ChatInputCommandInteraction.editReply (/home/fix/fixgpt/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:248:17) | |
10 | + | 2025-05-05T12:59:43: at async Object.execute (file:///home/fix/fixgpt/commands/prompt.js:54:11) | |
11 | + | 2025-05-05T12:59:43: at async Client.<anonymous> (file:///home/fix/fixgpt/app.js:52:5) { | |
12 | + | 2025-05-05T12:59:43: requestBody: { | |
13 | + | 2025-05-05T12:59:43: files: [], | |
14 | + | 2025-05-05T12:59:43: json: { | |
15 | + | 2025-05-05T12:59:43: content: `Okay, let's break down Rust vs. C# for UI development. There's no simple "better" - it depends heavily on your priorities and project scope.\n` + | |
16 | + | 2025-05-05T12:59:43: '\n' + | |
17 | + | 2025-05-05T12:59:43: '**C# (with .NET/WPF/WinForms/MAUI):**\n' + | |
18 | + | 2025-05-05T12:59:43: '\n' + | |
19 | + | 2025-05-05T12:59:43: '* **Pros:**\n' + | |
20 | + | 2025-05-05T12:59:43: ' * **Mature Ecosystem:** .NET has a *huge* ecosystem of UI frameworks (WPF, WinForms, MAUI – cross-platform). Lots of libraries, tutorials, and support.\n' + | |
21 | + | 2025-05-05T12:59:43: ' * **Rapid Development:** C# is generally faster to develop in due to garbage collection, a rich standard library, and simpler syntax.\n' + | |
22 | + | 2025-05-05T12:59:43: ' * **Easier Learning Curve:** Easier to pick up than Rust, especially if you have prior object-oriented programming experience.\n' + | |
23 | + | 2025-05-05T12:59:43: ' * **Visual Studio:** Excellent IDE support with Visual Studio.\n' + | |
24 | + | 2025-05-05T12:59:43: ' * **Cross-Platform (MAUI):** MAUI allows you to build UIs for Windows, macOS, Android, and iOS from a single codebase.\n' + | |
25 | + | 2025-05-05T12:59:43: '\n' + | |
26 | + | 2025-05-05T12:59:43: '* **Cons:**\n' + | |
27 | + | 2025-05-05T12:59:43: ' * **Performance:** Garbage collection can introduce pauses. Generally not *as* performant as Rust.\n' + | |
28 | + | 2025-05-05T12:59:43: " * **Memory Safety (less concern):** C#'s garbage collection abstracts away memory management, reducing risk but also limiting fine-grained control.\n" + | |
29 | + | 2025-05-05T12:59:43: '\n' + | |
30 | + | 2025-05-05T12:59:43: '\n' + | |
31 | + | 2025-05-05T12:59:43: '\n' + | |
32 | + | 2025-05-05T12:59:43: '**Rust (with frameworks like Iced, Relm4, egui):**\n' + | |
33 | + | 2025-05-05T12:59:43: '\n' + | |
34 | + | 2025-05-05T12:59:43: '* **Pros:**\n' + | |
35 | + | 2025-05-05T12:59:43: ' * **Performance:** Exceptionally fast and efficient due to its zero-cost abstractions and memory safety guarantees.\n' + | |
36 | + | 2025-05-05T12:59:43: " * **Memory Safety:** Rust's compiler prevents memory-related bugs at compile time (no null pointers, data races, etc.).\n" + | |
37 | + | 2025-05-05T12:59:43: ' * **Control:** You have fine-grained control over memory allocation and resource management.\n' + | |
38 | + | 2025-05-05T12:59:43: ' * **Emerging UI Frameworks:** Frameworks like Iced and Relm4 are improving, although not as mature as .NET options. egui is a popular immediate mode GUI library.\n' + | |
39 | + | 2025-05-05T12:59:43: '\n' + | |
40 | + | 2025-05-05T12:59:43: '* **Cons:**\n' + | |
41 | + | 2025-05-05T12:59:43: " * **Steeper Learning Curve:** Rust's ownership and borrowing system can be challenging to master.\n" + | |
42 | + | 2025-05-05T12:59:43: ' * **Development Speed:** Generally slower development speed compared to C#. The compiler can be strict.\n' + | |
43 | + | 2025-05-05T12:59:43: " * **Less Mature UI Ecosystem:** Rust's UI frameworks are newer and have fewer features/libraries compared to .NET.\n" + | |
44 | + | 2025-05-05T12:59:43: ' * **Debugging:** Debugging Rust can be more difficult.\n' + | |
45 | + | 2025-05-05T12:59:43: '\n' + | |
46 | + | 2025-05-05T12:59:43: '**Summary:**\n' + | |
47 | + | 2025-05-05T12:59:43: '\n' + | |
48 | + | 2025-05-05T12:59:43: '* **Choose C# if:** You need to build a UI *quickly*, prioritize ease of development, and/or need a mature and well-supported platform (like desktop apps for Windows). MAUI is a compelling option for cross-platform development.\n' + | |
49 | + | 2025-05-05T12:59:43: "* **Choose Rust if:** Performance is *absolutely critical*, you need precise control over resources, and you're comfortable with a steeper learning curve. Consider it for embedded systems or specialized applications.\n" + | |
50 | + | 2025-05-05T12:59:43: '\n' + | |
51 | + | 2025-05-05T12:59:43: '\n' + | |
52 | + | 2025-05-05T12:59:43: '\n' + | |
53 | + | 2025-05-05T12:59:43: 'To help me tailor my advice further, could you tell me:\n' + | |
54 | + | 2025-05-05T12:59:43: '\n' + | |
55 | + | 2025-05-05T12:59:43: '* What type of UI are you planning to build (desktop, web, embedded)?\n' + | |
56 | + | 2025-05-05T12:59:43: "* What's your priority: Speed of development, performance, or something else?", | |
57 | + | 2025-05-05T12:59:43: tts: false, | |
58 | + | 2025-05-05T12:59:43: nonce: undefined, | |
59 | + | 2025-05-05T12:59:43: enforce_nonce: false, | |
60 | + | 2025-05-05T12:59:43: embeds: undefined, | |
61 | + | 2025-05-05T12:59:43: components: undefined, | |
62 | + | 2025-05-05T12:59:43: username: undefined, | |
63 | + | 2025-05-05T12:59:43: avatar_url: undefined, | |
64 | + | 2025-05-05T12:59:43: allowed_mentions: undefined, | |
65 | + | 2025-05-05T12:59:43: flags: undefined, | |
66 | + | 2025-05-05T12:59:43: message_reference: undefined, | |
67 | + | 2025-05-05T12:59:43: attachments: undefined, | |
68 | + | 2025-05-05T12:59:43: sticker_ids: undefined, | |
69 | + | 2025-05-05T12:59:43: thread_name: undefined, | |
70 | + | 2025-05-05T12:59:43: applied_tags: undefined, | |
71 | + | 2025-05-05T12:59:43: poll: undefined | |
72 | + | 2025-05-05T12:59:43: } | |
73 | + | 2025-05-05T12:59:43: }, | |
74 | + | 2025-05-05T12:59:43: rawError: { | |
75 | + | 2025-05-05T12:59:43: message: 'Invalid Form Body', | |
76 | + | 2025-05-05T12:59:43: code: 50035, | |
77 | + | 2025-05-05T12:59:43: errors: { content: [Object] } | |
78 | + | 2025-05-05T12:59:43: }, | |
79 | + | 2025-05-05T12:59:43: code: 50035, | |
80 | + | 2025-05-05T12:59:43: status: 400, | |
81 | + | 2025-05-05T12:59:43: method: 'PATCH', | |
82 | + | 2025-05-05T12:59:43: url: 'https://discord.com/api/v10/webhooks/1366823670730719362/aW50ZXJhY3Rpb246MTM2ODg4OTcxMTM3NTk0MTY3MjpnUmhzTG8wUGxmREpPc0ZXa254eURaWnlUUm9kR0hIUG8zalZDMzZ4TTRxU01HNWo2U2ZSRTZGVnFMT21yRm5pbVdFTk1hQ243aTduSFFBeDQ1MlFzQ2c0SlFMNnlqMUF4NXFEdnozbXZUUDFFZ0JNZXU3WG1kTHI1WU1EamtVNA/messages/%40original' | |
83 | + | 2025-05-05T12:59:43: } |
prompt.js(stworzono plik)
@@ -0,0 +1,66 @@ | |||
1 | + | import { SlashCommandBuilder } from 'discord.js'; | |
2 | + | import axios from 'axios'; | |
3 | + | ||
4 | + | let prompting = false; | |
5 | + | const num_gpu_map = { | |
6 | + | 'gemma3:12b': 48, | |
7 | + | 'gemma3:27b': 30, | |
8 | + | 'dolphin-mixtral:8x7b-v2.5': 9, | |
9 | + | 'phi4': 33 | |
10 | + | }; | |
11 | + | ||
12 | + | export default { | |
13 | + | data: new SlashCommandBuilder() | |
14 | + | .setName('prompt') | |
15 | + | .setDescription('Prompt a model') | |
16 | + | .addStringOption(option => | |
17 | + | option.setName('model') | |
18 | + | .setDescription('The model to prompt, see /models for available models') | |
19 | + | .setRequired(true) | |
20 | + | .addChoices([ | |
21 | + | { name: 'gemma3:12b', value: 'gemma3:12b' }, | |
22 | + | { name: 'gemma3:27b', value: 'gemma3:27b' }, | |
23 | + | { name: 'dolphin-mixtral', value: 'dolphin-mixtral:8x7b-v2.5' }, | |
24 | + | { name: 'phi4', value: 'phi4' } | |
25 | + | ]) | |
26 | + | ) | |
27 | + | .addStringOption(option => | |
28 | + | option.setName('prompt') | |
29 | + | .setDescription('The prompt to send to the model') | |
30 | + | .setRequired(true) | |
31 | + | .setMaxLength(1500) | |
32 | + | ), | |
33 | + | ||
34 | + | async execute(interaction) { | |
35 | + | interaction.deferReply(); | |
36 | + | ||
37 | + | if(!prompting) { | |
38 | + | prompting = true; | |
39 | + | ||
40 | + | const ollamaReply = await axios.post('http://localhost:11434/api/generate', { | |
41 | + | model: interaction.options.getString('model'), | |
42 | + | prompt: interaction.options.getString('prompt'), | |
43 | + | system: "Feel free to reply with long responses if necessary, but not longer than 2000 characters.", | |
44 | + | stream: false, | |
45 | + | options: { | |
46 | + | num_gpu: num_gpu_map[interaction.options.getString('model')] | |
47 | + | } | |
48 | + | }); | |
49 | + | ||
50 | + | console.log('[INFO] Prompted model:', interaction.options.getString('model')); | |
51 | + | console.log('[INFO] Prompt:', interaction.options.getString('prompt')); | |
52 | + | ||
53 | + | if(ollamaReply) { | |
54 | + | await interaction.editReply(ollamaReply.data.response); | |
55 | + | } | |
56 | + | else{ | |
57 | + | return await interaction.editReply('Unable to prompt ollama, try again later.'); | |
58 | + | } | |
59 | + | ||
60 | + | prompting = false; | |
61 | + | } | |
62 | + | else{ | |
63 | + | await interaction.editReply(`Don't make me shit myself, i am already replying to a prompt.`); | |
64 | + | } | |
65 | + | } | |
66 | + | }; |
Nowsze
Starsze