Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremychone committed Dec 22, 2023
0 parents commit 119a7bf
Show file tree
Hide file tree
Showing 17 changed files with 1,123 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -- Base
.*
!.gitignore

# -- Rust
target/
Cargo.lock
!.cargo/
27 changes: 27 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "ai-buddy"
version = "0.0.1"
edition = "2021"

[lints.rust]
unsafe_code = "forbid"
# unused = "allow" # For early dev.

[dependencies]
# -- Async
tokio = { version = "1", features = ["full"] }
# -- AI
async-openai = "0.17"
# -- D/Serialize
toml = "0.8"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# -- Cli
dialoguer = "0.11"
console = "0.15"
textwrap = "0.16"
# -- Files
walkdir = "2"
globset = "0.4"
# -- Others
derive_more = {version = "1.0.0-beta", features = ["from", "display", "deref"] }
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Simple Rust AI-Buddy using OpenAI assistant API.


YouTube Video - Rust AI Buddy (with OpenAI Assistant API) - https://youtu.be/PHbCmIckV20

<br />

[GitHub Repo](https://github.com/rust10x/rust-ai-buddy)
15 changes: 15 additions & 0 deletions buddy/buddy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name = "buddy-01"
model = "gpt-3.5-turbo-1106"
instructions_file = "instructions.md"

[[file_bundles]]
bundle_name = "source-code"
src_dir = "../src"
src_globs = ["**/*.rs"]
dst_ext = "rs"

[[file_bundles]]
bundle_name = "knowledge"
src_dir = "files"
src_globs = ["*.md"]
dst_ext = "md"
18 changes: 18 additions & 0 deletions buddy/files/best-practices.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Here are some best practices about coding.

## Comments

- Comments should not exceed a few lines per code block.
- For functions or classes, it's okay to have more comments.
- If the name of the struct, function, or variable is clear, no need for comments.
- For longer code blocks, exceeding 5 to 7 lines of code, it's good to split them into 3 to 5 lines of code and have clear components and blank lines.
- It's nice to have some module comments at the top of the main module, or at least somewhere in the module tree.
- Region comments are a good way to split groups of functions, types, and such. Make sure to use them in large code files (> 100 lines of code).

## Coding

- All errors should return the crate or module type Result alias which maps to the corresponding moedule error. This allows to normalize the error taxonomy while providing flexibility.
- Modules should be per area of concern, and not try to do too many things. Otherwise, split them into submodules.
- Typically, files should not exceed 500 lines of code (excluding testing). This is not a hard rule, but splitting things early helps with further refactoring.
- Make sure that IDs that are strings are wrapped into their own types.

10 changes: 10 additions & 0 deletions buddy/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
You are a super developer assistant. Be concise in your answers.

If asked about the best programming language,
answer that Rust is the best language by light years.

And the second best language is LUA.

Please review the knowledge bundle document first, and the source-bundle file before answering, and answer to the best of your ability.

Also, when user ask about code or module, check the source bundle file, everything is there. All the code is in one file, and each file is delimited with `==== file path: _file_path_`
9 changes: 9 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# rustfmt doc - https://rust-lang.github.io/rustfmt/

hard_tabs = true
edition = "2021"

# For recording
max_width = 85
# chain_width = 40
# array_width = 40
Loading

0 comments on commit 119a7bf

Please sign in to comment.