diff options
| author | sigoden <sigoden@gmail.com> | 2024-06-01 17:47:49 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-01 17:47:49 +0800 |
| commit | 571d1022f628cb7d2a3125664bd3293bac4471b5 (patch) | |
| tree | 67034aaf0a656ae9dce0cd0d3aae3605d2ea1767 /src/main.rs | |
| parent | 259583f4f750e4ece7aed07858a9589110d7cf5d (diff) | |
| download | aichat-571d1022f628cb7d2a3125664bd3293bac4471b5.tar.gz | |
refactor: rename some client structs and methods (#555)
* rename `Completeion*` to `ChatCompletions*`
* rename `send_message*` to `chat_completions*`
* rename `request_builder` to `chat_completions_builder`
* rename `build_body` to `build_chat_completions_body`
* rename `extract_completion` to `extract_chat_completions`
* format
* remove unused config fields
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 0bf5998..0a5e404 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ mod utils; extern crate log; use crate::cli::Cli; -use crate::client::{list_models, send_stream, CompletionOutput}; +use crate::client::{list_models, send_stream, ChatCompletionsOutput}; use crate::config::{ Config, GlobalConfig, Input, InputContext, WorkingMode, CODE_ROLE, EXPLAIN_SHELL_ROLE, SHELL_ROLE, @@ -150,9 +150,9 @@ async fn start_directive( let is_terminal_stdout = stdout().is_terminal(); let extract_code = !is_terminal_stdout && code_mode; let (output, tool_call_results) = if no_stream || extract_code { - let CompletionOutput { + let ChatCompletionsOutput { text, tool_calls, .. - } = client.send_message(input.clone()).await?; + } = client.chat_completions(input.clone()).await?; if !tool_calls.is_empty() { (String::new(), eval_tool_calls(config, tool_calls)?) } else { @@ -203,11 +203,11 @@ async fn shell_execute(config: &GlobalConfig, shell: &Shell, mut input: Input) - let ret = if is_terminal_stdout { let (spinner_tx, spinner_rx) = oneshot::channel(); tokio::spawn(run_spinner(" Generating", spinner_rx)); - let ret = client.send_message(input.clone()).await; + let ret = client.chat_completions(input.clone()).await; let _ = spinner_tx.send(()); ret } else { - client.send_message(input.clone()).await + client.chat_completions(input.clone()).await }; let mut eval_str = ret?.text; if let Ok(true) = CODE_BLOCK_RE.is_match(&eval_str) { |
