-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
379948f
commit a1b84f1
Showing
29 changed files
with
191 additions
and
337 deletions.
There are no files selected for viewing
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"url": "http://127.0.0.1:8080" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"server_executable": "llama.cpp/build/bin/server", | ||
"model_path": "/home/namtd/workspace/personal/kicopilot/playground/models/model.gguf", | ||
"c": 2048 | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
if [! -d llama.cpp/build ]; then | ||
echo "Building the llamacpp ..." | ||
cd llama.cpp | ||
mkdir -p build | ||
rm -rf build/* | ||
cd build | ||
cmake .. -DLLAMA_BLAS=ON -DLLAMA_BLAS_VENDOR=OpenBLAS | ||
cmake --build . --config Release -- -j$(nproc) | ||
cd ../.. | ||
fi | ||
|
||
echo "Starting the llamcpp server ..." | ||
./llama.cpp/build/bin/server -m /home/namtd/workspace/personal/kicopilot/playground/models/model.gguf -c 128 --host 0.0.0.0 --port 8080 |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='temi', | ||
version='2.0.0', | ||
packages=find_packages(), | ||
entry_points={ | ||
'console_scripts': [ | ||
'temi = src.temi_interface:main', | ||
], | ||
}, | ||
# Add all necessary package requirements here | ||
install_requires=[ | ||
'requests', | ||
# Add other dependencies needed for your package | ||
], | ||
# Metadata | ||
author='Nam Tran', | ||
author_email='[email protected]', | ||
description='An assistant in your terminal powered by llama.cpp', | ||
long_description=open('README.md').read(), | ||
long_description_content_type='text/markdown', | ||
url='https://github.com/namtranase/terminalmind', # Use the URL to the github repo. | ||
project_urls={ | ||
'Source': 'https://github.com/namtranase/terminalmind', | ||
# Add any other relevant links here | ||
}, | ||
) |
Empty file.
Empty file.
Empty file.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class AssistantGit: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def get_response(self, api_func, user_input): | ||
completion_options = { | ||
"temperature": 0.7, | ||
"top_k": 50, | ||
# ... include other options as needed ... | ||
} | ||
prompt = f"### Human: {user_input}\n### Assistant: " | ||
response = api_func(prompt, **completion_options) | ||
|
||
return response | ||
|
||
|
||
class AssistantTerminal: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def get_response(self, api_func, user_input): | ||
completion_options = { | ||
"temperature": 0.7, | ||
"top_k": 50, | ||
# ... include other options as needed ... | ||
} | ||
prompt = f"### Human: {user_input}\n### Assistant: " | ||
response = api_func(prompt, **completion_options) | ||
|
||
return response |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class ChatModel: | ||
def __init__(self, instruction): | ||
self.instruction = instruction | ||
self.chat_history = [] | ||
|
||
def format_chat_prompt(self, user_input): | ||
formatted_chat = f"{self.instruction}\n" | ||
for i, message in enumerate(self.chat_history): | ||
speaker = "Human" if i % 2 == 0 else "Assistant" | ||
formatted_chat += f"### {speaker}: {message}\n" | ||
formatted_chat += f"### Human: {user_input}\n### Assistant: " | ||
return formatted_chat | ||
|
||
def format_prompt(self, user_input): | ||
formatted_chat = f"{self.instruction}\n" | ||
formatted_chat += f"### Human: {user_input}\n### Assistant: " | ||
return formatted_chat |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class ChatModel: | ||
def __init__(self, instruction): | ||
self.instruction = instruction | ||
self.chat_history = [] | ||
|
||
def format_chat_prompt(self, user_input): | ||
formatted_chat = f"{self.instruction}\n" | ||
for i, message in enumerate(self.chat_history): | ||
speaker = "Human" if i % 2 == 0 else "Assistant" | ||
formatted_chat += f"### {speaker}: {message}\n" | ||
formatted_chat += f"### Human: {user_input}\n### Assistant: " | ||
return formatted_chat | ||
|
||
def format_prompt(self, user_input): | ||
formatted_chat = f"{self.instruction}\n" | ||
formatted_chat += f"### Human: {user_input}\n### Assistant: " | ||
return formatted_chat | ||
|
||
class TermFuncCall: | ||
def __init__(self) -> None: | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class PromptWrapper: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def get_assistant_prompt(self): | ||
return None | ||
|
||
def get_function_call_prompt(self): | ||
return None |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import json | ||
|
||
from server_wrapper import ServerWrapper | ||
from prompt_wrapper import PromptWrapper | ||
from .modules.assistant.assistant import AssistantTerminal, AssistantGit | ||
from .modules.function_calling.function_model import TermFuncCall | ||
|
||
import argparse | ||
|
||
class TemiInterface: | ||
def __init__(self, config_path="configs/server_config"): | ||
config = None | ||
with open(config_path, "r", encoding="utf-8") as config_file: | ||
config = json.load(config_file) | ||
|
||
self.config = config | ||
self.server_wrapper = ServerWrapper(config=config) | ||
self.prompt_wrapper = PromptWrapper() | ||
self.ast_terminal = AssistantTerminal() | ||
self.ast_git = AssistantGit() | ||
self.term_func = TermFuncCall() | ||
|
||
def check_server_status(self): | ||
status = self.server_wrapper.check_server() | ||
return status | ||
|
||
def handle_assitant(self, user_input): | ||
print(user_input) | ||
if "git" in user_input: | ||
return self.ast_git.get_response(self.server_wrapper.generate_completion, user_input) | ||
else: | ||
return self.ast_terminal.get_response(self.server_wrapper.generate_completion, user_input) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='temi - Your Terminal Assistant') | ||
subparsers = parser.add_subparsers(dest='command') | ||
|
||
# Parser for "check server" command | ||
server_parser = subparsers.add_parser('check', help='Check the temi server status') | ||
server_parser.add_argument('status', nargs='?', help='The "status" argument to check the server') | ||
|
||
# Parser for "assistant" command | ||
query_parser = subparsers.add_parser('assistant', help='Assistant mode') | ||
query_parser.add_argument('user_input', nargs='+', help='The question or command for temi to process') | ||
|
||
args = parser.parse_args() | ||
temi_interface = TemiInterface("/home/namtd/workspace/personal/terminalmind/configs/sevrer_config.json") | ||
|
||
if args.command == 'check': | ||
status = temi_interface.check_server_status() | ||
print(status) | ||
elif args.command == 'assistant': | ||
# Join the list of user_input into a single string | ||
user_input = ' '.join(args.user_input) | ||
answer = temi_interface.handle_assitant(user_input) | ||
print(answer) | ||
else: | ||
parser.print_help() | ||
|
||
if __name__ == "__main__": | ||
main() |
Empty file.
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def trim(s): | ||
return s.strip() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.