Skip to content

Commit

Permalink
Merge pull request #373 from openchatai/fix/base_prompts
Browse files Browse the repository at this point in the history
removing unused code
  • Loading branch information
codebanesr authored Dec 6, 2023
2 parents 259e55a + af0925f commit f1740c2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 89 deletions.
35 changes: 0 additions & 35 deletions llm-server/routes/root_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,39 +196,6 @@ def get_swagger_doc(swagger_url: str) -> ResolvingParser:
else:
return ResolvingParser(spec_string=swagger_doc)


def handle_existing_workflow(
document: Document, # lagnchaing
text: str,
headers: Headers,
server_base_url: str,
swagger_url: Optional[str],
app: Optional[str],
swagger_doc: ResolvingParser,
session_id: str,
bot_id: str,
) -> ResponseDict:
# use user defined workflows if exists, if not use auto_gen_workflow
_workflow = mongo.workflows.find_one(
{"_id": ObjectId(document.metadata["workflow_id"])}
)

if _workflow is None:
_workflow = mongo.auto_gen_workflows.find_one(
{"_id": ObjectId(document.metadata["workflow_id"])}
)

output = run_workflow(
_workflow,
swagger_doc,
WorkflowData(text, headers, server_base_url, swagger_url, app),
app,
bot_id=bot_id,
)

return output


async def handle_api_calls(
ids: List[str],
swagger_doc: ResolvingParser,
Expand All @@ -250,8 +217,6 @@ async def handle_api_calls(
)

_workflow["swagger_url"] = swagger_url
# m_workflow = mongo.auto_gen_workflows.insert_one(_workflow)
# add_workflow_data_to_qdrant(m_workflow.inserted_id, _workflow, swagger_url)

return output

Expand Down
1 change: 0 additions & 1 deletion llm-server/routes/workflow/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .check_workflow_in_store import *
from .create_workflow_from_operation_ids import *
from .fetch_swagger_text import *
from .get_swagger_op_by_id import *
Expand Down
15 changes: 5 additions & 10 deletions llm-server/routes/workflow/utils/api_retrievers.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
from custom_types.api_operation import ApiOperation_vs
from opencopilot_types.workflow_type import WorkflowFlowType

# push it to the library
from shared.utils.opencopilot_utils.get_vector_store import get_vector_store
from shared.utils.opencopilot_utils import StoreOptions
from utils.chat_models import CHAT_MODELS
from utils import get_chat_model
from utils.get_chat_model import get_chat_model
from typing import Optional, List
from langchain.vectorstores.base import VectorStore
from utils.get_logger import CustomLogger
from utils.llm_consts import vs_thresholds

logger = CustomLogger(module_name=__name__)
chat = get_chat_model(CHAT_MODELS.gpt_3_5_turbo_16k)
Expand All @@ -21,12 +21,10 @@

async def get_relevant_docs(text: str, bot_id: str) -> Optional[str]:
try:
score_threshold = float(os.getenv("SCORE_THRESHOLD_KB", "0.65"))

kb_retriever = knowledgebase.as_retriever(
search_kwargs={
"k": 3,
"score_threshold": score_threshold,
"score_threshold": vs_thresholds.get("kb_score_threshold"),
"filter": {"bot_id": bot_id},
},
)
Expand All @@ -53,12 +51,11 @@ async def get_relevant_docs(text: str, bot_id: str) -> Optional[str]:

async def get_relevant_flows(text: str, bot_id: str) -> List[WorkflowFlowType]:
try:
score_threshold = float(os.getenv("SCORE_THRESHOLD_KB", "0.80"))

flow_retriever = flows.as_retriever(
search_kwargs={
"k": 3,
"score_threshold": score_threshold,
"score_threshold": vs_thresholds.get("flows_score_threshold"),
"filter": {"bot_id": bot_id},
},
)
Expand All @@ -83,12 +80,10 @@ async def get_relevant_flows(text: str, bot_id: str) -> List[WorkflowFlowType]:

async def get_relevant_apis_summaries(text: str, bot_id: str) -> List[ApiOperation_vs]:
try:
score_threshold = float(os.getenv("SCORE_THRESHOLD_KB", "0.75"))

apis_retriever = apis.as_retriever(
search_kwargs={
"k": 3,
"score_threshold": score_threshold,
"score_threshold": vs_thresholds.get("api_score_threshold"),
"filter": {"bot_id": bot_id},
},
)
Expand Down
40 changes: 0 additions & 40 deletions llm-server/routes/workflow/utils/check_workflow_in_store.py

This file was deleted.

2 changes: 0 additions & 2 deletions llm-server/shared/utils/opencopilot_utils/get_vector_store.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os
from langchain.vectorstores.pinecone import Pinecone

from langchain.vectorstores.qdrant import Qdrant
from langchain.vectorstores.base import VectorStore
from .store_type import StoreType
from .config import VECTOR_STORE_INDEX_NAME, PINECONE_TEXT_KEY
from .interfaces import StoreOptions
from .get_embeddings import get_embeddings
import qdrant_client
Expand Down
13 changes: 12 additions & 1 deletion llm-server/utils/llm_consts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import os

from typing import TypedDict

EXPERIMENTAL_FEATURES_ENABLED = os.getenv("EXPERIMENTAL_FEATURES_ENABLED", "NO")
SYSTEM_MESSAGE_PROMPT = "system_message_prompt"
SUMMARIZATION_PROMPT = "summarization_prompt"
X_App_Name = "X-App-Name"

class VsThresholds(TypedDict):
api_score_threshold: float
flows_score_threshold: float
kb_score_threshold: float

vs_thresholds: VsThresholds = {
"api_score_threshold": float(os.getenv("API_SCORE_THRESHOLD", "0.75")),
"flows_score_threshold": float(os.getenv("FLOWS_SCORE_THRESHOLD", "0.75")),
"kb_score_threshold": float(os.getenv("KB_SCORE_THRESHOLD", "0.75"))
}

0 comments on commit f1740c2

Please sign in to comment.