timeki commited on
Commit
72edd2d
1 Parent(s): 99e91d8

- dummy search and answer_search
- langchain_community packages
- typing class
- fix classes import

app.py CHANGED
@@ -1,7 +1,7 @@
1
  from climateqa.engine.embeddings import get_embeddings_function
2
  embeddings_function = get_embeddings_function()
3
 
4
- from climateqa.papers.openalex import OpenAlex
5
  from sentence_transformers import CrossEncoder
6
 
7
  # reranker = CrossEncoder("mixedbread-ai/mxbai-rerank-xsmall-v1")
@@ -30,7 +30,7 @@ from utils import create_user_id
30
  # ClimateQ&A imports
31
  from climateqa.engine.llm import get_llm
32
  from climateqa.engine.vectorstore import get_pinecone_vectorstore
33
- from climateqa.engine.retriever import ClimateQARetriever
34
  from climateqa.engine.reranker import get_reranker
35
  from climateqa.engine.embeddings import get_embeddings_function
36
  from climateqa.engine.chains.prompts import audience_prompts
@@ -113,8 +113,8 @@ async def chat(query,history,audience,sources,reports):
113
  if len(sources) == 0:
114
  sources = ["IPCC"]
115
 
116
- if len(reports) == 0:
117
- reports = []
118
 
119
  inputs = {"user_input": query,"audience": audience_prompt,"sources":sources}
120
  result = agent.astream_events(inputs,version = "v1") #{"callbacks":[MyCustomAsyncHandler()]})
@@ -141,7 +141,6 @@ async def chat(query,history,audience,sources,reports):
141
 
142
  try:
143
  async for event in result:
144
-
145
  if event["event"] == "on_chat_model_stream":
146
  if start_streaming == False:
147
  start_streaming = True
 
1
  from climateqa.engine.embeddings import get_embeddings_function
2
  embeddings_function = get_embeddings_function()
3
 
4
+ from climateqa.knowledge.openalex import OpenAlex
5
  from sentence_transformers import CrossEncoder
6
 
7
  # reranker = CrossEncoder("mixedbread-ai/mxbai-rerank-xsmall-v1")
 
30
  # ClimateQ&A imports
31
  from climateqa.engine.llm import get_llm
32
  from climateqa.engine.vectorstore import get_pinecone_vectorstore
33
+ from climateqa.knowledge.retriever import ClimateQARetriever
34
  from climateqa.engine.reranker import get_reranker
35
  from climateqa.engine.embeddings import get_embeddings_function
36
  from climateqa.engine.chains.prompts import audience_prompts
 
113
  if len(sources) == 0:
114
  sources = ["IPCC"]
115
 
116
+ # if len(reports) == 0: # TODO
117
+ reports = []
118
 
119
  inputs = {"user_input": query,"audience": audience_prompt,"sources":sources}
120
  result = agent.astream_events(inputs,version = "v1") #{"callbacks":[MyCustomAsyncHandler()]})
 
141
 
142
  try:
143
  async for event in result:
 
144
  if event["event"] == "on_chat_model_stream":
145
  if start_streaming == False:
146
  start_streaming = True
climateqa/engine/graph.py CHANGED
@@ -4,7 +4,7 @@ from contextlib import contextmanager
4
 
5
  from langchain.schema import Document
6
  from langgraph.graph import END, StateGraph
7
- from langchain_core.runnables.graph import CurveStyle, NodeColors, MermaidDrawMethod
8
 
9
  from typing_extensions import TypedDict
10
  from typing import List
@@ -37,11 +37,11 @@ class GraphState(TypedDict):
37
  max_year: int = None
38
  documents: List[Document]
39
 
40
- def search(state):
41
- return {}
42
 
43
- def answer_search(state):
44
- return {}
45
 
46
  def route_intent(state):
47
  intent = state["intent"]
 
4
 
5
  from langchain.schema import Document
6
  from langgraph.graph import END, StateGraph
7
+ from langchain_core.runnables.graph import CurveStyle, MermaidDrawMethod
8
 
9
  from typing_extensions import TypedDict
10
  from typing import List
 
37
  max_year: int = None
38
  documents: List[Document]
39
 
40
+ def search(state): #TODO
41
+ return state
42
 
43
+ def answer_search(state):#TODO
44
+ return state
45
 
46
  def route_intent(state):
47
  intent = state["intent"]
climateqa/knowledge/openalex.py CHANGED
@@ -163,7 +163,7 @@ class OpenAlex():
163
  class OpenAlexRetriever(BaseRetriever):
164
  min_year:int = 1960
165
  max_year:int = None
166
- k = 100
167
 
168
  def _get_relevant_documents(
169
  self, query: str, *, run_manager: CallbackManagerForRetrieverRun
 
163
  class OpenAlexRetriever(BaseRetriever):
164
  min_year:int = 1960
165
  max_year:int = None
166
+ k:int = 100
167
 
168
  def _get_relevant_documents(
169
  self, query: str, *, run_manager: CallbackManagerForRetrieverRun
requirements.txt CHANGED
@@ -15,3 +15,4 @@ flashrank==0.2.5
15
  rerankers==0.3.0
16
  torch==2.3.0
17
  nvidia-cudnn-cu12==8.9.2.26
 
 
15
  rerankers==0.3.0
16
  torch==2.3.0
17
  nvidia-cudnn-cu12==8.9.2.26
18
+ langchain-community==0.2