File size: 1,447 Bytes
9be1c64
 
 
 
 
 
 
 
521ae0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e8e126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# 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')