mlara commited on
Commit
c932f49
1 Parent(s): a10b5a2

third commit

Browse files
Files changed (1) hide show
  1. earnings_app.py +24 -25
earnings_app.py CHANGED
@@ -104,38 +104,37 @@ service_context = ServiceContext.from_defaults(
104
  index = GPTVectorStoreIndex.from_documents([], service_context=service_context)
105
 
106
 
107
- storage_context = wandb_callback.load_storage_context(
108
- artifact_url="llmop/final-project-v1/earnings-index:v3"
109
- )
110
 
111
- index = load_index_from_storage(storage_context, service_context=service_context)
 
 
112
 
113
- def auto_retrieve_fn(
114
- query: str, filter_key_list: List[str], filter_value_list: List[str]
115
- ):
116
- """Auto retrieval function.
117
 
118
- Performs auto-retrieval from a vector database, and then applies a set of filters.
 
 
 
119
 
120
- """
121
- query = query or "Query"
122
 
123
- exact_match_filters = [
124
- ExactMatchFilter(key=k, value=v)
125
- for k, v in zip(filter_key_list, filter_value_list)
126
- ]
127
- retriever = VectorIndexRetriever(
128
- index, filters=MetadataFilters(filters=exact_match_filters), top_k=top_k
129
- )
130
- query_engine = RetrieverQueryEngine.from_args(retriever, service_context=service_context)
131
-
132
- response = query_engine.query(query)
133
- return str(response)
134
 
 
 
 
 
 
 
 
 
135
 
136
- # Main function to extract information
137
- def extract_information():
138
- # Make sure to use a recent model that supports tools
139
 
140
  auto_retrieve_tool = FunctionTool.from_defaults(
141
  fn=auto_retrieve_fn,
 
104
  index = GPTVectorStoreIndex.from_documents([], service_context=service_context)
105
 
106
 
107
+ # Main function to extract information
108
+ def extract_information():
109
+ # Make sure to use a recent model that supports tools
110
 
111
+ storage_context = wandb_callback.load_storage_context(
112
+ artifact_url="llmop/final-project-v1/earnings-index:v3"
113
+ )
114
 
115
+ index = load_index_from_storage(storage_context, service_context=service_context)
 
 
 
116
 
117
+ def auto_retrieve_fn(
118
+ query: str, filter_key_list: List[str], filter_value_list: List[str]
119
+ ):
120
+ """Auto retrieval function.
121
 
122
+ Performs auto-retrieval from a vector database, and then applies a set of filters.
 
123
 
124
+ """
125
+ query = query or "Query"
 
 
 
 
 
 
 
 
 
126
 
127
+ exact_match_filters = [
128
+ ExactMatchFilter(key=k, value=v)
129
+ for k, v in zip(filter_key_list, filter_value_list)
130
+ ]
131
+ retriever = VectorIndexRetriever(
132
+ index, filters=MetadataFilters(filters=exact_match_filters), top_k=top_k
133
+ )
134
+ query_engine = RetrieverQueryEngine.from_args(retriever, service_context=service_context)
135
 
136
+ response = query_engine.query(query)
137
+ return str(response)
 
138
 
139
  auto_retrieve_tool = FunctionTool.from_defaults(
140
  fn=auto_retrieve_fn,