File size: 1,907 Bytes
27cf7e7
 
f37c506
0ca3532
4df8137
a4fbb88
f37c506
a4fbb88
f37c506
a4fbb88
f37c506
 
 
4df8137
a4fbb88
f37c506
eee27a3
a4fbb88
 
 
 
0ca3532
a4fbb88
 
 
0ca3532
a4fbb88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4df8137
a4fbb88
 
 
 
 
 
 
 
 
27cf7e7
 
f37c506
a4fbb88
f37c506
 
 
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
<!DOCTYPE html>
<html>
<head>
    <title>AdamAi Beta 1</title>
    <!-- Chargement de l'environnement Gradio-lite pour navigateur -->
    <script type="module" src="https://jsdelivr.net"></script>
    <link rel="stylesheet" href="https://jsdelivr.net" />
    <style>
        body { margin: 0; background-color: #f9fafb; font-family: sans-serif; }
    </style>
</head>
<body>

    <!-- Composant Gradio App -->
    <gradio-app>
    <main-python>
import gradio as gr
import urllib.request
import json

def ask_adam_ai(question):
    # ADRESSE API CORRECTE ET FIXE :
    url = "https://together.xyz"
    
    headers = {
        "Authorization": "Bearer 815c3ec04bb4db4d3fa7ffc64966d58d9ad7662c59efd5dfdf935ec213c9e97c",
        "Content-Type": "application/json"
    }
    
    data = {
        "model": "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
        "messages": [{"role": "user", "content": question}],
        "temperature": 0.6
    }
    
    req = urllib.request.Request(url, data=json.dumps(data).encode('utf-8'), headers=headers)
    
    try:
        with urllib.request.urlopen(req) as response:
            res = json.loads(response.read().decode('utf-8'))
            return res['choices']['message']['content']
    except Exception as e:
        return f"Error connecting to AdamAi engine: {str(e)}"

# Interface graphique générée par le navigateur
with gr.Blocks(theme=gr.themes.Soft()) as demo:
    gr.Markdown("# 🤖 AdamAi Beta 1")
    gr.Markdown("Running completely serverless in your browser via Gradio-lite!")
    
    user_input = gr.Textbox(label="Write your question:", placeholder="Ask AdamAi anything...")
    output_text = gr.Textbox(label="AdamAi Answer:", lines=6)
    
    submit_btn = gr.Button("Ask AI", variant="primary")
    submit_btn.click(fn=ask_adam_ai, inputs=user_input, outputs=output_text)

demo.launch()
    </main-python>
    </gradio-app>

</body>
</html>