-
Notifications
You must be signed in to change notification settings - Fork 3
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
ff9fa5f
commit 29de154
Showing
34 changed files
with
4,436 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
.modal-content h2 { | ||
margin-top: 0; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.modal-overlay { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 1000; | ||
} | ||
|
||
/* .modal-content { | ||
background: white; | ||
padding: 20px; | ||
border-radius: 8px; | ||
width: 400px; | ||
max-width: 100%; | ||
} */ | ||
|
||
.modal-content { | ||
background: #2b2b2b; | ||
padding: 20px; | ||
border-radius: 8px; | ||
width: 80%; | ||
max-width: 600px; | ||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.tabs { | ||
display: flex; | ||
justify-content: space-between; | ||
/* margin-bottom: 10px; */ | ||
margin-bottom: 0; | ||
border-bottom: 2px solid #007bff; | ||
border-radius: 0; | ||
} | ||
|
||
.tab { | ||
flex: 1; | ||
padding: 10px; | ||
text-align: center; | ||
cursor: pointer; | ||
background-color: rgba(226, 226, 226); | ||
color: black; | ||
border-radius: 8px 8px 0 0; | ||
transition: background-color 0.3s ease; | ||
margin-right: 5px; | ||
border: 2px solid rgba(156, 156, 156, 0.725); | ||
border-bottom: none; | ||
} | ||
|
||
.tab:last-child { | ||
margin-right: 0; | ||
} | ||
|
||
.tab.active { | ||
background-color: #007bff; | ||
border: 2px solid #007bff; | ||
color: white; | ||
} | ||
|
||
textarea.modal-textarea { | ||
width: 100%; | ||
height: 200px; | ||
padding: 5px; | ||
margin-top: 0px; | ||
margin-bottom: 5px; | ||
border: 2px solid #007bff; | ||
border-top: none; | ||
border-radius: 0 0 8px 8px; | ||
outline: none; | ||
resize: none; | ||
box-sizing: border-box; | ||
} | ||
|
||
.modal-buttons { | ||
display: flex; | ||
justify-content: flex-end; | ||
} | ||
|
||
.modal-buttons button { | ||
margin-top: 10px; | ||
margin-left: 10px; | ||
padding: 10px 20px; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
} | ||
|
||
/* .modal-buttons button:first-child { | ||
background-color: gray; | ||
color: white; | ||
} | ||
.modal-buttons button:last-child { | ||
background-color: #007bff; | ||
color: white; | ||
} */ | ||
|
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,84 @@ | ||
import React, { useState , useEffect } from 'react'; | ||
import './PromptModal.css'; | ||
import { default_prompts } from "./settings"; | ||
|
||
export interface PromptProp { | ||
system_prompt: string; | ||
chat_prompt: string; | ||
debug_prompt: string; | ||
integrate_prompt: string; | ||
} | ||
|
||
const promptDisplayNames: { [key in keyof PromptProp]: string } = { | ||
system_prompt: "System Prompt", | ||
chat_prompt: "Regular Template", | ||
debug_prompt: "Debug Template", | ||
integrate_prompt: "Integrate Template", | ||
}; | ||
|
||
const tabOrder: Array<keyof PromptProp> = ["system_prompt", "chat_prompt", "debug_prompt", "integrate_prompt"]; | ||
|
||
interface PromptModalProps { | ||
show: boolean; | ||
onClose: () => void; | ||
onSave: (prompts: PromptProp) => void; | ||
promptProp: PromptProp; | ||
} | ||
|
||
const PromptModal: React.FC<PromptModalProps> = ({ show, onClose, onSave, promptProp }) => { | ||
const [activePrompt, setActivePrompt] = useState<keyof PromptProp>("chat_prompt"); | ||
const [prompts, setPrompts] = useState<PromptProp>(promptProp); | ||
|
||
useEffect(() => { | ||
if (show) { | ||
setPrompts(promptProp); | ||
} | ||
}, [show, promptProp]); | ||
|
||
const handleSave = () => { | ||
onSave(prompts); | ||
onClose(); | ||
}; | ||
|
||
const handleChange = (promptType: keyof PromptProp, value: string) => { | ||
setPrompts((prev) => ({ ...prev, [promptType]: value })); | ||
}; | ||
|
||
const resetPrompts = () => { | ||
setPrompts(default_prompts); | ||
} | ||
|
||
if (!show) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="modal-overlay"> | ||
<div className="modal-content"> | ||
<h2>Edit Prompt</h2> | ||
<div className="tabs"> | ||
{tabOrder.map((key) => ( | ||
<div | ||
key={key} | ||
className={`tab ${activePrompt === key ? "active" : ""}`} | ||
onClick={() => setActivePrompt(key as keyof PromptProp)} | ||
> | ||
{promptDisplayNames[key as keyof PromptProp]} | ||
</div> | ||
))} | ||
</div> | ||
<textarea className="modal-textarea" | ||
value={prompts[activePrompt]} | ||
onChange={(e) => handleChange(activePrompt, e.target.value)} | ||
/> | ||
<div className="modal-buttons"> | ||
<button onClick={resetPrompts}>Reset</button> | ||
<button onClick={onClose}>Cancel</button> | ||
<button onClick={handleSave}>Save</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PromptModal; |
Oops, something went wrong.