MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / wrapper

Method wrapper

camel/runtime/remote_http_runtime.py:110–140  ·  view source on GitHub ↗
(
                *args, func=func, redirect_stdout=redirect_stdout, **kwargs
            )

Source from the content-addressed store, hash-verified

108 # Create a wrapper that explicitly binds `func`
109 @wraps(inner_func)
110 def wrapper(
111 *args, func=func, redirect_stdout=redirect_stdout, **kwargs
112 ):
113 for key, value in kwargs.items():
114 if isinstance(value, BaseModel):
115 kwargs[key] = value.model_dump()
116
117 resp = requests.post(
118 f"http://{self.host}:{self.port}/{func.get_function_name()}",
119 json=dict(
120 args=args,
121 kwargs=kwargs,
122 redirect_stdout=redirect_stdout,
123 ),
124 )
125 if resp.status_code != 200:
126 logger.error(
127 f"""ailed to execute function:
128 {func.get_function_name()},
129 status code: {resp.status_code},
130 response: {resp.text}"""
131 )
132 return {
133 "error": f"""Failed to execute function:
134 {func.get_function_name()},
135 response: {resp.text}"""
136 }
137 data = resp.json()
138 if redirect_stdout:
139 print(data["stdout"])
140 return json.loads(data["output"])
141
142 func.func = wrapper
143 self.tools_map[func.get_function_name()] = func

Callers

nothing calls this directly

Calls 3

model_dumpMethod · 0.45
get_function_nameMethod · 0.45
jsonMethod · 0.45

Tested by

no test coverage detected