Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit 878c1b7

Browse files
authored
Merge pull request #97 from openchatai/refactor/api_flows
using prance to resolve refs, hence this will remove lot of unnecessa…
2 parents dac6255 + e29cdf6 commit 878c1b7

23 files changed

+618
-520
lines changed

docker-compose.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ services:
7878
networks:
7979
- opencopilot_network
8080

81-
# adminer:
82-
# image: adminer
83-
# ports:
84-
# - "8080:8080"
85-
# depends_on:
86-
# - mysql
87-
# networks:
88-
# - opencopilot_network
81+
adminer:
82+
image: adminer
83+
ports:
84+
- "8080:8080"
85+
depends_on:
86+
- mysql
87+
networks:
88+
- opencopilot_network
8989

9090
qdrant:
9191
image: qdrant/qdrant

llm-server/api_caller/planner.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,25 @@ def _create_api_controller_agent(
245245
) -> AgentExecutor:
246246
get_llm_chain = LLMChain(llm=llm, prompt=PARSING_GET_PROMPT)
247247
post_llm_chain = LLMChain(llm=llm, prompt=PARSING_POST_PROMPT)
248+
put_llm_chain = LLMChain(llm=llm, prompt=PARSING_PUT_PROMPT)
249+
delete_llm_chain = LLMChain(llm=llm, prompt=PARSING_DELETE_PROMPT)
250+
path_llm_chain = LLMChain(llm=llm, prompt=PARSING_PATCH_PROMPT)
248251
tools: List[BaseTool] = [
249252
RequestsGetToolWithParsing(
250253
requests_wrapper=requests_wrapper, llm_chain=get_llm_chain
251254
),
252255
RequestsPostToolWithParsing(
253256
requests_wrapper=requests_wrapper, llm_chain=post_llm_chain
254257
),
258+
RequestsPutToolWithParsing(
259+
requests_wrapper=requests_wrapper, llm_chain=put_llm_chain
260+
),
261+
# RequestsDeleteToolWithParsing(
262+
# requests_wrapper=requests_wrapper, llm_chain=delete_llm_chain
263+
# ),
264+
# RequestsPatchToolWithParsing(
265+
# requests_wrapper=requests_wrapper, llm_chain=path_llm_chain
266+
# ),
255267
]
256268
prompt = PromptTemplate(
257269
template=API_CONTROLLER_PROMPT,
@@ -293,7 +305,7 @@ def _create_and_run_api_controller_agent(plan_str: str) -> str:
293305
"{method} {route}".format(method=method, route=route.split("?")[0])
294306
for method, route in matches
295307
]
296-
endpoint_docs_by_name = {name: docs for name, _, docs in api_spec.endpoints}
308+
# endpoint_docs_by_name = {name: docs for name, _, docs in api_spec.endpoints}
297309
docs_str = ""
298310
for endpoint_name in endpoint_names:
299311
found_match = False
@@ -359,5 +371,8 @@ def create_openapi_agent(
359371
callback_manager=callback_manager,
360372
verbose=verbose,
361373
maxIterations=2,
374+
early_stopping_method="generate", # allow one last pass to generate correct response
375+
max_execution_time=20, # kill after 20 seconds
376+
handle_parsing_errors=True,
362377
**(agent_executor_kwargs or {}),
363378
)

llm-server/app.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ def handle() -> Response:
2121
data = request.get_json()
2222
try:
2323
response = handle_request(data)
24-
return jsonify(response), 200
24+
return jsonify(response)
2525
except Exception as e:
26-
return jsonify({"response": str(e)}), 500
26+
return jsonify({"response": str(e)})
2727

2828

2929
@app.errorhandler(500)

llm-server/notebooks/openapi.ipynb

-141
This file was deleted.

0 commit comments

Comments
 (0)