Spaces:
Sleeping
Sleeping
update
Browse files
agent.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import operator
|
| 2 |
import os
|
| 3 |
import time
|
|
|
|
|
|
|
| 4 |
from langchain.chat_models import init_chat_model
|
| 5 |
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage, AnyMessage
|
| 6 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
@@ -15,8 +17,8 @@ from typing_extensions import TypedDict, Annotated
|
|
| 15 |
|
| 16 |
class State(TypedDict):
|
| 17 |
messages: Annotated[list, add_messages]
|
| 18 |
-
content_type: str
|
| 19 |
-
content: str
|
| 20 |
aggregate: Annotated[list, operator.add]
|
| 21 |
# graph_state: str
|
| 22 |
|
|
@@ -85,7 +87,8 @@ def get_graph(llm):
|
|
| 85 |
def make_plan(state: State):
|
| 86 |
|
| 87 |
print("\n-------------------- Starting to create a plan --------------------\n")
|
| 88 |
-
|
|
|
|
| 89 |
# get all messages from the state
|
| 90 |
messages = state["messages"]
|
| 91 |
# append planning message
|
|
|
|
| 1 |
import operator
|
| 2 |
import os
|
| 3 |
import time
|
| 4 |
+
from typing import Optional
|
| 5 |
+
|
| 6 |
from langchain.chat_models import init_chat_model
|
| 7 |
from langchain_core.messages import HumanMessage, SystemMessage, AIMessage, AnyMessage
|
| 8 |
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
|
|
|
|
| 17 |
|
| 18 |
class State(TypedDict):
|
| 19 |
messages: Annotated[list, add_messages]
|
| 20 |
+
content_type: Optional[str]
|
| 21 |
+
content: Optional[str]
|
| 22 |
aggregate: Annotated[list, operator.add]
|
| 23 |
# graph_state: str
|
| 24 |
|
|
|
|
| 87 |
def make_plan(state: State):
|
| 88 |
|
| 89 |
print("\n-------------------- Starting to create a plan --------------------\n")
|
| 90 |
+
if "content_type" in state:
|
| 91 |
+
print("Content is: ", state["content"])
|
| 92 |
# get all messages from the state
|
| 93 |
messages = state["messages"]
|
| 94 |
# append planning message
|
app.py
CHANGED
|
@@ -82,8 +82,8 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
| 82 |
# 2. Fetch Questions
|
| 83 |
print(f"Fetching questions from: {questions_url}")
|
| 84 |
try:
|
| 85 |
-
|
| 86 |
-
response = requests.get("https://agents-course-unit4-scoring.hf.space/questions", timeout=20)
|
| 87 |
response.raise_for_status()
|
| 88 |
questions_data = response.json()
|
| 89 |
#with open('data.json', 'r') as json_file:
|
|
|
|
| 82 |
# 2. Fetch Questions
|
| 83 |
print(f"Fetching questions from: {questions_url}")
|
| 84 |
try:
|
| 85 |
+
response = requests.get(questions_url, timeout=15)
|
| 86 |
+
#response = requests.get("https://agents-course-unit4-scoring.hf.space/questions", timeout=20)
|
| 87 |
response.raise_for_status()
|
| 88 |
questions_data = response.json()
|
| 89 |
#with open('data.json', 'r') as json_file:
|