-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/bots prompt multi model #66
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d6e1dd5
fix: 🐛 login url need add listener url change
sologeek 6c2b9f6
refactor: 💡 remove quick launcher
sologeek 9155e3f
feat: 🎸 bot prompt multi model
sologeek 84381f1
feat: 🎸 add official text bot
sologeek 7936730
fix: 🐛 req text logic update
sologeek 8e709db
fix: 🐛 user and bot avatar lost
sologeek 840c46b
fix: 🐛 manually unsubscribe when drop, related to Ribir #507
wjian23 b23250c
chore: 🤖 update ribir to v0.1.0-alpha.0
wjian23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
use std::path::PathBuf; | ||
use std::path::{Path, PathBuf}; | ||
|
||
use home::home_dir; | ||
|
||
|
@@ -15,6 +15,7 @@ static CURRENT_USER: &str = "current_user"; | |
static NONCE_FILE: &str = "nonce"; | ||
static TOKEN_FILE: &str = "token"; | ||
static LOCAL_STATE: &str = "local_state"; | ||
static POLESTAR_STATIC: &str = "static"; | ||
|
||
pub fn project_home_path() -> PathBuf { | ||
home_dir() | ||
|
@@ -103,6 +104,14 @@ pub fn create_if_not_exist_dir(path: PathBuf) { | |
} | ||
} | ||
|
||
pub fn get_static_file(file: &str) -> PolestarResult<Vec<u8>> { | ||
let mut path = project_home_path(); | ||
path.push(POLESTAR_STATIC); | ||
path.push(file); | ||
let content = std::fs::read(&path)?; | ||
Ok(content) | ||
} | ||
|
||
pub mod encrypt { | ||
use std::{fs::File, io::Write}; | ||
|
||
|
@@ -156,18 +165,18 @@ pub mod encrypt { | |
} | ||
|
||
pub mod launch { | ||
use std::{fs, io::Write}; | ||
use std::{fs, io::Write, path::PathBuf}; | ||
|
||
use super::{ | ||
create_if_not_exist_dir, project_bot_config_path, project_config_path, project_home_path, | ||
project_user_path, | ||
copy_dir_all, create_if_not_exist_dir, project_bot_config_path, project_config_path, | ||
project_home_path, project_user_path, POLESTAR_STATIC, | ||
}; | ||
|
||
pub fn setup_project() { | ||
create_if_not_exist_dir(project_home_path()); | ||
create_if_not_exist_dir(project_user_path()); | ||
create_if_not_exist_dir(project_config_path()); | ||
write_default_bot_config(); | ||
copy_static_files_to_user_data(); | ||
} | ||
|
||
pub fn write_default_bot_config() { | ||
|
@@ -183,4 +192,28 @@ pub mod launch { | |
.write_all(content.as_bytes()) | ||
.expect("can't write bot.json"); | ||
} | ||
|
||
pub fn copy_static_files_to_user_data() { | ||
let mut src = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
src.push("../gui/static"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is CARGO_MANIFEST_DIR valid after pack to install package |
||
let mut dst = project_home_path(); | ||
dst.push(POLESTAR_STATIC); | ||
copy_dir_all(src, dst).expect("Failed to copy static files"); | ||
} | ||
} | ||
|
||
use std::{fs, io}; | ||
|
||
fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()> { | ||
fs::create_dir_all(&dst)?; | ||
for entry in fs::read_dir(src)? { | ||
let entry = entry?; | ||
let ty = entry.file_type()?; | ||
if ty.is_dir() { | ||
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?; | ||
} else { | ||
fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?; | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the msg iter can be pass from the caller, skip(2) is odd