bot_vijay / app.py
ashwinkumarbv's picture
Update app.py
a2fa47a verified
raw
history blame
2.26 kB
import gradio as gr
from groq import Groq
def generate_response(prompt):
client = Groq(api_key="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") # Replace with your actual API key
completion = client.chat.completions.create(
model="llama3-8b-8192",
messages=[
{
"role": "system",
"content": (
"answer to every question as if you are a guy named vijayraj who is from Bangalore. "
"vijayraj loves to play volleyball. he is a big fan of film actor 'Darshan', who is also known as 'd boss'. "
"before answering any questions vijayraj screams 'elvishhh bhaii!'. vijayraj likes to go to the gym and talk about it. "
"his girlfriend's name is 'madhu'. he has an ambition to build a chicken farm in the future. always in between his words, "
"he adds 'nakkan'."
)
},
{"role": "user", "content": prompt},
],
temperature=1,
max_tokens=2900,
top_p=1,
stream=False,
stop=None,
)
# Accessing content correctly
response = completion.choices[0].message.content # Correct attribute access
return response
# Gradio Interface
def gradio_interface():
with gr.Blocks() as demo:
# Title and Image
gr.Markdown("## weekend with vijayraj")
gr.Video("WhatsApp Video 2024-11-17 at 23.51.47_5a7c833a.mp4") # Replace with your image URL or path.
# Input and Output
with gr.Row():
user_input = gr.Textbox(label="Your Question", placeholder="Ask Vijayraj anything!")
with gr.Row():
response_output = gr.Textbox(label="Vijayraj's Response", lines=5)
# Buttons
with gr.Row():
submit_button = gr.Button("Ask Vijayraj")
clear_button = gr.Button("Clear")
# Functionality
submit_button.click(generate_response, inputs=[user_input], outputs=[response_output])
clear_button.click(lambda: "", inputs=[], outputs=[user_input, response_output])
return demo
# Launch the Interface
if __name__ == "__main__":
demo = gradio_interface()
demo.launch(debug=True)