[PR #189] [MERGED] Improve command parsing and multiline string handling #15302

Closed
opened 2026-04-16 04:55:10 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/189
Author: @Mohit-Gaur
Created: 7/24/2023
Status: Merged
Merged: 7/25/2023
Merged by: @mxyng

Base: mainHead: main


📝 Commits (2)

  • ed89da9 Improve command parsing and multiline string handling
  • f5f7904 Incorporate code review improvements

📊 Changes

1 file changed (+10 additions, -7 deletions)

View changed files

📝 parser/parser.go (+10 -7)

📄 Description

This PR enhances the existing parser package. Main improvements include better error handling, optimized string-to-byte conversions, and efficient handling of multiline strings.

Detailed changes:

  • Define a multilineString constant for repeated values to avoid duplication.
  • Modify the error handling in the Parse function to return an error for unknown commands.
  • Replace bytes.ToUpper and bytes.ToLower with strings.ToUpper and strings.ToLower for faster string conversions.
  • Optimize removal of """ from multiline strings by using bytes.Index and bytes.LastIndex instead of bytes.Replace.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/189 **Author:** [@Mohit-Gaur](https://github.com/Mohit-Gaur) **Created:** 7/24/2023 **Status:** ✅ Merged **Merged:** 7/25/2023 **Merged by:** [@mxyng](https://github.com/mxyng) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (2) - [`ed89da9`](https://github.com/ollama/ollama/commit/ed89da92b48a33df80b4e472898acad4cb45d28e) Improve command parsing and multiline string handling - [`f5f7904`](https://github.com/ollama/ollama/commit/f5f79049c2735bc21d83356f8c5853fd0ae80389) Incorporate code review improvements ### 📊 Changes **1 file changed** (+10 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `parser/parser.go` (+10 -7) </details> ### 📄 Description This PR enhances the existing parser package. Main improvements include better error handling, optimized string-to-byte conversions, and efficient handling of multiline strings. Detailed changes: - Define a `multilineString` constant for repeated values to avoid duplication. - Modify the error handling in the `Parse` function to return an error for unknown commands. - Replace `bytes.ToUpper` and `bytes.ToLower` with `strings.ToUpper` and `strings.ToLower` for faster string conversions. - Optimize removal of `"""` from multiline strings by using `bytes.Index` and `bytes.LastIndex` instead of `bytes.Replace`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 04:55:10 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#15302