Spaces:
Runtime error
Runtime error
ishaan-mital
commited on
Commit
·
714ea85
1
Parent(s):
d99b731
lets see
Browse files
app.py
CHANGED
@@ -2,15 +2,15 @@ import gradio as gr
|
|
2 |
import os
|
3 |
import pinecone
|
4 |
import time
|
5 |
-
# from torch import cuda
|
6 |
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
7 |
-
|
8 |
-
|
9 |
from langchain.vectorstores import Pinecone
|
10 |
from langchain import HuggingFaceHub, LLMChain
|
11 |
from langchain.prompts import PromptTemplate
|
12 |
from langchain.chains import RetrievalQA
|
13 |
|
|
|
14 |
embed_model_id = 'sentence-transformers/all-MiniLM-L6-v2'
|
15 |
# device = f'cuda:{cuda.current_device()}' if cuda.is_available() else 'cpu'
|
16 |
|
@@ -48,8 +48,6 @@ index = pinecone.Index(index_name)
|
|
48 |
index.describe_index_stats()
|
49 |
|
50 |
|
51 |
-
|
52 |
-
|
53 |
text_field = 'text' # field in metadata that contains text content
|
54 |
|
55 |
vectorstore = Pinecone(
|
@@ -57,7 +55,7 @@ vectorstore = Pinecone(
|
|
57 |
)
|
58 |
|
59 |
|
60 |
-
hub = HuggingFaceHub(repo_id = "HuggingFaceH4/zephyr-7b-beta",huggingfacehub_api_token=
|
61 |
print(hub)
|
62 |
prompt = PromptTemplate(
|
63 |
input_variables=["question"],
|
@@ -70,7 +68,9 @@ rag_pipeline = RetrievalQA.from_chain_type(
|
|
70 |
)
|
71 |
|
72 |
def question(question):
|
|
|
73 |
answer = rag_pipeline(question)
|
|
|
74 |
return answer
|
75 |
|
76 |
demo = gr.Interface(fn=question, inputs="text", outputs="text")
|
|
|
2 |
import os
|
3 |
import pinecone
|
4 |
import time
|
|
|
5 |
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
6 |
+
import torch
|
7 |
+
import sentence_transformers
|
8 |
from langchain.vectorstores import Pinecone
|
9 |
from langchain import HuggingFaceHub, LLMChain
|
10 |
from langchain.prompts import PromptTemplate
|
11 |
from langchain.chains import RetrievalQA
|
12 |
|
13 |
+
headers = {"Authorization": f"Bearer {os.environ.get('API_KEY')}"}
|
14 |
embed_model_id = 'sentence-transformers/all-MiniLM-L6-v2'
|
15 |
# device = f'cuda:{cuda.current_device()}' if cuda.is_available() else 'cpu'
|
16 |
|
|
|
48 |
index.describe_index_stats()
|
49 |
|
50 |
|
|
|
|
|
51 |
text_field = 'text' # field in metadata that contains text content
|
52 |
|
53 |
vectorstore = Pinecone(
|
|
|
55 |
)
|
56 |
|
57 |
|
58 |
+
hub = HuggingFaceHub(repo_id = "HuggingFaceH4/zephyr-7b-beta",huggingfacehub_api_token={os.environ.get('API_KEY')})
|
59 |
print(hub)
|
60 |
prompt = PromptTemplate(
|
61 |
input_variables=["question"],
|
|
|
68 |
)
|
69 |
|
70 |
def question(question):
|
71 |
+
global chatbot
|
72 |
answer = rag_pipeline(question)
|
73 |
+
chatbot = answer
|
74 |
return answer
|
75 |
|
76 |
demo = gr.Interface(fn=question, inputs="text", outputs="text")
|