|
import g4f |
|
import gradio as gr |
|
import nest_asyncio |
|
nest_asyncio.apply() |
|
import psycopg2 |
|
|
|
|
|
conn = psycopg2.connect( |
|
dbname="verceldb", |
|
user="default", |
|
password="u0Er5IOhTwdU", |
|
host="ep-steep-wildflower-71166293.us-east-1.postgres.vercel-storage.com", |
|
port="5432" |
|
) |
|
|
|
|
|
cursor = conn.cursor() |
|
|
|
|
|
import g4f |
|
|
|
g4f.debug.logging = True |
|
g4f.check_version = False |
|
print(g4f.version) |
|
print(g4f.Provider.Ails.params) |
|
|
|
|
|
|
|
|
|
def rr(i): |
|
|
|
response = g4f.ChatCompletion.create( |
|
model=g4f.models.gpt_35_turbo, |
|
messages=[{"role": "user", "content": i}], |
|
) |
|
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() |