Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Merge pull request #97 from openchatai/refactor/api_flows
Browse files Browse the repository at this point in the history
using prance to resolve refs, hence this will remove lot of unnecessa…
  • Loading branch information
codebanesr authored Sep 30, 2023
2 parents dac6255 + e29cdf6 commit 878c1b7
Show file tree
Hide file tree
Showing 23 changed files with 618 additions and 520 deletions.
16 changes: 8 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ services:
networks:
- opencopilot_network

# adminer:
# image: adminer
# ports:
# - "8080:8080"
# depends_on:
# - mysql
# networks:
# - opencopilot_network
adminer:
image: adminer
ports:
- "8080:8080"
depends_on:
- mysql
networks:
- opencopilot_network

qdrant:
image: qdrant/qdrant
Expand Down
17 changes: 16 additions & 1 deletion llm-server/api_caller/planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,25 @@ def _create_api_controller_agent(
) -> AgentExecutor:
get_llm_chain = LLMChain(llm=llm, prompt=PARSING_GET_PROMPT)
post_llm_chain = LLMChain(llm=llm, prompt=PARSING_POST_PROMPT)
put_llm_chain = LLMChain(llm=llm, prompt=PARSING_PUT_PROMPT)
delete_llm_chain = LLMChain(llm=llm, prompt=PARSING_DELETE_PROMPT)
path_llm_chain = LLMChain(llm=llm, prompt=PARSING_PATCH_PROMPT)
tools: List[BaseTool] = [
RequestsGetToolWithParsing(
requests_wrapper=requests_wrapper, llm_chain=get_llm_chain
),
RequestsPostToolWithParsing(
requests_wrapper=requests_wrapper, llm_chain=post_llm_chain
),
RequestsPutToolWithParsing(
requests_wrapper=requests_wrapper, llm_chain=put_llm_chain
),
# RequestsDeleteToolWithParsing(
# requests_wrapper=requests_wrapper, llm_chain=delete_llm_chain
# ),
# RequestsPatchToolWithParsing(
# requests_wrapper=requests_wrapper, llm_chain=path_llm_chain
# ),
]
prompt = PromptTemplate(
template=API_CONTROLLER_PROMPT,
Expand Down Expand Up @@ -293,7 +305,7 @@ def _create_and_run_api_controller_agent(plan_str: str) -> str:
"{method} {route}".format(method=method, route=route.split("?")[0])
for method, route in matches
]
endpoint_docs_by_name = {name: docs for name, _, docs in api_spec.endpoints}
# endpoint_docs_by_name = {name: docs for name, _, docs in api_spec.endpoints}
docs_str = ""
for endpoint_name in endpoint_names:
found_match = False
Expand Down Expand Up @@ -359,5 +371,8 @@ def create_openapi_agent(
callback_manager=callback_manager,
verbose=verbose,
maxIterations=2,
early_stopping_method="generate", # allow one last pass to generate correct response
max_execution_time=20, # kill after 20 seconds
handle_parsing_errors=True,
**(agent_executor_kwargs or {}),
)
4 changes: 2 additions & 2 deletions llm-server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def handle() -> Response:
data = request.get_json()
try:
response = handle_request(data)
return jsonify(response), 200
return jsonify(response)
except Exception as e:
return jsonify({"response": str(e)}), 500
return jsonify({"response": str(e)})


@app.errorhandler(500)
Expand Down
141 changes: 0 additions & 141 deletions llm-server/notebooks/openapi.ipynb

This file was deleted.

Loading

0 comments on commit 878c1b7

Please sign in to comment.