Spaces:
Runtime error
Runtime error
qa attempt
Browse files
app.py
CHANGED
@@ -40,50 +40,20 @@ metadata_field_info=[
|
|
40 |
),
|
41 |
]
|
42 |
|
43 |
-
|
44 |
-
# metadata_field_info=[
|
45 |
-
# AttributeInfo(
|
46 |
-
# name="author",
|
47 |
-
# description="The author of the excerpt",
|
48 |
-
# type="string or list[string]",
|
49 |
-
# ),
|
50 |
-
# AttributeInfo(
|
51 |
-
# name="chapter_number",
|
52 |
-
# description="The chapter number of excerpt",
|
53 |
-
# type="integer",
|
54 |
-
# ),
|
55 |
-
# AttributeInfo(
|
56 |
-
# name="chapter_name",
|
57 |
-
# description="The chapter name of the excerpt",
|
58 |
-
# type="string",
|
59 |
-
# ),
|
60 |
-
# ]
|
61 |
-
|
62 |
-
# document_content_description = "Excerpt's from Reid Hoffman's book Impromptu"
|
63 |
-
# embeddings = OpenAIEmbeddings()
|
64 |
-
|
65 |
-
# index_name = str(os.environ['PINECONE_INDEX_NAME'])
|
66 |
-
|
67 |
def load_chain():
|
68 |
-
# vectorstore = Pinecone.from_existing_index(index_name, embeddings)
|
69 |
-
# llm = OpenAI(temperature=0)
|
70 |
retriever = SelfQueryRetriever.from_llm(
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
-
# docsearch = Pinecone.from_existing_index(index_name, embeddings)
|
79 |
-
# return docsearch
|
80 |
-
|
81 |
-
# def load_chain():
|
82 |
-
# """Logic for loading the chain you want to use should go here."""
|
83 |
-
# llm = OpenAI(temperature=0)
|
84 |
-
# chain = ConversationChain(llm=llm)
|
85 |
-
# return chain
|
86 |
-
|
87 |
chain = load_chain()
|
88 |
|
89 |
# From here down is all the StreamLit UI.
|
|
|
40 |
),
|
41 |
]
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
def load_chain():
|
|
|
|
|
44 |
retriever = SelfQueryRetriever.from_llm(
|
45 |
+
llm,
|
46 |
+
vectorstore,
|
47 |
+
document_content_description,
|
48 |
+
metadata_field_info,
|
49 |
+
verbose=True)
|
50 |
+
qa = RetrievalQA.from_chain_type(
|
51 |
+
llm=OpenAI(),
|
52 |
+
chain_type="stuff",
|
53 |
+
retriever=retriever,
|
54 |
+
return_source_documents=False)
|
55 |
+
return qa
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
chain = load_chain()
|
58 |
|
59 |
# From here down is all the StreamLit UI.
|