semanticsearch / app.py
Maitreyee22's picture
Update app.py
fabae77 verified
raw
history blame
937 Bytes
from datasets import load_dataset
from sentence_transformers import SentenceTransformer
import os
from openai import OpenAI # or your preferred client
from pinecone import Pinecone, ServerlessSpec
import gradio as gr
#Setup API Keys
api_key = os.getenv("OPENAI_API_KEY")
client = OpenAI(api_key=api_key) # or openai.api_key = api_key
papi_key = os.getenv("PINECONE_API_KEY")
environment = os.getenv("PINECONE_ENVIRONMENT")
pc = Pinecone(api_key=papi_key)
# # Now do stuff
# if 'my_index' not in pc.list_indexes().names():
# pc.create_index(
# name='my_index',
# dimension=1536,
# metric='euclidean',
# spec=ServerlessSpec(
# cloud='gcp',
# region='us-west4-gcp'
# )
# )
# Define a simple function
def greet(name):
return f"Hello, {name}!"
# Create the interface
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
# Launch the app
demo.launch()