Skip to content

Commit 908c50a

Browse files
authored
Merge pull request llmware-ai#738 from RS-labhub/main
Quine Quest 011 Submision
2 parents d8754db + b42f37f commit 908c50a

19 files changed

+601
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3+
4+
name: Python application
5+
6+
on:
7+
push:
8+
branches: [ "master" ]
9+
pull_request:
10+
branches: [ "master" ]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
build:
17+
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Python 3.10
23+
uses: actions/setup-python@v3
24+
with:
25+
python-version: "3.10"
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8 pytest
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
- name: Test with pytest
38+
run: |
39+
pytest

Quest/Chatbot/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/__pycache__

Quest/Chatbot/Assets/Chatbot.png

104 KB
Loading

Quest/Chatbot/Assets/Classic Gui.png

26 KB
Loading
81.6 KB
Loading
75.6 MB
Binary file not shown.

Quest/Chatbot/Assets/Models.png

938 KB
Loading

Quest/Chatbot/Assets/Modern GUI.png

56.9 KB
Loading
40.7 KB
Loading

Quest/Chatbot/Assets/RS LOGO.png

222 KB
Loading

Quest/Chatbot/Assets/author.jpeg

352 KB
Loading

Quest/Chatbot/CODE_OF_CONDUCT.md

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from llmware.models import ModelCatalog
2+
from llmware.prompts import Prompt
3+
4+
def simple_chatbot(model_name):
5+
model = Prompt().load_model(model_name)
6+
7+
print(f"Chatbot initialized with model: {model_name}")
8+
9+
while True:
10+
user_input = input("You: ")
11+
12+
output = model.prompt_main(user_input,
13+
prompt_name="default_with_context",
14+
temperature=0.30)
15+
bot_response = output["llm_response"].strip("\n")
16+
17+
print("Bot:", bot_response)
18+
19+
if user_input.lower() == 'quit':
20+
print("Exiting chatbot...")
21+
break
22+
23+
if __name__ == "__main__":
24+
model_name = "phi-3-gguf"
25+
simple_chatbot(model_name)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import customtkinter as ctk
2+
from tkinter import LEFT, RIGHT, BOTH, X, Y, END, WORD
3+
from llmware.prompts import Prompt
4+
5+
6+
class Chatbot:
7+
8+
def __init__(self, root, model):
9+
self.model = model
10+
self.root = root
11+
self.root.title("LLMWARE Chatbot Interface")
12+
self.root.geometry("400x600")
13+
self.root.overrideredirect(True) # Remove default title bar
14+
15+
ctk.set_appearance_mode("dark") # Modes: system (default), light, dark
16+
ctk.set_default_color_theme(
17+
"dark-blue"
18+
) # Themes: blue (default), dark-blue, green
19+
20+
# Create custom title bar
21+
self.title_bar = ctk.CTkFrame(self.root, height=30, corner_radius=0)
22+
self.title_bar.pack(fill=X)
23+
24+
self.title_label = ctk.CTkLabel(
25+
self.title_bar, text="LLMWARE Chatbot Interface", anchor="w", padx=10
26+
)
27+
self.title_label.pack(side=LEFT, fill=Y)
28+
29+
self.minimize_button = ctk.CTkButton(
30+
self.title_bar, text="_", width=30, command=self.minimize_window
31+
)
32+
self.minimize_button.pack(side=RIGHT, padx=(0, 5), pady=(5, 0))
33+
34+
self.close_button = ctk.CTkButton(
35+
self.title_bar, text="X", width=30, command=self.close_window
36+
)
37+
self.close_button.pack(side=RIGHT, padx=(0, 5), pady=(5, 0))
38+
39+
self.chat_frame = ctk.CTkFrame(root)
40+
self.chat_frame.pack(expand=True, fill=BOTH, padx=10, pady=(0, 10))
41+
42+
self.chat_display = ctk.CTkTextbox(
43+
self.chat_frame,
44+
wrap=WORD,
45+
state="disabled",
46+
fg_color="#333333",
47+
text_color="white",
48+
)
49+
self.chat_display.pack(expand=True, fill=BOTH, padx=10, pady=10)
50+
51+
self.input_frame = ctk.CTkFrame(root)
52+
self.input_frame.pack(side=ctk.BOTTOM, fill=X, padx=10, pady=10)
53+
54+
self.input_entry = ctk.CTkEntry(
55+
self.input_frame, placeholder_text="Type your message here..."
56+
)
57+
self.input_entry.pack(side=LEFT, expand=True, fill=X, padx=(0, 10))
58+
59+
self.send_button = ctk.CTkButton(
60+
self.input_frame, text="Send", command=self.send_message
61+
)
62+
self.send_button.pack(side=RIGHT)
63+
64+
self.previous_sender = None # To keep track of the previous message sender
65+
66+
self.make_window_draggable()
67+
68+
def make_window_draggable(self):
69+
self.title_bar.bind("<Button-1>", self.start_move)
70+
self.title_bar.bind("<B1-Motion>", self.do_move)
71+
self.title_bar.bind("<ButtonRelease-1>", self.stop_move)
72+
73+
def start_move(self, event):
74+
self.x = event.x
75+
self.y = event.y
76+
77+
def do_move(self, event):
78+
deltax = event.x - self.x
79+
deltay = event.y - self.y
80+
new_x = self.root.winfo_x() + deltax
81+
new_y = self.root.winfo_y() + deltay
82+
self.root.geometry(f"+{new_x}+{new_y}")
83+
84+
def stop_move(self, event):
85+
self.x = None
86+
self.y = None
87+
88+
def minimize_window(self):
89+
self.root.iconify()
90+
91+
def close_window(self):
92+
self.root.destroy()
93+
94+
def send_message(self):
95+
message = self.input_entry.get().strip()
96+
if message != "":
97+
self.chat_display.configure(state="normal")
98+
if self.previous_sender == "Bot":
99+
self.chat_display.insert(END, "\n\n")
100+
self.chat_display.insert(END, "You: " + message + "\n")
101+
self.chat_display.insert(
102+
END, "Bot: " + self.generate_bot_response(message) + "\n\n"
103+
)
104+
self.chat_display.configure(state="disabled")
105+
self.chat_display.see(END) # Scroll to the end
106+
self.input_entry.delete(0, END)
107+
self.previous_sender = "You"
108+
109+
def generate_bot_response(self, user_message="Hi"):
110+
model = Prompt().load_model(self.model)
111+
112+
output = model.prompt_main(
113+
user_message, prompt_name="default_with_context", temperature=0.30
114+
)
115+
bot_response = output["llm_response"].strip("\n")
116+
# bot_response = output["llm_response"].strip("\n").split("\n")[0]
117+
118+
return bot_response
119+
120+
121+
if __name__ == "__main__":
122+
root = ctk.CTk()
123+
app = Chatbot(root, "phi-3-gguf")
124+
root.mainloop()
+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import tkinter as tk
2+
from tkinter import scrolledtext
3+
from llmware.models import ModelCatalog
4+
from llmware.prompts import Prompt
5+
6+
class ChatbotUI:
7+
def __init__(self, root):
8+
self.root = root
9+
self.root.title("LLMWARE Chatbot Interface")
10+
11+
self.chat_frame = tk.Frame(root)
12+
self.chat_frame.pack(expand=True, fill=tk.BOTH)
13+
14+
self.chat_display = scrolledtext.ScrolledText(self.chat_frame, wrap=tk.WORD)
15+
self.chat_display.pack(expand=True, fill=tk.BOTH)
16+
17+
self.input_frame = tk.Frame(root, bg="lightgray")
18+
self.input_frame.pack(side=tk.BOTTOM, fill=tk.X)
19+
20+
self.input_entry = tk.Entry(self.input_frame)
21+
self.input_entry.pack(side=tk.LEFT, expand=True, fill=tk.X)
22+
23+
self.send_button = tk.Button(self.input_frame, text="Send", command=self.send_message)
24+
self.send_button.pack(side=tk.RIGHT)
25+
26+
self.previous_sender = None
27+
28+
def send_message():
29+
user_input = entry.get()
30+
chat_history.insert(tk.END, f"You: {user_input}\n")
31+
chat_history.yview(tk.END) # Scroll to the bottom
32+
entry.delete(0, tk.END) # Clear the entry field
33+
34+
# Get bot response
35+
output = model.prompt_main(user_input, prompt_name="default_with_context", temperature=0.30)
36+
bot_response = output["llm_response"].strip("\n")
37+
38+
# Display bot response
39+
chat_history.insert(tk.END, f"Bot: {bot_response}\n\n")
40+
chat_history.yview(tk.END) # Scroll to the bottom
41+
42+
# Create main window
43+
root = tk.Tk()
44+
root.title("LLMWARE Chatbot Interface")
45+
46+
# Load the model
47+
model_name = "phi-3-gguf"
48+
model = Prompt().load_model(model_name)
49+
50+
# Create chat history window
51+
chat_history = tk.Text(root, width=50, height=15)
52+
chat_history.grid(row=0, column=0, padx=10, pady=10, columnspan=2)
53+
54+
# Create entry field for user input
55+
entry = tk.Entry(root, width=40)
56+
entry.grid(row=1, column=0, padx=10, pady=10)
57+
58+
# Create send button
59+
send_button = tk.Button(root, text="Send", width=8, command=send_message)
60+
send_button.grid(row=1, column=1, padx=10, pady=10)
61+
62+
# Start the GUI event loop
63+
root.mainloop()

0 commit comments

Comments
 (0)