ChatBot / app.py
C2MV's picture
Update app.py
7e8e126 verified
raw
history blame
1.45 kB
# Setup and load your keys
import os
from g4f import ChatCompletion
from google.colab import userdata
from pinecone import Pinecone
import pandas as pd
from datasets import Dataset
from sentence_transformers import SentenceTransformer
import gradio as gr
model_name = "BAAI/bge-m3"
# APIs personales
#PINECONE_ENVIRONMENT = us-east-1
#PINECONE_API_KEY = 3a3e9022-381d-436e-84cb-ba93464d283e
os.environ["PINECONE_ENVIRONMENT"] = "us-east-1"
os.environ["PINECONE_API_KEY"] = "3a3e9022-381d-436e-84cb-ba93464d283e"
# Retrieve the Pinecone API key from the user
PINECONE_API_KEY = userdata.get("PINECONE_API_KEY") # Use the key you set in the secrets
PINECONE_ENVIRONMENT = "us-east-1" # Use the environment you set in the secrets
# Initialize Pinecone with the API key
pc = Pinecone(api_key=PINECONE_API_KEY)
# Ruta del archivo CSV
file_path = '/content/dataset.csv'
# Cargar el dataset y establecerlo como variable global
try:
df = pd.read_csv(file_path)
DATASET = Dataset.from_pandas(df)
print(f"Dataset '{file_path}' loaded successfully.\n")
print(DATASET)
except Exception as e:
DATASET = None
print(f"Error loading dataset: {e}")
# Funci贸n para imprimir la informaci贸n del dataset actual
def print_dataset_info():
print(f"Current dataset: {DATASET}" if DATASET else "No dataset loaded.")
# Guardar la variable global para uso en otras celdas
get_ipython().run_cell_magic('capture', '', '%store DATASET')