MCPcopy Create free account
hub / github.com/nlweb-ai/NLWeb / list_prompts

Function list_prompts

AskAgent/python/chatbot_interface.py:125–174  ·  view source on GitHub ↗

Forward list_prompts request to NLWeb

()

Source from the content-addressed store, hash-verified

123
124 @server.list_prompts()
125 async def list_prompts() -> list[Prompt]:
126 """Forward list_prompts request to NLWeb"""
127 result = await forward_to_nlweb("list_prompts", {}, server_url, endpoint)
128
129 if "error" in result:
130 # Fallback to default if server is unavailable
131 return [
132 Prompt(
133 name="ask_nlw",
134 description="Connects with the NLWeb server to answer questions",
135 arguments=[
136 PromptArgument(
137 name="query",
138 description="query string in english",
139 required=True
140 )
141 ]
142 )
143 ]
144
145 # Extract prompts from the response
146 try:
147 prompts = result.get("response", {}).get("prompts", [])
148 return [Prompt(
149 name=prompt["id"],
150 description=prompt["description"],
151 arguments=[
152 PromptArgument(
153 name="query",
154 description="query string in english",
155 required=True
156 )
157 ]
158 ) for prompt in prompts]
159 except (KeyError, TypeError) as e:
160 print(f"Error processing prompts: {e!s}", file=sys.stderr)
161 # Fallback to default
162 return [
163 Prompt(
164 name="ask_nlw",
165 description="Connects with the NLWeb server to answer questions",
166 arguments=[
167 PromptArgument(
168 name="query",
169 description="query string in english",
170 required=True
171 )
172 ]
173 )
174 ]
175
176 @server.call_tool()
177 async def call_tool(name: str, arguments: dict) -> list[TextContent]:

Callers

nothing calls this directly

Calls 2

forward_to_nlwebFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected