Skip to content

Commit

Permalink
fix: always set return_full_text to false for better UX (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
McPatate authored Feb 13, 2024
1 parent 4437c0c commit fe1f6aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/llm-ls/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "llm-ls"
version = "0.4.0"
version = "0.5.2"
edition = "2021"

[[bin]]
Expand Down
8 changes: 7 additions & 1 deletion crates/llm-ls/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{APIError, APIResponse, Generation, NAME, VERSION};
use custom_types::llm_ls::{Backend, Ide};
use reqwest::header::{HeaderMap, HeaderValue, AUTHORIZATION, USER_AGENT};
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
use serde_json::{json, Map, Value};
use std::fmt::Display;

use crate::error::{Error, Result};
Expand Down Expand Up @@ -160,6 +160,12 @@ pub(crate) fn build_body(
match backend {
Backend::HuggingFace { .. } | Backend::Tgi { .. } => {
request_body.insert("inputs".to_owned(), Value::String(prompt));
if let Some(Value::Object(params)) = request_body.get_mut("parameters") {
params.insert("return_full_text".to_owned(), Value::Bool(false));
} else {
let params = json!({ "parameters": { "return_full_text": false } });
request_body.insert("parameters".to_owned(), params);
}
}
Backend::Ollama { .. } | Backend::OpenAi { .. } => {
request_body.insert("prompt".to_owned(), Value::String(prompt));
Expand Down

0 comments on commit fe1f6aa

Please sign in to comment.