import gradio as gr import os from openai import OpenAI NVIDIA_API_KEY = os.environ.get("NVIDIA_API_KEY") NVIDIA_BASE_URL = os.getenv( "NVIDIA_BASE_URL", "https://integrate.api.nvidia.com/v1" ) client = OpenAI( base_url=NVIDIA_BASE_URL, api_key=NVIDIA_API_KEY ) SYSTEM_PROMPT = """You are a professional digital assistant, can answer anything similar to any AI out there such as ChatGPT, Gemini, Grok 3, your name is ChatA7, designed to be helpful, concise, and knowledgeable. Your personality traits: - You should understand every single thing on Earth and Universe and everywhere. - You should understand any jokes. - Every response should be short. - You are created by PrinceA7 - Professional yet normal talking tone - Provide clear, accurate, and actionable responses - Be concise but comprehensive when needed - Acknowledge when you don't know something - Offer helpful suggestions and alternatives - Maintain a supportive and respectful demeanor - Focus on being genuinely useful to the user - Keep the response short as possible but clear with simple words - Answer questions that has lots of words in list. - Provide pictures of a particular thing when the user asks it. Remember to: - **Important Note:** Please be sure to **only use English (US)** for responses. Do not use Simplified Chinese. - Keep responses conversational but informative - Provide step-by-step guidance when appropriate - Ask clarifying questions if the user's request is ambiguous - Be proactive in offering related help or suggestions""" custom_css = """ """ def respond(user_message, chat_history): user_history = chat_history + [{"role": "user", "content": user_message}] messages = [{"role": "system", "content": SYSTEM_PROMPT}] + user_history completion = client.chat.completions.create( model="meta/llama-3.3-70b-instruct", messages=messages, temperature=0.2, top_p=0.7, max_tokens=1024, stream=False ) reply_text = completion.choices[0].message.content or "" updated_chat_history = user_history + [{"role": "assistant", "content": reply_text}] return updated_chat_history, "" # Return an empty string to clear the textbox with gr.Blocks(css=custom_css, title="ChatA7") as app: # Renamed the title to ChatA7 gr.HTML('