Omar ID EL MOUMEN commited on
Commit
a01e43c
·
1 Parent(s): 11fd3b1
Files changed (1) hide show
  1. server.py +20 -9
server.py CHANGED
@@ -102,13 +102,19 @@ async def search_specs(keywords: str, limit: int, release: str = None, wg: str =
102
  Arguments available: keywords: string [mandatory, separated by space], limit [mandatory, default = 5], release: string [optional, filter] (the release version (e.g. 18, 9, 19, ...), generally the first number of the full version), wg: string [optional, filter] = working group (S1, C4, SP, ...), spec_type: string [optional, filter] (either TS or TR), mode [mandatory, default = 'and'] = search mode (and = all keywords must be in the search, or = at least one keyword in the search)
103
  """
104
  endpoint = DOC3GPPFINDER_BASE + "/search-spec"
105
- data = await post_data_to_api(endpoint, {
106
  "keywords": keywords,
107
- "release": release,
108
- "wg": wg,
109
- "spec_type": spec_type,
110
  "mode": mode
111
- })
 
 
 
 
 
 
 
 
 
112
  if isinstance(data, tuple) and data[0] is None:
113
  return f"An error has occured while searching specifications"
114
  results = data['results'][:min(len(data['results'])-1, limit)]
@@ -129,7 +135,12 @@ async def get_multiple_documents_url(doc_ids: List[str], release: int = None):
129
  Arguments available: doc_ids: list of string [mandatory], release: integer [optional for every case]
130
  """
131
  endpoint = DOC3GPPFINDER_BASE + "/batch"
132
- data = await post_data_to_api(endpoint, doc_ids=doc_ids, release=release)
 
 
 
 
 
133
  if isinstance(data, tuple) and data[0] is None:
134
  return f"An error while searching publications: {data[1]}"
135
  results = data["results"]
@@ -141,13 +152,13 @@ async def get_multiple_documents_url(doc_ids: List[str], release: int = None):
141
  # PTT Endpoints
142
 
143
  @mcp.tool()
144
- async def search_documents_web(query: str, data_type: str = None, limit: int = 5):
145
  """
146
  Search on the Web (thanks to DuckDuckGo) documents based on the user's query
147
- Arguments available: query: string [mandatory], data_type: string [optional, either 'pdf', 'patent' or None (classic web search)], limit: integer [optional, default = 5]
148
  """
149
  endpoint = DUCKDUCKGO_BASE + "/search"
150
- data = await fake_post_data_to_api(endpoint, query=query, data_type=data_type, max_references=limit)
151
  if isinstance(data, tuple) and data[0] is None:
152
  return f"An error while searching publications: {data[1]}"
153
  results = data["results"]
 
102
  Arguments available: keywords: string [mandatory, separated by space], limit [mandatory, default = 5], release: string [optional, filter] (the release version (e.g. 18, 9, 19, ...), generally the first number of the full version), wg: string [optional, filter] = working group (S1, C4, SP, ...), spec_type: string [optional, filter] (either TS or TR), mode [mandatory, default = 'and'] = search mode (and = all keywords must be in the search, or = at least one keyword in the search)
103
  """
104
  endpoint = DOC3GPPFINDER_BASE + "/search-spec"
105
+ body = {
106
  "keywords": keywords,
 
 
 
107
  "mode": mode
108
+ }
109
+
110
+ if release is not None:
111
+ body['release'] = release
112
+ if wg is not None:
113
+ body['wg'] = wg
114
+ if spec_type is not None:
115
+ body['spec_type'] = spec_type
116
+
117
+ data = await post_data_to_api(endpoint, body)
118
  if isinstance(data, tuple) and data[0] is None:
119
  return f"An error has occured while searching specifications"
120
  results = data['results'][:min(len(data['results'])-1, limit)]
 
135
  Arguments available: doc_ids: list of string [mandatory], release: integer [optional for every case]
136
  """
137
  endpoint = DOC3GPPFINDER_BASE + "/batch"
138
+ body = {
139
+ "doc_ids": doc_ids,
140
+ }
141
+ if release is not None:
142
+ body['release'] = release
143
+ data = await post_data_to_api(endpoint, body)
144
  if isinstance(data, tuple) and data[0] is None:
145
  return f"An error while searching publications: {data[1]}"
146
  results = data["results"]
 
152
  # PTT Endpoints
153
 
154
  @mcp.tool()
155
+ async def search_documents_web(query: str, data_type: str = "web", limit: int = 5):
156
  """
157
  Search on the Web (thanks to DuckDuckGo) documents based on the user's query
158
+ Arguments available: query: string [mandatory], data_type: string [optional, either 'pdf', 'patent' or 'web', default = 'web'], limit: integer [optional, default = 5]
159
  """
160
  endpoint = DUCKDUCKGO_BASE + "/search"
161
+ data = await fake_post_data_to_api(endpoint, {"query": query, "data_type": data_type, 'max_references': limit})
162
  if isinstance(data, tuple) and data[0] is None:
163
  return f"An error while searching publications: {data[1]}"
164
  results = data["results"]