diff options
| author | sigoden <sigoden@gmail.com> | 2023-11-27 14:04:50 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-27 14:04:50 +0800 |
| commit | 35c75506e2fd94e2285d8a3cb66208d518d5f992 (patch) | |
| tree | 97fb643bb5e231022442c1cc617f2daeaa152a66 /src/utils | |
| parent | 5bfe95d31110e75e84626598f033805b0ae4326c (diff) | |
| download | aichat-35c75506e2fd94e2285d8a3cb66208d518d5f992.tar.gz | |
feat: support vision (#249)
* feat: support vision
* clippy
* implement vision
* resolve data url to local file
* add model openai:gpt-4-vision-preview
* use newline to concate embeded text files
* set max_tokens for gpt-4-vision-preview
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/mod.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 0039298..8a80b23 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -8,6 +8,8 @@ pub use self::clipboard::set_text; pub use self::prompt_input::*; pub use self::tiktoken::cl100k_base_singleton; +use sha2::{Digest, Sha256}; + pub fn now() -> String { let now = chrono::Local::now(); now.to_rfc3339_opts(chrono::SecondsFormat::Secs, false) @@ -76,6 +78,13 @@ pub fn init_tokio_runtime() -> anyhow::Result<tokio::runtime::Runtime> { .with_context(|| "Failed to init tokio") } +pub fn sha256sum(input: &str) -> String { + let mut hasher = Sha256::new(); + hasher.update(input); + let result = hasher.finalize(); + format!("{:x}", result) +} + #[cfg(test)] mod tests { use super::*; |
