File size: 3,101 Bytes
3770d0d
2ef2764
3770d0d
 
76e6aeb
2ef2764
76e6aeb
 
 
 
3770d0d
76e6aeb
3770d0d
 
 
 
 
76e6aeb
3770d0d
 
 
76e6aeb
 
 
 
 
 
 
3770d0d
 
 
b0c0d18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3770d0d
 
b0c0d18
 
318d2d5
b0c0d18
7577e5a
 
20cd3e6
3770d0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# 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()