Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,41 +8,16 @@ client = Groq(api_key=GROQ_API_KEY)
|
|
| 8 |
|
| 9 |
TITLE = "<h1><center>CodeAssist AI</center></h1>"
|
| 10 |
PLACEHOLDER = """<center><p>Hi, I'm your coding assistant. Ask me anything about programming!</p></center>"""
|
| 11 |
-
CSS = """
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
background: black !important;
|
| 16 |
-
border-radius: 100vh !important;
|
| 17 |
-
}
|
| 18 |
-
h3 {
|
| 19 |
-
text-align: center;
|
| 20 |
-
}
|
| 21 |
-
footer {
|
| 22 |
-
text-align: center;
|
| 23 |
-
padding: 10px;
|
| 24 |
-
position: fixed;
|
| 25 |
-
left: 0;
|
| 26 |
-
bottom: 20px;
|
| 27 |
-
width: 100%;
|
| 28 |
-
background-color: rgba(240, 240, 240, 0.8);
|
| 29 |
-
z-index: 1000;
|
| 30 |
-
}
|
| 31 |
-
"""
|
| 32 |
-
|
| 33 |
-
FOOTER_TEXT = """
|
| 34 |
-
<footer>
|
| 35 |
-
<p>If you enjoyed the functionality of the app, please leave a like!<br>
|
| 36 |
-
Check out more on <a href="https://www.linkedin.com/in/girish-wangikar/" target="_blank">LinkedIn</a> |
|
| 37 |
-
<a href="https://girishwangikar.github.io/Girish_Wangikar_Portfolio.github.io/" target="_blank">Portfolio</a></p>
|
| 38 |
-
</footer>
|
| 39 |
-
"""
|
| 40 |
|
| 41 |
def generate_response(
|
| 42 |
-
message: str,
|
| 43 |
-
history: list,
|
| 44 |
-
system_prompt: str,
|
| 45 |
-
temperature: float = 0.5,
|
| 46 |
max_tokens: int = 512
|
| 47 |
):
|
| 48 |
conversation = [
|
|
@@ -76,30 +51,36 @@ chatbot = gr.Chatbot(height=600, placeholder=PLACEHOLDER)
|
|
| 76 |
|
| 77 |
with gr.Blocks(css=CSS, theme="GSW") as demo:
|
| 78 |
gr.HTML(TITLE)
|
|
|
|
| 79 |
chat_interface = gr.ChatInterface(
|
| 80 |
fn=generate_response,
|
| 81 |
chatbot=chatbot,
|
| 82 |
fill_height=True,
|
| 83 |
-
additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False),
|
| 84 |
additional_inputs=[
|
| 85 |
-
gr.
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
],
|
| 104 |
examples=[
|
| 105 |
["What are Python generators, and how do I use them effectively in my code?"],
|
|
@@ -109,10 +90,10 @@ with gr.Blocks(css=CSS, theme="GSW") as demo:
|
|
| 109 |
],
|
| 110 |
cache_examples=False,
|
| 111 |
)
|
| 112 |
-
|
| 113 |
clear_btn = gr.Button("Clear Conversation")
|
| 114 |
clear_btn.click(clear_conversation, outputs=[chatbot, chatbot])
|
| 115 |
-
|
| 116 |
gr.HTML(FOOTER_TEXT)
|
| 117 |
|
| 118 |
if __name__ == "__main__":
|
|
|
|
| 8 |
|
| 9 |
TITLE = "<h1><center>CodeAssist AI</center></h1>"
|
| 10 |
PLACEHOLDER = """<center><p>Hi, I'm your coding assistant. Ask me anything about programming!</p></center>"""
|
| 11 |
+
CSS = """.duplicate-button { margin: auto !important; color: white !important; background: black !important; border-radius: 100vh !important;}
|
| 12 |
+
h3 { text-align: center;}
|
| 13 |
+
footer { text-align: center; padding: 10px; position: fixed; left: 0; bottom: 20px; width: 100%; background-color: rgba(240, 240, 240, 0.8); z-index: 1000;}"""
|
| 14 |
+
FOOTER_TEXT = """<footer> <p>If you enjoyed the functionality of the app, please leave a like!<br> Check out more on <a href="https://www.linkedin.com/in/girish-wangikar/" target="_blank">LinkedIn</a> | <a href="https://girishwangikar.github.io/Girish_Wangikar_Portfolio.github.io/" target="_blank">Portfolio</a></p></footer>"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
def generate_response(
|
| 17 |
+
message: str,
|
| 18 |
+
history: list,
|
| 19 |
+
system_prompt: str,
|
| 20 |
+
temperature: float = 0.5,
|
| 21 |
max_tokens: int = 512
|
| 22 |
):
|
| 23 |
conversation = [
|
|
|
|
| 51 |
|
| 52 |
with gr.Blocks(css=CSS, theme="GSW") as demo:
|
| 53 |
gr.HTML(TITLE)
|
| 54 |
+
|
| 55 |
chat_interface = gr.ChatInterface(
|
| 56 |
fn=generate_response,
|
| 57 |
chatbot=chatbot,
|
| 58 |
fill_height=True,
|
|
|
|
| 59 |
additional_inputs=[
|
| 60 |
+
gr.Accordion(
|
| 61 |
+
label="⚙️ Parameters",
|
| 62 |
+
open=False,
|
| 63 |
+
children=[
|
| 64 |
+
gr.Textbox(
|
| 65 |
+
value="You are a helpful coding assistant, specialized in code completion, debugging, and analysis. Provide concise and accurate responses.",
|
| 66 |
+
label="System Prompt",
|
| 67 |
+
),
|
| 68 |
+
gr.Slider(
|
| 69 |
+
minimum=0,
|
| 70 |
+
maximum=1,
|
| 71 |
+
step=0.1,
|
| 72 |
+
value=0.5,
|
| 73 |
+
label="Temperature",
|
| 74 |
+
),
|
| 75 |
+
gr.Slider(
|
| 76 |
+
minimum=50,
|
| 77 |
+
maximum=1024,
|
| 78 |
+
step=1,
|
| 79 |
+
value=512,
|
| 80 |
+
label="Max tokens",
|
| 81 |
+
),
|
| 82 |
+
]
|
| 83 |
+
)
|
| 84 |
],
|
| 85 |
examples=[
|
| 86 |
["What are Python generators, and how do I use them effectively in my code?"],
|
|
|
|
| 90 |
],
|
| 91 |
cache_examples=False,
|
| 92 |
)
|
| 93 |
+
|
| 94 |
clear_btn = gr.Button("Clear Conversation")
|
| 95 |
clear_btn.click(clear_conversation, outputs=[chatbot, chatbot])
|
| 96 |
+
|
| 97 |
gr.HTML(FOOTER_TEXT)
|
| 98 |
|
| 99 |
if __name__ == "__main__":
|