Omar ID EL MOUMEN commited on
Commit
bdd682d
·
1 Parent(s): 67e4ad5

Add tool for RAG questions

Browse files
Files changed (1) hide show
  1. server.py +27 -0
server.py CHANGED
@@ -126,5 +126,32 @@ def search_3gpp_specifications(keywords: str, threshold: int, release: Optional[
126
 
127
  return "\n--\n".join([f"3GPP {spec['type']} {spec['id']} version {spec['version']} - {spec['title']} is downloadable via this link: {spec['url']}\n{spec['scope']}" for spec in responseJson['results']])
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  if __name__ == "__main__":
130
  mcp.run(transport="stdio")
 
126
 
127
  return "\n--\n".join([f"3GPP {spec['type']} {spec['id']} version {spec['version']} - {spec['title']} is downloadable via this link: {spec['url']}\n{spec['scope']}" for spec in responseJson['results']])
128
 
129
+ @mcp.tool()
130
+ def ask_questions_to_3gpp_database(question: str, threshold: int = 65, release: Optional[str] = "", working_group: Optional[str] = "", spec_type: Optional[str] = "") -> str:
131
+ """
132
+ Retrieve technical documents sections to help AI answer the user's technical question, if same topic already called, re-use the downloaded documents
133
+ 3GPP specifications are used as source documents, using BM25 to filter the documents
134
+ Args: question: string, threshold: integer 0-100 [default 60], release: optional filter, string [only the number Rel-19 -> '19'], working_group: optional filter, string [options: C1,C2,...,C6,CP or S1,S2,...,S6,SP], spec_type: optional filter, string [either TS (Technical Specification) or TR (Technical Report)]
135
+ For each non-used optional filters, leave a empty string
136
+ After extracting the documents, answer to the question with a complete and detailed paragraph with the sources cited
137
+ """
138
+ body = {"question": question, "threshold": threshold}
139
+ if release:
140
+ body['release'] = release
141
+ if working_group:
142
+ body['working_group'] = working_group
143
+ if spec_type:
144
+ body['spec_type'] = spec_type
145
+
146
+ response = requests.post("https://organizedprogrammers-3gppdocfinder.hf.space/list-rag-docs", headers={
147
+ "Content-Type": "application/json"
148
+ }, data=json.dumps(body), verify=False)
149
+
150
+ if response.status_code != 200:
151
+ return f"Unable to extract documents: {response.status_code}"
152
+
153
+ docs = response.json()['output']
154
+ return docs
155
+
156
  if __name__ == "__main__":
157
  mcp.run(transport="stdio")