Skip to content

Commit 3ae3762

Browse files
Add files via upload
1 parent 5f2d33a commit 3ae3762

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/frontend/archive_gui.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import os
2+
import sys
3+
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QPushButton
4+
from PyQt5.QtCore import Qt
5+
from archive.archive_analyzer import analyze_sources
6+
7+
class ArchiveGUI(QWidget):
8+
def __init__(self):
9+
super().__init__()
10+
11+
self.initUI()
12+
13+
def initUI(self):
14+
self.setGeometry(300, 300, 300, 200)
15+
self.setWindowTitle('Archive Analyzer')
16+
17+
layout = QVBoxLayout()
18+
19+
button = QPushButton('Analyze Sources')
20+
button.clicked.connect(self.analyze_sources)
21+
layout.addWidget(button)
22+
23+
self.setLayout(layout)
24+
25+
def analyze_sources(self):
26+
analyze_sources()
27+
28+
if __name__ == '__main__':
29+
app = QApplication(sys.argv)
30+
ex = ArchiveGUI()
31+
ex.show()
32+
sys.exit(app.exec_())

src/frontend/export_history.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import json
3+
import csv
4+
5+
def export_chat_history(chat_history, file_format="json", file_name="chat_history"):
6+
if file_format == "json":
7+
with open(f"{file_name}.json", "w") as file:
8+
json.dump(chat_history, file)
9+
elif file_format == "csv":
10+
with open(f"{file_name}.csv", "w", newline="") as file:
11+
writer = csv.writer(file)
12+
writer.writerow(["Prompt", "Response"])
13+
writer.writerows(chat_history)
14+
15+
# Example Usage
16+
history = [("Hello", "Hi!"), ("How are you?", "I'm fine, thank you.")]
17+
export_chat_history(history, file_format="csv")

src/frontend/gui_chat_interface.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
import gradio as gr
3+
from backend.ai_chat import MultiAIChat
4+
5+
chat_history = []
6+
7+
def chat_with_ai(prompt, ai_provider):
8+
chat = MultiAIChat("openai_key", "huggingface_key", "anthropic_key")
9+
response = ""
10+
if ai_provider == "OpenAI":
11+
response = chat.openai_chat(prompt)
12+
elif ai_provider == "Hugging Face":
13+
response = chat.huggingface_chat(prompt)
14+
elif ai_provider == "Anthropic":
15+
response = chat.anthropic_chat(prompt)
16+
chat_history.append((prompt, response))
17+
return chat_history
18+
19+
iface = gr.Interface(
20+
fn=chat_with_ai,
21+
inputs=[gr.Textbox(label="Your Prompt"), gr.Radio(["OpenAI", "Hugging Face", "Anthropic"], label="AI Provider")],
22+
outputs=gr.Chatbot(label="Chat History"),
23+
live=True
24+
)
25+
26+
iface.launch()

0 commit comments

Comments
 (0)