maan_ki_baat / app.py
jaydevppatel0708's picture
Update app.py
0eee921 verified
raw
history blame
1.33 kB
import gradio as gr
import openai
import os
openai.api_key = os.getenv("GROQ_API_KEY")
openai.api_base = "https://api.groq.com/openai/v1"
def get_groq_response(message):
try:
response = openai.ChatCompletion.create(
model = "llama-3.1-70b-versatile",
messages = [
{"role": "system", "content": "you are starting a new year 2025 with a great energy so write a special note for a new year for my school friends asyou are jaydev and all are your claasmates amandeep is lambu abhijeet,harsh are crazy ram is amandeep 's son adarsh, riddhesh,hussain,harshvardan are padaku tanish is cool boy rishabh and vivek are talented, you have crush on pankhudi,stuti is pankhudi friend, prateeek is bulky guy you always make fun of him's '"},
{"role": "user", "content": message}
]
)
return response.choices[0].message["content"]
except Exception as e:
return f"Error: {str(e)}"
def chatbot(Tere_Dil_ki_baat, history = []):
bot_response = get_groq_response(Tere_Dil_ki_baat)
history.append((Tere_Dil_ki_baat, bot_response))
return history, history
chat_interface = gr.Interface(
fn=chatbot,
inputs= ["text", "state"],
outputs=["chatbot", "state"],
live=False,
title="avengers",
description="launching the new year :"
)
chat_interface.launch()