mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-12-24 21:37:03 +00:00
Compare commits
2 Commits
prototype-
...
prototype-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5964289284 | ||
|
|
6b81854d48 |
@@ -212,7 +212,7 @@ impl IndexScheduler {
|
||||
#[cfg(test)]
|
||||
run_loop_iteration: self.run_loop_iteration.clone(),
|
||||
features: self.features.clone(),
|
||||
chat_settings: self.chat_settings.clone(),
|
||||
chat_settings: self.chat_settings,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -870,12 +870,12 @@ impl IndexScheduler {
|
||||
|
||||
pub fn chat_settings(&self) -> Result<Option<serde_json::Value>> {
|
||||
let rtxn = self.env.read_txn().map_err(Error::HeedTransaction)?;
|
||||
self.chat_settings.get(&rtxn, &"main").map_err(Into::into)
|
||||
self.chat_settings.get(&rtxn, "main").map_err(Into::into)
|
||||
}
|
||||
|
||||
pub fn put_chat_settings(&self, settings: &serde_json::Value) -> Result<()> {
|
||||
let mut wtxn = self.env.write_txn().map_err(Error::HeedTransaction)?;
|
||||
self.chat_settings.put(&mut wtxn, &"main", &settings)?;
|
||||
self.chat_settings.put(&mut wtxn, "main", settings)?;
|
||||
wtxn.commit().map_err(Error::HeedTransaction)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -186,10 +186,9 @@ async fn non_streamed_chat(
|
||||
if let Some(api_key) = chat_settings.api_key.as_ref() {
|
||||
config = config.with_api_key(api_key);
|
||||
}
|
||||
// We cannot change the endpoint
|
||||
// if let Some(endpoint) = chat_settings.endpoint.as_ref() {
|
||||
// config.with_api_base(&endpoint);
|
||||
// }
|
||||
if let Some(base_api) = chat_settings.base_api.as_ref() {
|
||||
config = config.with_api_base(base_api);
|
||||
}
|
||||
let client = Client::with_config(config);
|
||||
|
||||
setup_search_tool(&mut chat_completion, &chat_settings.prompts);
|
||||
@@ -257,10 +256,9 @@ async fn streamed_chat(
|
||||
if let Some(api_key) = chat_settings.api_key.as_ref() {
|
||||
config = config.with_api_key(api_key);
|
||||
}
|
||||
// We cannot change the endpoint
|
||||
// if let Some(endpoint) = chat_settings.endpoint.as_ref() {
|
||||
// config.with_api_base(&endpoint);
|
||||
// }
|
||||
if let Some(base_api) = chat_settings.base_api.as_ref() {
|
||||
config = config.with_api_base(base_api);
|
||||
}
|
||||
|
||||
setup_search_tool(&mut chat_completion, &chat_settings.prompts);
|
||||
|
||||
@@ -276,11 +274,11 @@ async fn streamed_chat(
|
||||
match result {
|
||||
Ok(resp) => {
|
||||
let delta = &resp.choices[0].delta;
|
||||
#[allow(deprecated)]
|
||||
let ChatCompletionStreamResponseDelta {
|
||||
content,
|
||||
// Using deprecated field but keeping for compatibility
|
||||
#[allow(deprecated)]
|
||||
function_call: _,
|
||||
function_call: _,
|
||||
ref tool_calls,
|
||||
role: _,
|
||||
refusal: _,
|
||||
@@ -291,7 +289,7 @@ async fn streamed_chat(
|
||||
break 'main;
|
||||
}
|
||||
|
||||
if let Some(_) = content {
|
||||
if content.is_some() {
|
||||
tx.send(Event::Data(sse::Data::new_json(&resp).unwrap())).await.unwrap()
|
||||
}
|
||||
|
||||
@@ -321,8 +319,8 @@ async fn streamed_chat(
|
||||
|
||||
let (meili_calls, _other_calls): (Vec<_>, Vec<_>) =
|
||||
mem::take(&mut global_tool_calls)
|
||||
.into_iter()
|
||||
.map(|(_, call)| ChatCompletionMessageToolCall {
|
||||
.into_values()
|
||||
.map(|call| ChatCompletionMessageToolCall {
|
||||
id: call.id,
|
||||
r#type: ChatCompletionToolType::Function,
|
||||
function: FunctionCall {
|
||||
@@ -342,7 +340,7 @@ async fn streamed_chat(
|
||||
|
||||
for call in meili_calls {
|
||||
tx.send(Event::Data(
|
||||
sse::Data::new_json(&json!({
|
||||
sse::Data::new_json(json!({
|
||||
"object": "chat.completion.tool.call",
|
||||
"tool": call,
|
||||
}))
|
||||
@@ -380,7 +378,7 @@ async fn streamed_chat(
|
||||
);
|
||||
|
||||
tx.send(Event::Data(
|
||||
sse::Data::new_json(&json!({
|
||||
sse::Data::new_json(json!({
|
||||
"object": "chat.completion.tool.output",
|
||||
"tool": ChatCompletionRequestMessage::Tool(
|
||||
ChatCompletionRequestToolMessage {
|
||||
|
||||
@@ -48,7 +48,7 @@ async fn patch_settings(
|
||||
#[serde(deny_unknown_fields, rename_all = "camelCase")]
|
||||
pub struct ChatSettings {
|
||||
pub source: String,
|
||||
pub endpoint: Option<String>,
|
||||
pub base_api: Option<String>,
|
||||
pub api_key: Option<String>,
|
||||
pub prompts: ChatPrompts,
|
||||
pub indexes: BTreeMap<String, ChatIndexSettings>,
|
||||
@@ -95,7 +95,7 @@ impl Default for ChatSettings {
|
||||
fn default() -> Self {
|
||||
ChatSettings {
|
||||
source: "openai".to_string(),
|
||||
endpoint: None,
|
||||
base_api: None,
|
||||
api_key: None,
|
||||
prompts: ChatPrompts {
|
||||
system: DEFAULT_SYSTEM_MESSAGE.to_string(),
|
||||
|
||||
Reference in New Issue
Block a user