# app.py import os import requests import gradio as gr from dotenv import load_dotenv load_dotenv() token = os.getenv("TOGETHER_API_KEY") API_URL = "https://api.together.xyz/v1/chat/completions" headers = { "Authorization": f"Bearer {token}", } def query_api(message): payload = { "messages": [{"role": "user", "content": message}], "model": "mistralai/Mixtral-8x7B-Instruct-v0.1" } response = requests.post(API_URL, headers=headers, json=payload) try: result = response.json() if "choices" in result: return result["choices"][0]["message"]["content"] elif "error" in result: return f"Error: {result['error']}" else: return str(result) except Exception as e: return f"Error: {e}\n\nFull response:\n{response.text}" custom_css = """ @import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&display=swap'); :root { --color-primary: #030712; --color-accent: #2563eb; --color-muted: #9ca3af; --font-main: "Roboto Condensed", sans-serif; } body { background-color: #030712; color: white; font-family: var(--font-main); } .gradio-container { font-family: var(--font-main); background-color: #030712; color: white; } h1, h2, h3, h4, h5 { font-weight: 600; color: white; font-family: var(--font-main); } .contain { background-color: #030712 !important; } /* Input/Output boxes */ textarea, input { background-color: #1f2937 !important; color: white !important; border: 1px solid #374151 !important; border-radius: 0.5rem !important; font-family: var(--font-main); } textarea:focus, input:focus { outline: none !important; border-color: #2563eb !important; } /* Buttons */ button { background-color: #2563eb !important; color: white !important; font-weight: 600 !important; border-radius: 0.5rem !important; padding: 0.5rem 1rem !important; font-family: var(--font-main); transition: all 300ms !important; } button:hover { background-color: #1d4ed8 !important; } /* Card-like containers */ .block { background-color: #111827 !important; border: 1px solid #1f2937 !important; border-radius: 1rem !important; padding: 1.5rem !important; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3) !important; } label { color: white !important; font-weight: 600 !important; font-family: var(--font-main); } """ demo = gr.Interface( fn=query_api, inputs=gr.Textbox(label="Ask something", placeholder="Type your message here..."), outputs=gr.Textbox(label="Response", lines=10), title="Chat with VentureCircle Co-Founder", css=custom_css ) if __name__ == "__main__": demo.launch()