Skip to content

Commit

Permalink
Merge pull request #200 from openchatai/fix/nullability_issue
Browse files Browse the repository at this point in the history
Modified slack truncated json, added prompts
  • Loading branch information
davidsmithdevops authored Oct 29, 2023
2 parents 4a0bfeb + ffc1f5d commit 8d13607
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions _swaggers/slack_truncated.json
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@
"tags": [
"chat"
],
"description": "Sends a message to a channel.",
"description": "Post messages to public channels, private channels, direct messages, and multi-person direct messages.",
"externalDocs": {
"description": "API method documentation",
"url": "https://api.slack.com/methods/chat.postMessage"
Expand Down Expand Up @@ -2262,7 +2262,7 @@
"tags": [
"conversations"
],
"description": "Initiates a public or private channel-based conversation",
"description": "Creates a new public or private channel.",
"externalDocs": {
"description": "API method documentation",
"url": "https://api.slack.com/methods/conversations.create"
Expand Down Expand Up @@ -3448,7 +3448,7 @@
"tags": [
"conversations"
],
"description": "Opens or resumes a direct message or multi-person direct message.",
"description": "Opens or resumes an existing direct message or multi-person direct message.",
"externalDocs": {
"description": "API method documentation",
"url": "https://api.slack.com/methods/conversations.open"
Expand Down
2 changes: 1 addition & 1 deletion llm-server/integrations/custom_prompts/slack.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
flow_generation_prompts = ""

api_generation_prompt = "Use encoded value for channel"
api_generation_prompt = "Use encoded value for channel. When sending message, also identify whether the message is being sent to a channel or a user and generate body accordingly."
2 changes: 1 addition & 1 deletion llm-server/integrations/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def process_state(headers: Dict[str, Any]) -> Dict[str, Any]:
cache = mongo.app_cache.find_one({"app": "slack"}, {"_id": 0})

# Check if cache exists and is less than 2 minutes old
if cache and now - cache["timestamp"] < 120:
if cache and now - cache["timestamp"] < 600:
print("Returning cached data")
return cache

Expand Down
6 changes: 3 additions & 3 deletions llm-server/routes/root_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def handle_request(data: Dict[str, Any]) -> Any:
) = extract_data(data)

log_user_request(text)

check_required_fields(base_prompt, text, swagger_url)

swagger_doc = get_swagger_doc(swagger_url)
Expand Down Expand Up @@ -124,16 +123,17 @@ def check_required_fields(base_prompt: str, text: str, swagger_url: str) -> None


def get_swagger_doc(swagger_url: str) -> ResolvingParser:
logging.info(f"Swagger url: {swagger_url}")
swagger_doc: Optional[Dict[str, Any]] = mongo.swagger_files.find_one(
{"meta.swagger_url": swagger_url}, {"meta": 0, "_id": 0}
)

if swagger_url.startswith("http:") or swagger_url.startswith("https:"):
return ResolvingParser(url=swagger_url)
elif swagger_url.endswith(".json") or swagger_url.endswith(".yaml"):
return ResolvingParser(url=shared_folder + swagger_url)
elif swagger_doc:
return ResolvingParser(spec_string=swagger_doc)
else:
return ResolvingParser(url=shared_folder + swagger_url)


def handle_existing_workflow(
Expand Down
4 changes: 2 additions & 2 deletions llm-server/routes/workflow/extractors/extract_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def gen_body_from_schema(
model="gpt-3.5-turbo-16k",
temperature=0,
)

api_generation_prompt = None
if app:
module_name = f"integrations.custom_prompts.{app}"
module = importlib.import_module(module_name)
Expand All @@ -43,7 +43,7 @@ def gen_body_from_schema(
HumanMessage(content="prev api responses: {}".format(prev_api_response)),
HumanMessage(content="current_state: {}".format(current_state)),
HumanMessage(
content="Given the provided information, generate the appropriate minified JSON payload to use as body for the API request. If a user doesn't provide a required parameter, use sensible defaults for required params, and leave optional params"
content="Given the provided information, generate the appropriate minified JSON payload to use as body for the API request. If a user doesn't provide a required parameter, use sensible defaults for required params, and leave optional params."
),
]

Expand Down
8 changes: 4 additions & 4 deletions llm-server/routes/workflow/utils/detect_multiple_intents.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,16 @@ def generate_consolidated_requirement(
conversation_str = join_conversations(history)
messages = [
SystemMessage(
content="You are an AI model designed to perform text substitution. You will receive user input. If the user's input contains references such as `the` or `this` etc... you should replace these words with the specific objects or concepts they refer to within the ongoing conversation, if applicable. However, if the user's input already contains all the necessary information, you should return the original user text."
content="You are an AI model designed to generate a standalone prompt. The user message may also contain instructions for you as a bot, like generating some content in this message. You should act accordingly"
),
HumanMessage(
content="You will receive user input. Based on the conversation and the current user prompt, I want you to convert the user prompt into a standalone prompt if the user prompt references something in conversation history."
),
HumanMessage(
content="Conversation History: ({}), \n\n Current User input: ({}).".format(
conversation_str, user_input
),
),
HumanMessage(
content="Give me the user input after substituting the references."
),
]
content = chat(messages).content
return content
Expand Down

0 comments on commit 8d13607

Please sign in to comment.