File size: 1,230 Bytes
c6694ef
 
 
 
7f27daa
 
 
 
 
 
 
 
 
 
 
 
 
 
c6694ef
 
 
 
 
 
 
 
 
 
 
 
c1a6070
7f27daa
c6694ef
7f27daa
c6694ef
7f27daa
 
 
c6694ef
7f27daa
c6694ef
 
 
 
 
 
 
 
7f27daa
 
c6694ef
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
import g4f
import gradio as gr 
import nest_asyncio
nest_asyncio.apply()
import psycopg2

# Connexion à la base de données PostgreSQL
conn = psycopg2.connect(
    dbname="verceldb",
    user="default",
    password="u0Er5IOhTwdU",
    host="ep-steep-wildflower-71166293.us-east-1.postgres.vercel-storage.com",
    port="5432"
)

# Création d'un curseur pour exécuter des requêtes SQL
cursor = conn.cursor()


import g4f

g4f.debug.logging = True  # Enable logging
g4f.check_version = False  # Disable automatic version checking
print(g4f.version)  # Check version
print(g4f.Provider.Ails.params)  # Supported args




def rr(i):

    response  = g4f.ChatCompletion.create(
    model=g4f.models.gpt_35_turbo,
    messages=[{"role": "user", "content": i}],
)  # Alternative model setting
    insert_query = "INSERT INTO votre_table (question, reponse) VALUES (%s, %s);"
    cursor.execute(insert_query, (i, response))
    conn.commit()

    
    return response 

iface = gr.Interface(
    fn=rr,
    inputs=gr.Textbox(label="Question:", lines=4),
    outputs=gr.Textbox(label="Réponse"),
    title="bot",
    description="By Isa Ibn Maryam.  😂😂 Vas dormir ! Espace fermé ! ")
cursor.close()
conn.close()
iface.launch()