Spaces:
Running
Running
Update app/main.py
Browse files- app/main.py +4 -3
app/main.py
CHANGED
@@ -4,9 +4,10 @@ from langgraph.graph import StateGraph, START, END
|
|
4 |
from typing import TypedDict, Optional
|
5 |
import io
|
6 |
from PIL import Image
|
|
|
7 |
|
8 |
#OPEN QUESTION: SHOULD WE PASS ALL PARAMS FROM THE ORCHESTRATOR TO THE NODES INSTEAD OF SETTING IN EACH MODULE?
|
9 |
-
|
10 |
# Define the state schema
|
11 |
class GraphState(TypedDict):
|
12 |
query: str
|
@@ -20,7 +21,7 @@ class GraphState(TypedDict):
|
|
20 |
|
21 |
# node 2: retriever
|
22 |
def retrieve_node(state: GraphState) -> GraphState:
|
23 |
-
client = Client("giz/chatfed_retriever") # HF repo name
|
24 |
context = client.predict(
|
25 |
query=state["query"],
|
26 |
reports_filter=state.get("reports_filter", ""),
|
@@ -33,7 +34,7 @@ def retrieve_node(state: GraphState) -> GraphState:
|
|
33 |
|
34 |
# node 3: generator
|
35 |
def generate_node(state: GraphState) -> GraphState:
|
36 |
-
client = Client("giz/chatfed_generator")
|
37 |
result = client.predict(
|
38 |
query=state["query"],
|
39 |
context=state["context"],
|
|
|
4 |
from typing import TypedDict, Optional
|
5 |
import io
|
6 |
from PIL import Image
|
7 |
+
import os
|
8 |
|
9 |
#OPEN QUESTION: SHOULD WE PASS ALL PARAMS FROM THE ORCHESTRATOR TO THE NODES INSTEAD OF SETTING IN EACH MODULE?
|
10 |
+
HF_TOKEN = os.environ.get("HF_TOKEN")
|
11 |
# Define the state schema
|
12 |
class GraphState(TypedDict):
|
13 |
query: str
|
|
|
21 |
|
22 |
# node 2: retriever
|
23 |
def retrieve_node(state: GraphState) -> GraphState:
|
24 |
+
client = Client("giz/chatfed_retriever", hf_token=HF_TOKEN) # HF repo name
|
25 |
context = client.predict(
|
26 |
query=state["query"],
|
27 |
reports_filter=state.get("reports_filter", ""),
|
|
|
34 |
|
35 |
# node 3: generator
|
36 |
def generate_node(state: GraphState) -> GraphState:
|
37 |
+
client = Client("giz/chatfed_generator", hf_token=HF_TOKEN)
|
38 |
result = client.predict(
|
39 |
query=state["query"],
|
40 |
context=state["context"],
|