Spaces:
Sleeping
Sleeping
Kieran Gookey
commited on
Commit
·
2145acc
1
Parent(s):
6ad144b
Added string
Browse files- app.py +11 -1
- requirements.txt +2 -1
app.py
CHANGED
|
@@ -7,6 +7,8 @@ from llama_index import ServiceContext, VectorStoreIndex
|
|
| 7 |
from llama_index.schema import Document
|
| 8 |
import uuid
|
| 9 |
from llama_index.vector_stores.types import MetadataFilters, ExactMatchFilter
|
|
|
|
|
|
|
| 10 |
|
| 11 |
inference_api_key = st.secrets["INFRERENCE_API_TOKEN"]
|
| 12 |
|
|
@@ -16,6 +18,12 @@ inference_api_key = st.secrets["INFRERENCE_API_TOKEN"]
|
|
| 16 |
# llm_model_name = st.text_input(
|
| 17 |
# 'Embed Model name', "mistralai/Mistral-7B-Instruct-v0.2")
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
embed_model_name = "jinaai/jina-embedding-s-en-v1"
|
| 20 |
llm_model_name = "mistralai/Mistral-7B-Instruct-v0.2"
|
| 21 |
|
|
@@ -57,12 +65,14 @@ if html_file is not None:
|
|
| 57 |
documents, show_progress=True, metadata={"source": "HTML"}, service_context=service_context)
|
| 58 |
|
| 59 |
query_engine = index.as_query_engine(
|
| 60 |
-
filters=filters, service_context=service_context)
|
| 61 |
|
| 62 |
response = query_engine.query(query)
|
| 63 |
|
| 64 |
st.write(response.response)
|
| 65 |
|
|
|
|
|
|
|
| 66 |
# if st.button('Start Pipeline'):
|
| 67 |
# if html_file is not None and embed_model_name is not None and llm_model_name is not None and query is not None:
|
| 68 |
# st.write('Running Pipeline')
|
|
|
|
| 7 |
from llama_index.schema import Document
|
| 8 |
import uuid
|
| 9 |
from llama_index.vector_stores.types import MetadataFilters, ExactMatchFilter
|
| 10 |
+
from typing import List
|
| 11 |
+
from pydantic import BaseModel
|
| 12 |
|
| 13 |
inference_api_key = st.secrets["INFRERENCE_API_TOKEN"]
|
| 14 |
|
|
|
|
| 18 |
# llm_model_name = st.text_input(
|
| 19 |
# 'Embed Model name', "mistralai/Mistral-7B-Instruct-v0.2")
|
| 20 |
|
| 21 |
+
|
| 22 |
+
class PriceModel(BaseModel):
|
| 23 |
+
"""Data model for price"""
|
| 24 |
+
price: str
|
| 25 |
+
|
| 26 |
+
|
| 27 |
embed_model_name = "jinaai/jina-embedding-s-en-v1"
|
| 28 |
llm_model_name = "mistralai/Mistral-7B-Instruct-v0.2"
|
| 29 |
|
|
|
|
| 65 |
documents, show_progress=True, metadata={"source": "HTML"}, service_context=service_context)
|
| 66 |
|
| 67 |
query_engine = index.as_query_engine(
|
| 68 |
+
filters=filters, service_context=service_context, response_mode="tree_summarize", output_cls=PriceModel)
|
| 69 |
|
| 70 |
response = query_engine.query(query)
|
| 71 |
|
| 72 |
st.write(response.response)
|
| 73 |
|
| 74 |
+
st.write(f'Price: {response.price}')
|
| 75 |
+
|
| 76 |
# if st.button('Start Pipeline'):
|
| 77 |
# if html_file is not None and embed_model_name is not None and llm_model_name is not None and query is not None:
|
| 78 |
# st.write('Running Pipeline')
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
streamlit
|
| 2 |
llama_index
|
| 3 |
-
uuid
|
|
|
|
|
|
| 1 |
streamlit
|
| 2 |
llama_index
|
| 3 |
+
uuid
|
| 4 |
+
pydantic
|