Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,22 +9,19 @@ from langchain.agents import AgentExecutor, create_openai_functions_agent
|
|
9 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
10 |
from langchain_core.messages import AIMessage, HumanMessage
|
11 |
from langchain.tools import StructuredTool
|
|
|
12 |
from gptcache import cache
|
13 |
-
from gptcache.adapter.langchain_models import
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
|
18 |
-
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
19 |
|
20 |
-
onnx = Onnx()
|
21 |
-
data_manager = get_data_manager(CacheBase("sqlite"), VectorBase("faiss", dimension=onnx.dimension))
|
22 |
cache.init(
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
cache.set_openai_key()
|
28 |
|
29 |
def repo_get_all_employees_from_database():
|
30 |
url = "https://api.airtable.com/v0/appopGmlHujYnd6Vw/Interviewers?maxRecords=100&view=Grid%20view"
|
@@ -85,7 +82,7 @@ class GetEmployees(BaseModel):
|
|
85 |
duration_hours: int = Field(..., description="Required duration of the availability in hours")
|
86 |
|
87 |
# llm = ChatOpenAI(temperature=1.0, model_name="gpt-3.5-turbo", openai_api_key=OPENAI_API_KEY)
|
88 |
-
llm =
|
89 |
|
90 |
tools = [
|
91 |
StructuredTool.from_function(
|
|
|
9 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
10 |
from langchain_core.messages import AIMessage, HumanMessage
|
11 |
from langchain.tools import StructuredTool
|
12 |
+
# cache
|
13 |
from gptcache import cache
|
14 |
+
from gptcache.adapter.langchain_models import LangChainChat
|
15 |
+
|
16 |
+
def get_msg(data, **_):
|
17 |
+
return data.get("messages")[-1].content
|
18 |
|
|
|
19 |
|
|
|
|
|
20 |
cache.init(
|
21 |
+
pre_embedding_func=get_msg,
|
22 |
+
)
|
23 |
+
|
24 |
+
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
25 |
|
26 |
def repo_get_all_employees_from_database():
|
27 |
url = "https://api.airtable.com/v0/appopGmlHujYnd6Vw/Interviewers?maxRecords=100&view=Grid%20view"
|
|
|
82 |
duration_hours: int = Field(..., description="Required duration of the availability in hours")
|
83 |
|
84 |
# llm = ChatOpenAI(temperature=1.0, model_name="gpt-3.5-turbo", openai_api_key=OPENAI_API_KEY)
|
85 |
+
llm = LangChainChat(llm=ChatOpenAI(temperature=1.0, model_name="gpt-3.5-turbo", openai_api_key=OPENAI_API_KEY))
|
86 |
|
87 |
tools = [
|
88 |
StructuredTool.from_function(
|