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

Commit

Permalink
fixing some prompt logic
Browse files Browse the repository at this point in the history
  • Loading branch information
codebanesr committed Sep 30, 2023
1 parent 37e14d6 commit e29cdf6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
3 changes: 3 additions & 0 deletions llm-server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pathspec==0.11.2
pathy==0.10.2
pinecone-client==2.2.2
portalocker==2.7.0
prance==23.6.21.0
preshed==3.0.8
protobuf==4.24.2
pydantic==1.10.11
Expand All @@ -92,6 +93,8 @@ regex==2023.6.3
requests==2.31.0
rfc3339-validator==0.1.4
rpds-py==0.10.2
ruamel.yaml==0.17.32
ruamel.yaml.clib==0.2.7
safetensors==0.3.1
six==1.16.0
smart-open==6.3.0
Expand Down
7 changes: 6 additions & 1 deletion llm-server/routes/root_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,15 @@ def handle_request(data: Dict[str, Any]) -> Any:
) or json.loads(fetch_swagger_text(swagger_url))

try:
if not hasSingleIntent(swagger_doc, text):
k = hasSingleIntent(swagger_doc, text)
if k == False:
return run_workflow(
WorkflowData(text, headers, server_base_url, swagger_url), swagger_doc
)
elif(k == True):
raise "Try match and call"
else:
return {"response": k}
except Exception as e:
print(e)

Expand Down
20 changes: 13 additions & 7 deletions llm-server/utils/detect_multiple_intents.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,17 @@ def getSummaries(swagger_doc: Any):
def hasSingleIntent(swagger_doc: Any, user_requirement: str) -> bool:
summaries = getSummaries(swagger_doc)
_DEFAULT_TEMPLATE = """
User: Here is a list of API summaries:
{summaries}
You are an AI chatbot equipped with the capability to interact with APIs on behalf of users. However, users may also ask you general questions that do not necessitate API calls.
Can one of these api's suffice the users request? Please reply with either "YES" or "NO" with explanation
**User Input:**
```
User: Here is a list of API summaries:
{summaries}
User requirement:
{user_requirement}
If the request can be completed with a single API call, please reply with "__ONE__". If it requires multiple API calls, respond with "__MULTIPLE__". If the query is a general question and does not require an API call, provide the answer to the question.
User Requirement:
{user_requirement}
"""
llm = get_llm()
PROMPT = PromptTemplate(
Expand All @@ -100,7 +104,9 @@ def hasSingleIntent(swagger_doc: Any, user_requirement: str) -> bool:

print(f"Summary call response: {response}")

if "yes" in response.lower():
if "__ONE__" in response.upper():
return True
else:
elif "__MULTIPLE__" in response.upper():
return False
else:
return response

0 comments on commit e29cdf6

Please sign in to comment.